java.lang.Object
|
+--stec.iws.iws
public class iws extends Object
Methods used to initialize, run and stop iServer.
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 iServer runtime environment.
|
getBaseDirectory
|
Returns the base directory or archive that iServer uses to run from.
|
getMimeType
|
Returns the MIME type of the specified file.
|
getServerVersion
|
Returns the current version of iServer.
|
getStartTime
|
Returns the time in milliseconds since January 1, 1970 UTC when the server was started.
|
getWorkDirectory
|
Returns the path to the given work directory.
|
init
|
Initializes the iServer runtime environment.
|
log
|
Used to log exceptions or errors messages.
|
run
|
Starts and run iServer.
|
shutdown
|
Returns whether iServer is being shut down. A second form is used by the
administration thread to shut down iServer.
|
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 iServer runtime environment.
Syntax
public static void destroy()
Parameters
Returns
Throws
Example
iws.destroy();
getBaseDirectory
Returns the base directory or archive that iServer uses to run from.
Syntax
public static String getBaseDirectory()
Parameters
Returns
String
|
the base directory or archive file.
|
Throws
Notes
A files MIME, Multipurpose Internet Mail Extension, type is a Web protocol
for defining a files type.
Example
String base_dir = iws.getBaseDirectory();
getMimeType
Returns the MIME type of the specified file.
Syntax
public 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);
getServerVersion
Returns the current version of iServer.
Syntax
public static String getServerVersion()
Parameters
Returns
String
|
the current version of iServer.
|
Throws
Example
String version = iws.getServerVersion();
getStartTime
Returns the time in milliseconds since January 1, 1970 UTC when the server was started.
Syntax
public 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();
getWorkDirectory
Returns the path to the given work directory.
Syntax
public static String getWorkDirectory(String path)
Parameters
path
|
the working directory.
|
Returns
String
|
the absolute path to the working directory.
|
Throws
Exception
|
any exception thrown.
|
Notes
If the specified path is a relative path then the work directory is relative
to the iServer's base directory.
If the work directory does not exists then it will be created.
Example
String workdir = iws.getWorkDirectory("./upload");
init
Initializes the iServer runtime environment.
Syntax
public static void init()
public static void init(String arg)
public static void init(String[] args)
Parameters
arg
|
a string containing argument to use.
|
args
|
an array of strings containing arguments to iServer.
|
Returns
Throws
Notes
Presently the only parameter is an optional base directory that iServer uses
to find its configuration files.
Example
iws.init(args);
log
Used to log exceptions or errors messages.
Syntax
public static void log(Throwable exception)
public static void log(String message)
public 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 iServer.
Syntax
public static void run() throws Exception
Parameters
Returns
Throws
Example
iws.run();
shutdown
Returns whether iServer is being shut down. A second form is used by the
administration thread to shut down iServer.
Syntax
public static boolean shutdown()
public static void shutdown(int returnCode)
Parameters
returnCode
|
the return code to return to the iws wrapper.
0 to stop iServer or 0x7fff to restart iServer.
|
Returns
boolean
|
whether iServer is being shut down.
|
Throws
Example
iws.shutdown(0);
|