|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsunlabs.brazil.server.Main (view source)
public class Main
Sample main program for starting an http server.
A new thread is started for each
Server
,
listening on a socket for HTTP connections.
As each connection is accepted, a
Request
object is constructed,
and the registered
Handler
is called.
The configuration properties required by the server
and the handler (or handlers), are gathered
from command line arguments and configuration files specified on the
command line.
The command line arguments are processed in order from left to
right, with the results being accumulated in a properties object.
The server is then started with Server.props
set to the
final value of the properties.
Some of the properties are interpreted directly by the server,
such as the port to listen on, or the handler to use
(see Server
for the complete list). The rest
are arbitrary name/value pairs that may be used by the handler.
Although any of the options may be specified as name/value pairs,
some of them: the ones interpreted by the server, the default
handler (FileHandler
, or Main
,
may be prefixed with a "-".
Those options are explained below:
sunlabs.brazil.handler.FileHandler
)
root
property, it is treated specially. See below.
If the config file is not found in the filesystem,
it is read from the jar file, with this class as the
virtual current directory if a relative path
is provided.
Following these options, any additional additional pairs of
names and values (no "-"'s allowed) are placed directly in
Server.props
.
If the resource "/sunlabs/brazil/server/config" is found, it is used to initialize the configuration.
If a non absolute root
property is specified in a
configuration file, it is modified to resolve relative to the
directory containing the configuration file, and not the directory
in which the server was started. If multiple configuration files
with root properties (or -r
options, or "root" properties)
are specified, the last one tekes precedence.
The "serverClass" property may be set to the string to use as the server's class, instead of "sunlabs.brazil.server.Server"
Constructor Summary | |
---|---|
Main()
|
Method Summary | |
---|---|
static Object |
initObject(Server server,
String name)
|
static void |
initProps(Properties config)
Initialize a properties file with some standard mime types The FileHandler only delivers files whose suffixes
are known to map to mime types. |
static void |
main(String[] args)
|
static boolean |
startServer(Properties config)
Start a server using the supplied properties. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Main()
Method Detail |
---|
public static void main(String[] args) throws Exception
Exception
public static boolean startServer(Properties config)
config
- The configuration properties for the serverpublic static Object initObject(Server server, String name)
public static void initProps(Properties config)
FileHandler
only delivers files whose suffixes
are known to map to mime types. The server is started with
the suffixes: .html, .txt, .gif, .jpg, pdf, .png, .css, .class, and .jar
predefined. If additional types are required, they should be supplied as
command line arguments.
|
Version Kenai-svn-r24, Generated 08/18/09 Copyright (c) 2001-2009, Sun Microsystems. |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |