|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.GenericService SK.gnome.dwarf.GenericServer SK.gnome.dwarf.http.Host
Provides the HTTP host.
This class represents a HTTP host. The host identification strings must be set
via the setHostId(String[])
method. The following identifier types are possible
as the array elements:
Each Host manages a list of Application
objects representing the particular
servlet contexts (or so-called web applications). The getApplication(String)
method
returns the particular Application object for the given context path.
The Host provides automatic deploying of web applications and WAR files. This
feature is disabled by default and can be enabled by specifying the deployment directory via
the setDeployDir(File)
method. See the autoDeploy
method
for more information, too.
A Host instance must contain a HTTPLogFormat
object, which defines
format of the HTTP transfer log messages for all nested web applications, if they do not
use their own log format. If no log format is specified, the ExtendedLogFormat
will
be used by default. A different log format can be simply added to the host, and it will be
automatically used instead of the default one.
Field Summary | |
protected java.util.Map |
applications
The mapping between context paths and web applications. |
protected java.io.File |
deployDir
The deployment directory. |
protected java.lang.String[] |
hostId
The list of host identification strings. |
protected HTTPLogFormat |
logFormat
HTTP log format. |
Fields inherited from class SK.gnome.dwarf.GenericService |
initParameters, parent |
Fields inherited from interface SK.gnome.dwarf.Service |
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED |
Constructor Summary | |
Host(java.lang.String name)
Creates a new Host. |
Method Summary | |
void |
addService(SK.gnome.dwarf.Service service)
Adds the given service to the server. |
protected void |
autoDeploy(SK.gnome.dwarf.Server parent)
Automatically deploys WAR files. |
Application |
getApplication(java.lang.String path)
Returns an Application instance for the given context path. |
java.lang.String |
getContextPath(java.lang.String path)
Returns the context path of the given URI path. |
java.lang.String[] |
getHostId()
Returns the host identifications. |
HTTPLogFormat |
getLogFormat()
Returns the log format. |
void |
init(SK.gnome.dwarf.Server parent)
Initializes the service. |
void |
setDeployDir(java.io.File dir)
Sets the deployment directory. |
void |
setHostId(java.lang.String[] hosts)
Sets the host identification. |
Methods inherited from class SK.gnome.dwarf.GenericServer |
addService, getAuthenticator, getLogger, getParameters, getService, getServices, getServices, removeService, report, shutdown, start, stop |
Methods inherited from class SK.gnome.dwarf.GenericService |
getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getName, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface SK.gnome.dwarf.Service |
getFullName, getName, getState, log, log, login, logout |
Field Detail |
protected java.lang.String[] hostId
Default value: {"localhost", "127.0.0.1"}
getHostId()
protected java.util.Map applications
Contains all applications contained by the Host, mapped by the applications' context paths as returned from their getContextPath method.
protected java.io.File deployDir
This directory is used for the automatic deploying of WAR files.
autoDeploy(Server)
protected HTTPLogFormat logFormat
This field is set automatically by the addService
method
if the service being added to the Host extends the HTTPLogFormat
class.
init(Server)
Constructor Detail |
public Host(java.lang.String name)
Method Detail |
public void setHostId(java.lang.String[] hosts)
Host identification can be either a hostname or an IP address, or a combination of them. The host name denotes a name-based virtual host and the IP address denotes a IP-based virtual hosts. If multiple identifiers are specified, they must be separated by commas.
hosts
- comma-separated list of host names or IP addresseshostId
public java.lang.String[] getHostId()
hostId
public void setDeployDir(java.io.File dir)
dir
- the directorydeployDir
public HTTPLogFormat getLogFormat()
logFormat
public void addService(SK.gnome.dwarf.Service service) throws SK.gnome.dwarf.ServiceException
If a service being added to the Host is an instance of the HTTPLogFormat
class, reference to it is stored in the logFormat
field. This log format will be
used by the contained applications if they do not use their own log formats.
The method does not allow to add a service implementing the Parameters
interface since the HTTPParameters
must be inherited from the HTTP
server object.
SK.gnome.dwarf.ServiceException
public void init(SK.gnome.dwarf.Server parent) throws SK.gnome.dwarf.ServiceException
If the parent server is not an instance of the HTTPServer
class,
the IllegalServiceClassException
is thrown.
If logFormat
field is null, a new ExtendedLogFormat
instance
is added to the Host automatically.
This method calls the autoDeploy
method before the
service is initialized if the deployDir
is not null.
SK.gnome.dwarf.ServiceException
public java.lang.String getContextPath(java.lang.String path)
The list of contained web applications is searched and the context path is returned if a corresponding web application was found. If no application was found for the given path, the empty string is returned, which always identifies the root web application.
public Application getApplication(java.lang.String path)
It searches through the contained web applications and returns the application instance for the given context path, or null if no application was found.
Note that the root application is always mapped to the empty string key.
protected void autoDeploy(SK.gnome.dwarf.Server parent) throws java.io.IOException, SK.gnome.dwarf.ServiceException
This method is called by the init
method before the service is
initialized. It searches for all subdirectories within the deployDir
directory.
If a subdirectory contains the "WEB-INF/web.xml" file, a new WebApplication
instance is created with the rootDir attribute pointing to this subdirectory.
The name as well as the context path of the web application is determined from the name of the subdirectory. But there is one special case: if the subdirectory is named "default", the application will be mapped to the default (root) context, i.e. its getContextPath method will return the empty string.
There are two ways of creating application subdirectories: 1) you can manually copy the whole directory tree containing the web application files, or 2) you can copy just the* WAR file itself. In the second case, the WAR file will be automatically extracted to the corresponding subdirectory first.
Let's say that the top-level web directory is "www". For the local HTTP host
we can create the "www/localhost" subdirectory in it, and enable the automatic
deploying by setting the deployDir
attribute to "www/localhost". If we
then copy the "catalog.war" file to this directory, the HTTP host will create
corresponding "www/localhost/catalog" subdirectory and extract the WAR archive
content to it. Then it will instantiate and configure a new web application with the
name "$catalog", context path "/catalog" and rootDir set to
"www/localhost/catalog".
Once a web application is deployed, the WAR file can be removed from the deployment
directory. However, if you then copy a new WAR file with the same name and a different
content to it, the application files will be updated according to the new file when the
server is started for the next time.
(The server creates a single WEB-INF/deploy.dat file, which stores MD5 binary
digest of the deployed WAR file. Do not delete this file since it is necessary for
the automatic web application files updating.)
If the WAR file is signed, it will be verified prior to deploying.
The host with the automatic deploying enabled can contain also manually configured web applications, but the root directories of these applications must not be located inside the host's deployment directory.
parent
- the parent server of this service
java.io.IOException
- if an error occured during the file operations
SK.gnome.dwarf.ServiceException
- if an error occured during the deploying
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |