org.w3c.jigsaw.http
Class httpd

java.lang.Object
  extended by org.w3c.jigsaw.http.httpd
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Runnable, ServerHandler, ServerInterface, PropertyMonitoring, Status
Direct Known Subclasses:
AdminServer, httpsd, webdavd

public class httpd
extends java.lang.Object
implements ServerInterface, java.lang.Runnable, PropertyMonitoring, java.lang.Cloneable, Status

The server main class. This class can be used either through its main method, to run a full httpd server, or simply by importing it into your app. This latter possibility allows you to export some of your application state through http.

The server itself uses this to report about memory consumption, running threads, etc.


Field Summary
static java.lang.String CHECKURL_P
          Name of the property indicating the URL of Jigsaw's chekpointer.
static java.lang.String CLIENT_BUFSIZE_P
          Nam eof the property giving the client output buffer size.
static java.lang.String CLIENT_DEBUG_P
          Name of the property indicating wether client should be debuged.
static java.lang.String CLIENT_FACTORY_P
          Name of the property indicating the client factory class.
static java.lang.String CLIENT_PRIORITY_P
          Name of the client thread priority property.
static java.lang.String CONFIG_P
          Name of the property giving the server's config directory.
static boolean debug
          debug flag
static java.lang.String DEFHOSTIP_P
          If the Host property is not set (see below), you can select if you want to use FQDN (broken on some jdk implementation) or just the IP address as the default host name, it usually defaults to "false" means, use FQDN.
static java.lang.String DISPLAY_URL_ON_ERROR_P
          Should we show the URL that triggered an error in the error message or not? Displaying it can lead to so-called "cross-scripting" hacks
static java.lang.String DOCURL_P
          Name of the property indicating the URL of Jigsaw's help.
static java.lang.String EDIT_ROOT_P
          Name of the property that indicates the root resource for edit.
static java.lang.String FS_SENSITIVITY
          Name of the property indicating if the file-system is case sensitive.
protected  java.lang.String host
          FIXME check The server host name.
static java.lang.String HOST_P
          Name of the server host property.
protected  int[] instances
           
static java.lang.String KEEP_ALIVE_P
          Name of the server's keep alive flag.
static java.lang.String KEEP_TIMEOUT_P
          Name of the server's connection time out property.
static java.lang.String LENIENT_P
          Name of property indicating the "lenient" mode of HTTP parsing.
static java.lang.String LOGGER_P
          Name of property indicating the logger class to use.
static int MAX_LOADED_STORE
           
static java.lang.String MAX_LOADED_STORE_P
          Max number of store loaded in memory.
protected  int port
          FIXME check The server port.
static java.lang.String PORT_P
          Name of the server port property.
protected  ObservableProperties props
          This server set of properties.
static java.lang.String PROPS_P
          Name of the property giving the path of the property file.
static java.lang.String PUBLIC_P
          Name of the property indicating the public methods allowed on that server.
static java.lang.String REQUEST_TIMEOUT_P
          Name of the server's request time out property.
 FramedResource root
          This server root entity.
static java.lang.String ROOT_CLASS_P
           
static java.lang.String ROOT_NAME_P
          Name of the property giving the name of the root resource.
static java.lang.String ROOT_P
          Name of the property giving the server root directory.
static java.lang.String SERIALIZER_CLASS_P
          Name of the serializer class used to store resources.
static java.lang.String SERVER_GROUP_P
          UNIX - Name of the property that indicates the server group.
static java.lang.String SERVER_SOFTWARE_P
          Name of the server software property.
static java.lang.String SERVER_USER_P
          UNIX - Name of the property that indicates the server user.
static java.lang.String SHUFFLER_PATH_P
          Name of the property giving the shuffler path.
static java.lang.String SPACE_P
          Name of the property giving the server space directory.
static java.lang.String STARTUP_P
          Name of the property indicating the startup classes to load
static int STORE_SIZE_LIMIT
           
static java.lang.String STORE_SIZE_LIMIT_P
          Max number of store loaded in memory.
 java.lang.Thread thread
           
 EventManager timer
           
static java.lang.String TRACE_P
          Name of the server's trace property.
static java.lang.String TRASHDIR_P
          Name of the property indicating the trash directory.
protected  java.net.URL url
          FIXME check for clones This server URL.
static java.lang.String USE_SM_P
          Name of property that indicates if some security manager is required.
static int verscount
          The current internal version counter of Jigsaw.
static java.lang.String VERSCOUNT_P
           
static java.lang.String version
          The current displayed version of Jigsaw.
 
Constructor Summary
httpd()
          Create a new server instance in this process.
 
Method Summary
 boolean checkFileSystemSensitivity()
          Is the underlying file-system case sensitive ?
 void checkpoint()
          Checkpoint all cached data, by saving them to disk.
protected  boolean checkUpgrade(java.lang.String id, ObservableProperties props)
           
protected  void cleanTempDirectory()
          Clean the temp dir.
protected  void cleanup(boolean restart)
          Cleanup the resources associated with this server context.
 ServerHandler clone(ServerHandlerManager shm, java.lang.String id, ObservableProperties props)
          clone this server
 void debug(boolean onoff)
          Turn debugging on/off for this instance of httpd server.
 java.util.Enumeration enumeratePropertySet()
          Enumerate all the registered property sets
 void errlog(Client client, java.lang.String msg)
          Emit a server error on behalf of some client object.
 void errlog(java.lang.Object from, java.lang.String msg)
          The prefered form for reporting errors.
 void errlog(Resource from, java.lang.String msg)
          Another nice way of reporting errors from an HTTPResource.
 void errlog(java.lang.String msg)
          Emit an error on behalf of the server.
 void fatal(java.lang.Exception e, java.lang.String msg)
          Emit a fatal error.
 void fatal(java.lang.String msg)
          Emit a fatal error.
 java.io.File getAuthDirectory()
          Get this server authentication directory.
protected  java.lang.String getBanner()
           
 int getClientBufferSize()
          Get the client's buffer size.
 boolean getClientDebug()
          Get the client's debug flags from the properties.
 boolean getClientKeepConnection()
          Does this server wants clients to try keeping connections alive ?
 int getClientThreadPriority()
          Get the client's threads priority from the properties.
 java.io.File getConfigDirectory()
          Get this server config directory.
 ResourceReference getConfigResource()
          get this server config resource
 int getConnectionTimeOut()
          Get the connection allowed idle time from the properties.
 ResourceContext getDefaultContext()
          Get the default resource context for that server.
 java.lang.String getDocumentationURL()
          Get the full URL of Jigsaw's documentation.
 ResourceReference getEditRoot()
          Get the server's edit root resource.
 java.lang.String getHost()
          Get this server host name.
 java.lang.String getHTMLStatus()
          Give the status of this class as a partial HTML text which will be added into a block level element
 java.lang.String getIdentifier()
          Get this server identifier.
 java.io.File getIndexerDirectory()
          Get this server index directory
 IndexersCatalog getIndexersCatalog()
          get the indexer catalog of this server
 java.net.InetAddress getInetAddress()
          Get the server inet address
 int getLocalPort()
          Get the server local port
 Logger getLogger()
          Get the logger for that server.
protected  MimeParserFactory getMimeClientFactory(Client client)
           
 int getPort()
          Get this server port number.
 ObservableProperties getProperties()
          Get this server properties.
 Resource getPropertySet(java.lang.String name)
          Get a property set matching a specific name
 RealmsCatalog getRealmsCatalog()
          Get this server realm catalog.
 int getRequestTimeOut()
          Get the request allowed time slice from the properties.
 ResourceSpace getResourceSpace()
          Get this server resource space
 ResourceStoreManager getResourceStoreManager()
          Get this server resourcestore manager.
 FramedResource getRoot()
          Get the server current root resource.
 java.io.File getRootDirectory()
          Get this server root directory.
 ResourceReference getRootReference()
          get the resource reference of the root resource of the server
 Shuffler getShuffler(Client client)
          Get a shuffler for this server's client.
 java.lang.String getSoftware()
          Get the server software string.
 java.io.File getSpaceDir()
          Get this server space diretory
 httpdStatistics getStatistics()
          Get this server statistics.
 java.io.File getStoreDirectory()
          Get this server store directory.
 java.io.File getTempDirectory()
          Get temp directory
 java.lang.String getTrashDirectory()
          Get the tracsh directory
 java.net.URL getURL()
          Get the server URL.
 void initialize(ServerHandlerManager shm, java.lang.String identifier, ObservableProperties props)
          Initialize a new HTTP server.
protected  void initializeProperties()
          FIXME protected for now to handle clones Initialize some of the servers instance values from properties.
protected  void initializePropertySets()
           
 boolean isLenient()
          Get the lenient value, tru if we are lenient in HTTP parsing
 ResourceReference loadResource(java.lang.String name)
          Lookup the root store for some resource.
 ResourceReference loadRoot(java.lang.String name)
          Dynamically change the root resource for the server.
protected  void loadStartupClasses()
          startup classes
 void log(Client client, Request request, Reply reply, int nbytes, long duration)
          Emit a log entry.
 void log(java.lang.String msg)
          Emit a log message.
static void main(java.lang.String[] args)
          debugging main
 ReplyInterface perform(RequestInterface req)
          Perform the given request on behalf of this server.
 boolean propertyChanged(java.lang.String name)
          The property monitoring implementation.
 void registerPropertySet(PropertySet set)
          Register a property set to the server.
 void restart()
          Restart the server properly.
 void run()
           
 void shutdown()
          Shutdown the server properly.
 void start()
          start the server it will than startup, and finally run in its own thread.
 void startCheckpoint()
          start the automatic checkpoint
 void trace(Client client, java.lang.String msg)
          Emit a server trace.
 void trace(java.lang.String msg)
          Emit a server trace, on behalf of the server itself.
static void usage()
          this server's usage
 void warning(java.lang.Exception e, java.lang.String msg)
          Emit a warning.
 void warning(java.lang.String msg)
          Emit a warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
The current displayed version of Jigsaw.

See Also:
Constant Field Values

verscount

public static final int verscount
The current internal version counter of Jigsaw. This counter is bumped anytime the configuration needs upgrade.

See Also:
Constant Field Values

debug

public static final boolean debug
debug flag

See Also:
Constant Field Values

VERSCOUNT_P

public static final java.lang.String VERSCOUNT_P
See Also:
Constant Field Values

SERVER_SOFTWARE_P

public static final java.lang.String SERVER_SOFTWARE_P
Name of the server software property. The server software is the string that gets emited by Jigsaw on each reply, to tell the client what server emited the reply.

This property defaults to Jigsaw/1.0a.

See Also:
Constant Field Values

DEFHOSTIP_P

public static final java.lang.String DEFHOSTIP_P
If the Host property is not set (see below), you can select if you want to use FQDN (broken on some jdk implementation) or just the IP address as the default host name, it usually defaults to "false" means, use FQDN.

See Also:
Constant Field Values

HOST_P

public static final java.lang.String HOST_P
Name of the server host property. The host property should be set to the name of the host running this server.

This property defaults to the local host name, although if you want directory listing to work propertly, you might need to provide the full host name (including its domain).

See Also:
Constant Field Values

ROOT_P

public static final java.lang.String ROOT_P
Name of the property giving the server root directory.

The server root directory is used to deduce a bunch of defaults properties, when they don't have any specific values.

This property has no defaults.

See Also:
Constant Field Values

CONFIG_P

public static final java.lang.String CONFIG_P
Name of the property giving the server's config directory.

See Also:
Constant Field Values

SPACE_P

public static final java.lang.String SPACE_P
Name of the property giving the server space directory. The server space directory should contain an index file, built with the indexer.

This property defaults to /WWW.

See Also:
Constant Field Values

PORT_P

public static final java.lang.String PORT_P
Name of the server port property. At initializatiojn time, the server will bind its accepting socket to the host its runs on, and to the provided port.

This property defaults to 8888.

See Also:
Constant Field Values

TRACE_P

public static final java.lang.String TRACE_P
Name of the server's trace property. When set to true, the server will emit some traces indicating its current state by using the logger trace methods. This property should be set to true if you want clients to emit traces.

This property defaults to false.

See Also:
Constant Field Values

KEEP_ALIVE_P

public static final java.lang.String KEEP_ALIVE_P
Name of the server's keep alive flag. This property is used to determine wether this server should keep its connection alive. Keeping connection alive requires this flag to set to true, and clients to be compliant to the keep alive feature as described in HTTP/1.1 specification.

This property defaults to true.

See Also:
Constant Field Values

KEEP_TIMEOUT_P

public static final java.lang.String KEEP_TIMEOUT_P
Name of the server's connection time out property. This property gives, in milliseconds, the timeout to use for connections that remains idel, waiting for an incoming request.

This property defaults to 10000 milliseconds.

See Also:
Constant Field Values

REQUEST_TIMEOUT_P

public static final java.lang.String REQUEST_TIMEOUT_P
Name of the server's request time out property. The request time out property value indicates, in milliseconds, the allowed duration of a request. Any request whose duration exceeds this time out value will be aborted.

This property defaults to 60000.

See Also:
Constant Field Values

CLIENT_PRIORITY_P

public static final java.lang.String CLIENT_PRIORITY_P
Name of the client thread priority property. Every client threads will run at the given priority, which should be in the range of valid threads priority.

This property defaults to Thread.NORM_PRIORITY.

See Also:
Constant Field Values

CLIENT_BUFSIZE_P

public static final java.lang.String CLIENT_BUFSIZE_P
Nam eof the property giving the client output buffer size. Each clients, when not using a shuffler, has to allocate its own output buffer, Output buffer size may increase/decrease significantly the Jigsaw performances, so change it with care.

This property defaults to 8192.

See Also:
Constant Field Values

CLIENT_DEBUG_P

public static final java.lang.String CLIENT_DEBUG_P
Name of the property indicating wether client should be debuged. When debuged, clients emit some traces, through the server logger about their current state.

This property defaults to false.

See Also:
Constant Field Values

USE_SM_P

public static final java.lang.String USE_SM_P
Name of property that indicates if some security manager is required. You usually don't want to run a security manager for the server, except in the unlikely (right now) case that you want the server to be able to host agents.

This property defaults to false.

See Also:
Constant Field Values

LOGGER_P

public static final java.lang.String LOGGER_P
Name of property indicating the logger class to use. The Jigsaw server allows you to implement your own logger. The only logger provided with the core server is the org.w3c.jigsaw.core.CommonLogger, which implements the common log format.

Property defaults to org.w3c.jigsaw.core.CommonLogger

See Also:
Constant Field Values

LENIENT_P

public static final java.lang.String LENIENT_P
Name of property indicating the "lenient" mode of HTTP parsing.

Property defaults to true

See Also:
Constant Field Values

CLIENT_FACTORY_P

public static final java.lang.String CLIENT_FACTORY_P
Name of the property indicating the client factory class.

See Also:
Constant Field Values

SHUFFLER_PATH_P

public static final java.lang.String SHUFFLER_PATH_P
Name of the property giving the shuffler path. This property should be set if you are to use the shuffler. The data shuffler is an external process to whiuch Jigsaw delegates the task of writing back document content to clients. Use this when you think your server isn't fast enough.

This should be an absloute path.

This property has no defaults.

See Also:
Constant Field Values

ROOT_NAME_P

public static final java.lang.String ROOT_NAME_P
Name of the property giving the name of the root resource. Upon startup, or restart, the server will look in its root store a resource whose name is given by this resource, and install it as its root resource.

This property defaults to root.

See Also:
Constant Field Values

ROOT_CLASS_P

public static final java.lang.String ROOT_CLASS_P
See Also:
Constant Field Values

MAX_LOADED_STORE_P

public static final java.lang.String MAX_LOADED_STORE_P
Max number of store loaded in memory.

See Also:
Constant Field Values

MAX_LOADED_STORE

public static final int MAX_LOADED_STORE
See Also:
Constant Field Values

STORE_SIZE_LIMIT_P

public static final java.lang.String STORE_SIZE_LIMIT_P
Max number of store loaded in memory.

See Also:
Constant Field Values

STORE_SIZE_LIMIT

public static final int STORE_SIZE_LIMIT
See Also:
Constant Field Values

PROPS_P

public static final java.lang.String PROPS_P
Name of the property giving the path of the property file. this should be used internally (for restart) only.

This property defaults to config/httpd.props.

See Also:
Constant Field Values

FS_SENSITIVITY

public static final java.lang.String FS_SENSITIVITY
Name of the property indicating if the file-system is case sensitive. This property determines wether Jigsaw will list all files to check for case sensitivity, before creating a resource for that file.

For obvious security reasons, this property defaults to true.

See Also:
Constant Field Values

DOCURL_P

public static java.lang.String DOCURL_P
Name of the property indicating the URL of Jigsaw's help. This URL should point to the URL path of Jigsaw's documentation as served by that server.


STARTUP_P

public static java.lang.String STARTUP_P
Name of the property indicating the startup classes to load


TRASHDIR_P

public static java.lang.String TRASHDIR_P
Name of the property indicating the trash directory.


CHECKURL_P

public static java.lang.String CHECKURL_P
Name of the property indicating the URL of Jigsaw's chekpointer.


PUBLIC_P

public static java.lang.String PUBLIC_P
Name of the property indicating the public methods allowed on that server. This property should provide a | separated list of methods available on that server.

This property defaults to: GET | HEAD | PUT | POST | OPTIONS | DELETE | LINK | UNLINK | TRACE.


EDIT_ROOT_P

public static java.lang.String EDIT_ROOT_P
Name of the property that indicates the root resource for edit. The edit root resource is the one that will show up by default when accessing the admin server from JigAdmin.


SERIALIZER_CLASS_P

public static java.lang.String SERIALIZER_CLASS_P
Name of the serializer class used to store resources.


SERVER_USER_P

public static java.lang.String SERVER_USER_P
UNIX - Name of the property that indicates the server user. When set, the server will try to turn itself to the given user name after initialization. If this fail, the server will abort.

This property has no default value.


SERVER_GROUP_P

public static java.lang.String SERVER_GROUP_P
UNIX - Name of the property that indicates the server group. When set, the server will try to turn itself to the given group name after initialization. If this fail, the server will abort.

This property has no default value.


DISPLAY_URL_ON_ERROR_P

public static java.lang.String DISPLAY_URL_ON_ERROR_P
Should we show the URL that triggered an error in the error message or not? Displaying it can lead to so-called "cross-scripting" hacks


thread

public java.lang.Thread thread

timer

public EventManager timer

instances

protected int[] instances

props

protected ObservableProperties props
This server set of properties.


host

protected java.lang.String host
FIXME check The server host name.


port

protected int port
FIXME check The server port.


root

public FramedResource root
This server root entity.


url

protected java.net.URL url
FIXME check for clones This server URL.

Constructor Detail

httpd

public httpd()
Create a new server instance in this process.

Parameters:
identifier - The server's identifier.
props - The server properties.
Method Detail

propertyChanged

public boolean propertyChanged(java.lang.String name)
The property monitoring implementation.

Specified by:
propertyChanged in interface PropertyMonitoring
Parameters:
name - The name of the property that has changed.
Returns:
A boolean, true if the changed was taken into account, false otherwise.

loadResource

public ResourceReference loadResource(java.lang.String name)
Lookup the root store for some resource.

Specified by:
loadResource in interface ServerInterface
Parameters:
name - The name of the resource to lookup in the root store.
Returns:
The loaded resource, or null.

startCheckpoint

public void startCheckpoint()
start the automatic checkpoint


checkpoint

public void checkpoint()
Checkpoint all cached data, by saving them to disk.

Specified by:
checkpoint in interface ServerInterface

loadRoot

public ResourceReference loadRoot(java.lang.String name)
Dynamically change the root resource for the server. This is kind a dangerous operation !

Specified by:
loadRoot in interface ServerInterface
Parameters:
name - The name of the new root resource, to be found in the root resource store.
Returns:
The new installed root resource, or null if we couldn't load the given resource.

getMimeClientFactory

protected MimeParserFactory getMimeClientFactory(Client client)

loadStartupClasses

protected void loadStartupClasses()
startup classes


initializeProperties

protected void initializeProperties()
                             throws ServerHandlerInitException
FIXME protected for now to handle clones Initialize some of the servers instance values from properties.

Throws:
ServerHandlerInitException - if unable to be initialized.

registerPropertySet

public void registerPropertySet(PropertySet set)
Register a property set to the server.

Parameters:
propSet - The property set to register.

enumeratePropertySet

public java.util.Enumeration enumeratePropertySet()
Enumerate all the registered property sets

Returns:
an enumeration of PropertySet

getPropertySet

public Resource getPropertySet(java.lang.String name)
Get a property set matching a specific name

Returns:
a Resource, the property set found

initializePropertySets

protected void initializePropertySets()

getStatistics

public httpdStatistics getStatistics()
Get this server statistics.


getProperties

public ObservableProperties getProperties()
Get this server properties.

Specified by:
getProperties in interface ServerInterface

checkFileSystemSensitivity

public boolean checkFileSystemSensitivity()
Is the underlying file-system case sensitive ?

Specified by:
checkFileSystemSensitivity in interface ServerInterface
Returns:
A boolean, true if file system is case sensitive, false otherwise.

getDocumentationURL

public java.lang.String getDocumentationURL()
Get the full URL of Jigsaw's documentation.

Specified by:
getDocumentationURL in interface ServerInterface
Returns:
A String encoded URL.

getTrashDirectory

public java.lang.String getTrashDirectory()
Get the tracsh directory

Specified by:
getTrashDirectory in interface ServerInterface

getClientDebug

public final boolean getClientDebug()
Get the client's debug flags from the properties.

Specified by:
getClientDebug in interface ServerInterface

getClientKeepConnection

public final boolean getClientKeepConnection()
Does this server wants clients to try keeping connections alive ?

Specified by:
getClientKeepConnection in interface ServerInterface

getRequestTimeOut

public final int getRequestTimeOut()
Get the request allowed time slice from the properties.

Specified by:
getRequestTimeOut in interface ServerInterface

getConnectionTimeOut

public final int getConnectionTimeOut()
Get the connection allowed idle time from the properties.

Specified by:
getConnectionTimeOut in interface ServerInterface

getClientThreadPriority

public final int getClientThreadPriority()
Get the client's threads priority from the properties.

Specified by:
getClientThreadPriority in interface ServerInterface

getClientBufferSize

public final int getClientBufferSize()
Get the client's buffer size.

Specified by:
getClientBufferSize in interface ServerInterface

getHost

public java.lang.String getHost()
Get this server host name.

Specified by:
getHost in interface ServerInterface

getPort

public int getPort()
Get this server port number.

Specified by:
getPort in interface ServerInterface

getRoot

public FramedResource getRoot()
Get the server current root resource.

Specified by:
getRoot in interface ServerInterface

getRootReference

public ResourceReference getRootReference()
get the resource reference of the root resource of the server


getLogger

public Logger getLogger()
Get the logger for that server.

Returns:
A Logger compatible instance, or null if no logger specified.

getEditRoot

public ResourceReference getEditRoot()
Get the server's edit root resource. The edit root is the one that shows up by default when using JigAdmin It is named "root" in the interface.

Returns:
An HTTPResource.

getURL

public java.net.URL getURL()
Get the server URL.

Specified by:
getURL in interface ServerInterface

getSoftware

public java.lang.String getSoftware()
Get the server software string.

Specified by:
getSoftware in interface ServerInterface

getLocalPort

public int getLocalPort()
Get the server local port

Specified by:
getLocalPort in interface ServerInterface

getIdentifier

public java.lang.String getIdentifier()
Get this server identifier.

Specified by:
getIdentifier in interface ServerHandler
Returns:
A String identifying this server context.

getInetAddress

public java.net.InetAddress getInetAddress()
Get the server inet address

Specified by:
getInetAddress in interface ServerHandler
Returns:
The INET address this server is listening to.

getRootDirectory

public java.io.File getRootDirectory()
Get this server root directory.

Specified by:
getRootDirectory in interface ServerInterface

getSpaceDir

public java.io.File getSpaceDir()
Get this server space diretory


getConfigDirectory

public java.io.File getConfigDirectory()
Get this server config directory.

Specified by:
getConfigDirectory in interface ServerInterface

getAuthDirectory

public java.io.File getAuthDirectory()
Get this server authentication directory.

Specified by:
getAuthDirectory in interface ServerInterface

getStoreDirectory

public java.io.File getStoreDirectory()
Get this server store directory.

Specified by:
getStoreDirectory in interface ServerInterface

getIndexerDirectory

public java.io.File getIndexerDirectory()
Get this server index directory

Specified by:
getIndexerDirectory in interface ServerInterface

getTempDirectory

public java.io.File getTempDirectory()
Get temp directory

Specified by:
getTempDirectory in interface ServerInterface

cleanTempDirectory

protected void cleanTempDirectory()
Clean the temp dir.


getIndexersCatalog

public IndexersCatalog getIndexersCatalog()
get the indexer catalog of this server

Specified by:
getIndexersCatalog in interface ServerInterface

getRealmsCatalog

public RealmsCatalog getRealmsCatalog()
Get this server realm catalog.


getResourceStoreManager

public ResourceStoreManager getResourceStoreManager()
Get this server resourcestore manager.

Specified by:
getResourceStoreManager in interface ServerInterface

getResourceSpace

public ResourceSpace getResourceSpace()
Get this server resource space

Specified by:
getResourceSpace in interface ServerInterface

getDefaultContext

public ResourceContext getDefaultContext()
Get the default resource context for that server.

Specified by:
getDefaultContext in interface ServerInterface

isLenient

public boolean isLenient()
Get the lenient value, tru if we are lenient in HTTP parsing


cleanup

protected void cleanup(boolean restart)
Cleanup the resources associated with this server context. This method should only be called by the server thread itself, when it is requested to perform the cleanup.

Parameters:
restart - If true the server is restarted (reinitialized) straight away.

shutdown

public void shutdown()
Shutdown the server properly. This methods shutdown the server, and clean-up all its associated resources. If the current thread is not the server thread, it unblocks the server thread from its accept() call, and forces it to perform the rest of the shutdown operation itself.

Specified by:
shutdown in interface ServerHandler
See Also:
cleanup(boolean)

restart

public void restart()
Restart the server properly. This methods restarts the server. It cleans-up all its associated resources, and reinitialize it from scratch. If the current thread is not the server thread, it unblocks the server thread from its accept() call, and forces it to perform the rest of the restart operation itself.

Parameters:
reload_properties - Should we reload the properties from the property file, or should we just reinitialize from the current set of properties.
See Also:
cleanup(boolean)

debug

public void debug(boolean onoff)
Turn debugging on/off for this instance of httpd server.

Parameters:
A - boolean, true turns debugging on, flase turns it off.

trace

public void trace(Client client,
                  java.lang.String msg)
Emit a server trace. Traces are used solely for debugging purposes. You should either use log or error to report informations.

Parameters:
client - The client object which wants to report the trace.
msg - The trace message.
See Also:
log(org.w3c.jigsaw.http.Client, org.w3c.jigsaw.http.Request, org.w3c.jigsaw.http.Reply, int, long)

trace

public void trace(java.lang.String msg)
Emit a server trace, on behalf of the server itself.

Specified by:
trace in interface ServerHandler
Parameters:
msg - The trace the server wants to emit.

log

public void log(Client client,
                Request request,
                Reply reply,
                int nbytes,
                long duration)
Emit a log entry.

Parameters:
client - The client whose request is to be logged.
request - The request that has been handled.
reply - The emitted reply.
nbytes - The number of bytes emitted back to the client.
duration - The time it took to process the request.

log

public void log(java.lang.String msg)
Emit a log message.

Specified by:
log in interface ServerHandler
Parameters:
msg - The message to log.

errlog

public void errlog(Client client,
                   java.lang.String msg)
Emit a server error on behalf of some client object.

Parameters:
client - The client.
msg - The error message.

errlog

public void errlog(java.lang.String msg)
Emit an error on behalf of the server.

Specified by:
errlog in interface ServerHandler
Parameters:
msg - The error message.

errlog

public void errlog(java.lang.Object from,
                   java.lang.String msg)
The prefered form for reporting errors.

Parameters:
from - The object that emited the error.
msg - The error message.

errlog

public void errlog(Resource from,
                   java.lang.String msg)
Another nice way of reporting errors from an HTTPResource.

Specified by:
errlog in interface ServerInterface
Parameters:
from - The resource that trigered the error.
msg - The error message.

fatal

public void fatal(java.lang.Exception e,
                  java.lang.String msg)
Emit a fatal error.

Parameters:
e - Any exception that caused the error.
msg - Any additional message.

fatal

public void fatal(java.lang.String msg)
Emit a fatal error.

Parameters:
msg - Any error message

warning

public void warning(java.lang.String msg)
Emit a warning. Warnings are emited, typically if the configuration is inconsistent, and the server can continue its work.

Parameters:
msg - The warning message.

warning

public void warning(java.lang.Exception e,
                    java.lang.String msg)
Emit a warning.

Parameters:
e - Any exception.
msg - Any message.

getShuffler

public Shuffler getShuffler(Client client)
Get a shuffler for this server's client. Whenever possible, we use a shuffler program to speed up communication with the client. This methods return whatever the server deems appropriate for this client shuffler.

Returns:
A Shuffler instance, or null.
See Also:
Shuffler

getBanner

protected java.lang.String getBanner()

run

public void run()
Specified by:
run in interface java.lang.Runnable

perform

public ReplyInterface perform(RequestInterface req)
                       throws ProtocolException,
                              ResourceException
Perform the given request on behalf of this server.

Specified by:
perform in interface ServerInterface
Parameters:
request - The request to perform.
Returns:
A non-null Reply instance.
Throws:
ProtocolException - If some error occurs during processing the request.
ResourceException - If a resource got a fatal error.

checkUpgrade

protected boolean checkUpgrade(java.lang.String id,
                               ObservableProperties props)

initialize

public void initialize(ServerHandlerManager shm,
                       java.lang.String identifier,
                       ObservableProperties props)
                throws ServerHandlerInitException
Initialize a new HTTP server. The server wil first be initialized from the available properties, it will than startup, and finally run in its own thread.

Specified by:
initialize in interface ServerHandler
Parameters:
identifier - The string identifying this server's occurence.
props - A set of properties to initialize from.
shm - The global server handler manager.
Throws:
ServerHandlerInitException - if unable to be initialized.

start

public void start()
           throws ServerHandlerInitException
start the server it will than startup, and finally run in its own thread.

Specified by:
start in interface ServerHandler
Throws:
ServerHandlerInitException - if initialization failed.

clone

public ServerHandler clone(ServerHandlerManager shm,
                           java.lang.String id,
                           ObservableProperties props)
                    throws ServerHandlerInitException
clone this server

Specified by:
clone in interface ServerHandler
Parameters:
shm - The global server handler manager.
id - The new ServerHandler identifier.
props - The properties that overide part of the configuration of the cloned server.
Returns:
A newly created server, sharing the configuration of the cloned server, except for the config options defined by the given property set.
Throws:
ServerHandlerInitException - if unable to be initialized.

getConfigResource

public ResourceReference getConfigResource()
get this server config resource

Specified by:
getConfigResource in interface ServerHandler
Returns:
A ContainerResource instance.

getHTMLStatus

public java.lang.String getHTMLStatus()
Give the status of this class as a partial HTML text which will be added into a block level element

Specified by:
getHTMLStatus in interface Status
Returns:
a String, the generated HTML

usage

public static void usage()
this server's usage


main

public static void main(java.lang.String[] args)
debugging main