java.lang.Object
|
+--stec.iws.iws
public final class iws
Methods used to initialize, run and stop the server.
Fields
Field
|
Description
|
aliases
|
Used to access, add, remove and change aliases.
|
hosts
|
Used to access, add, remove and change virtual hosts.
|
locales
|
Used to access, add, remove and change locales.
|
messages
|
Used to access, add, remove and change messages.
|
mimetypes
|
Used to access, add, remove and change mimetypes.
|
realms
|
Used to access, add, remove and change realms.
|
resources
|
Used to access, add, remove and change resources.
|
servlets
|
Used to access, add, remove and change servlets.
|
servlet_contexts
|
Used to access, add, remove and change servlet contexts.
|
Methods
Method
|
Description
|
destroy
|
Stops the server's runtime environment.
|
getBaseDirectory
|
Returns the base directory or archive that the server uses to run from.
|
getConfigDirectory
|
Returns the directory or archive path that the server uses to load configuration files from.
|
getDefaultCharset
|
Returns the specified default character encoding.
|
getDefaultContentEncoding
|
Returns the specified default content encoding.
|
getDefaultContentType
|
Returns the specified default content type.
|
getDefaultLanguage
|
Returns the specified default language.
|
getDefaultLocale
|
Returns the specified default locale or the platform's default locale.
|
getFileEncoding
|
Returns the specified file encoding or the platform's default file encoding.
|
getMimeType
|
Returns the MIME type of the specified file.
|
getRealPath
|
Returns the real path for the specified path.
|
getServerVersion
|
Returns the current version of the server.
|
getShutdownCode
|
Returns the numeric code specified when shutdown() was called.
|
getStartTime
|
Returns the time in milliseconds since January 1, 1970 UTC when the server was started.
|
getTemplatesDirectory
|
Returns the directory or archive path that the server uses to load templates from.
|
getWorkDirectory
|
Returns the path to the given work directory.
|
init
|
Initializes the server's runtime environment.
|
isContentNegotiated
|
Returns whether content negotiation is enabled.
|
log
|
Used to log exceptions or errors messages.
|
run
|
Starts and run the server.
|
shutdown
|
Returns whether the server is being shut down. A second form is used by the
administration thread to shut down the server.
|
Example
import stec.iws.iws;
import stec.iws.ServletManager;
import stec.iws.ServletContextImpl;
public class testServer
{
void static main(String[] args)
{
try
{
iws.init(args);
iws.servlets.put("File", "stec.iws.FileServlet");
ServletContextImpl context =
ServletManager.getServletContext("/");
ServletManager.loadServlet(context, "File");
iws.run();
}
catch(Exception ex)
{
log(ex);
}
finally
{
iws.destroy();
}
}
}
aliases
Used to access, add, remove and change aliases.
Syntax
public static Hashtable aliases
Notes
Aliases are automatically loaded when iws.init() is called.
Example
iws.aliases.put("/scripts", "/cgi-bin")
hosts
Used to access, add, remove and change virtual hosts.
Syntax
public static Hashtable hosts
Notes
Hosts are automatically loaded when iws.init() is called.
Example
iws.hosts.put("iob", "./servers/iob")
locales
Used to access, add, remove and change locales.
Syntax
public static Hashtable locales
Notes
Locales are automatically loaded when iws.init() is called.
Example
iws.locales.put("*", "ISO-8859-1")
messages
Used to access, add, remove and change messages.
Syntax
public static Hashtable messages
Notes
Messages are automatically loaded when iws.init() is called.
Example
iws.messages.put("200", "200 OK")
mimetypes
Used to access, add, remove and change mimetypes.
Syntax
public static Hashtable mimetypes
Notes
Mimetypes are automatically loaded when iws.init() is called.
Example
iws.mimetypes.put(".htm", "text/html")
realms
Used to access, add, remove and change realms.
Syntax
public static Hashtable realms
Notes
Realms are automatically loaded when iws.init() is called.
Example
iws.realms.put("default", "stec.iws.FileRealm")
resources
Used to access, add, remove and change resources.
Syntax
public static Hashtable resources
Notes
Resources are automatically loaded when iws.init() is called.
Example
iws.resources.put("/protected", "default")
servlets
Used to access, add, remove and change servlets.
Syntax
public static Hashtable servlets
Notes
Servlets are automatically loaded when iws.init() is called.
Example
iws.servlets.put("FileServlet", "stec.iws.FileServlet")
servlet_contexts
Used to access, add, remove and change servlet contexts.
Syntax
public static Hashtable servlet_contexts
Notes
Servlet Contexts are automatically loaded when iws.init() is called.
Example
iws.servlet_contexts.put("/accounting", "retries=5&timeout=10000")
destroy
Stops the server's runtime environment.
Syntax
public final static void destroy()
Parameters
Returns
Throws
Example
iws.destroy();
getBaseDirectory
Returns the base directory or archive that the server uses to run from.
Syntax
public final static String getBaseDirectory()
Parameters
Returns
String
|
the base directory or archive file.
|
Throws
Example
String base_dir = iws.getBaseDirectory();
getConfigDirectory
Returns the directory or archive path that the server uses to load configuration files from.
Syntax
public final static String getConfigDirectory()
Parameters
Returns
String
|
the directory or archive path that the server uses to load configuration files from.
|
Throws
Example
String config_dir = iws.getConfigDirectory();
getDefaultCharset
Returns the specified default character encoding.
Syntax
public final static String getDefaultCharset()
Parameters
Returns
String
|
the specified default character encoding.
null if none was specified.
|
Throws
Example
String charset = iws.getDefaultCharset();
getDefaultContentEncoding
Returns the specified default content encoding.
Syntax
public final static String[] getDefaultContentEncoding()
Parameters
Returns
String[]
|
the specified default content encoding.
The first element contains the content encoding and the second element
contains the file extension.
null if none was specified.
|
Throws
Example
String charset = iws.getDefaultContentEncoding();
getDefaultContentType
Returns the specified default content type.
Syntax
public final static String[] getDefaultContentType()
Parameters
Returns
String[]
|
the specified default content type.
The first element contains the content type and the second element
contains the file extension.
null if none was specified.
|
Throws
Example
String charset = iws.getDefaultContentType();
getDefaultLanguage
Returns the specified default language.
Syntax
public final static String getDefaultLanguage()
Parameters
Returns
String
|
the specified default language.
null if none was specified.
|
Throws
Example
String language = iws.getDefaultLanguage();
getDefaultLocale
Returns the specified default locale or the platform's default locale.
Syntax
public final static Locale getDefaultLocale()
Parameters
Returns
java.util.Locale
|
the specified default locale or the platform's default locale.
|
Throws
Example
Locale locale = iws.getDefaultLocale();
getFileEncoding
Returns the specified file encoding or the platform's default file encoding.
Syntax
public final static String getFileEncoding()
Parameters
Returns
String
|
the specified file encoding or the platform's default file encoding.
|
Throws
Example
String encoding = iws.getFileEncoding();
getMimeType
Returns the MIME type of the specified file.
Syntax
public final static String getMimeType(String filename)
Parameters
filename
|
the filename to use.
|
Returns
String
|
the associated mime type.
|
Throws
Notes
A files MIME, Multipurpose Internet Mail Extension, type is a Web protocol
for defining a files type.
Example
String mimetype = iws.getMimeType(filename);
getRealPath
Returns the real path for the specified path.
Syntax
public final static String getRealPath(String path)
throws IOException
Parameters
Returns
Throws
IOException
|
any IO exception thrown.
|
Example
String path = iws.getRealPath("./workdir");
getServerVersion
Returns the current version of the server.
Syntax
public final static String getServerVersion()
Parameters
Returns
String
|
the current version of the server.
|
Throws
Example
String version = iws.getServerVersion();
getShutdownCode
Returns the numeric code specified when shutdown() was called.
Syntax
public final static int getShutdownCode()
Parameters
Returns
int
|
the numeric code specified when shutdown was called.
0 to stop the server or 0x7fff to restart the server.
|
Throws
Example
int shutdown_code = iws.getShutdownCode();
getStartTime
Returns the time in milliseconds since January 1, 1970 UTC when the server was started.
Syntax
public final static long getStartTime()
Parameters
Returns
long
|
the time in milliseconds since January 1, 1970 UTC when the server was started.
|
Throws
Example
long start_time = iws.getStartTime();
getTemplatesDirectory
Returns the directory or archive path that the server uses to load templates files from.
Syntax
public final static String getTemplatesDirectory()
Parameters
Returns
String
|
the directory or archive path that the server uses to load templates files from.
|
Throws
Example
String config_dir = iws.getTemplatesDirectory();
getWorkDirectory
Returns the path to the given work directory.
Syntax
public final static String getWorkDirectory(String path)
throws IOException
Parameters
path
|
the working directory.
|
Returns
String
|
the absolute path to the working directory.
|
Throws
IOException
|
any IO exception thrown.
|
Notes
If the specified path is a relative path then the work directory is relative
to the server's base directory.
If the work directory does not exists then it will be created.
Example
String workdir = iws.getWorkDirectory("./upload");
init
Initializes the server's runtime environment.
Syntax
public final static void init(String[] args) throws Exception
Parameters
args
|
an array of strings containing arguments used during the initialization of
the server's runtime environment.
|
Returns
Throws
Notes
Presently the only parameter is an optional base directory that the server
uses to find its configuration files.
Example
iws.init(args);
isContentNegotiated
Returns whether content negotiation is enabled.
Syntax
public final static boolean isContentNegotiated()
Parameters
Returns
boolean
|
whether content negotiation is enabled.
|
Throws
Example
boolean negotiate = iws.isContentNegotiated();
log
Used to log exceptions or errors messages.
Syntax
public final static void log(Throwable exception)
public final static void log(String message)
public final static void log(Throwable exception, String message)
Parameters
exception
|
an Error or Exception object.
|
message
|
event message to log.
|
Returns
Throws
Example
iws.destroy();
run
Starts and run the server.
Syntax
public final static void run() throws Exception
Parameters
Returns
Throws
Example
iws.run();
shutdown
Returns whether the server is being shut down. A second form is used by the
administration thread to shut down the server.
Syntax
public final static boolean shutdown()
public final static void shutdown(int shutdown_code)
Parameters
shutdown_code
|
the numeric code returned to the iws wrapper.
0 to stop the server or 0x7fff to restart the server.
|
Returns
boolean
|
whether the server is being shut down.
|
Throws
Example
iws.shutdown(0);
|