de.fhg.igd.semoa.bin
Class ServletLauncher

java.lang.Object
  extended byde.fhg.igd.semoa.bin.ServletLauncher

public class ServletLauncher
extends Object

This tool is used to publish servlets to and retract servlets from the Environment and thereby adjust the corresponding web server links.

There are several perameters for the Servlet-tool:

Version:
"$Id: ServletLauncher.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Roger Hartmann, Jan Peters
See Also:
HttpServer, HttpsServer

Field Summary
static String DESCR
          The command line parameters.
static int HTTP
          Variables denoting the HTTP protocol to provide the servlet for.
static int HTTPS
          Variables denoting the HTTPS protocol to provide the servlet for.
 
Constructor Summary
ServletLauncher()
           
 
Method Summary
protected static String getServletInfo(javax.servlet.http.HttpServlet servlet)
          Returns servlet specific information as String.
static void main(String[] args)
          Publishes a Servlet with the given parameters.
protected static void printUsage()
          Prints usage of the command line parameters to System.out.
static void publish(javax.servlet.Servlet servlet, String servletPath, String servletName, Properties initParams, String basePath, int protocols)
          Publishes a Servlet with the given parameters.
static void publish(String servletClass, String servletPath, String servletName, Properties initParams, String basePath, int protocols)
          Publishes a Servlet with the given parameters.
static void retract(String servletPath, int protocols)
          Retract the servlet registered under the the given path.
static SortedMap servletPaths(int protocols)
          Returns all servlet paths currently registered for the given protocol(s), whereas the paths contain the corresponding web server prefix within the Environment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP

public static final int HTTP
Variables denoting the HTTP protocol to provide the servlet for.

See Also:
Constant Field Values

HTTPS

public static final int HTTPS
Variables denoting the HTTPS protocol to provide the servlet for.

See Also:
Constant Field Values

DESCR

public static final String DESCR
The command line parameters.

See Also:
Constant Field Values
Constructor Detail

ServletLauncher

public ServletLauncher()
Method Detail

publish

public static void publish(String servletClass,
                           String servletPath,
                           String servletName,
                           Properties initParams,
                           String basePath,
                           int protocols)
                    throws ObjectExistsException,
                           javax.servlet.ServletException
Publishes a Servlet with the given parameters. If both protocols HTTP and HTTPS are given, one instance of the servletClass is created, and then linked to the HTTP as well as the HTTPS server. To create two separate servletClass instances for the HTTP resp. the HTTPS server, this method has to be called twice, one time for each protocol. The servlet's method init() is invoked automatically before the link(s) to the corresponding web server(s) is/are established.

Parameters:
servletClass - The servlet's class name.
servletPath - The relative path under which the Servlet will be registered. If null the given the servletName will be used. The servlet URL will then be: (http|https) ://localhost:<webserverPort> /<servletPath>
servletName - The name for the servlet. If this parameter is null, the classname (without package prefix) will be used (see ServletConfig#getServletName()).
initParams - The servlet's init parameters (see ServletConfig#getInitParameter()).
basePath - The servlet specific base path used to construct by ServletContext#getRealPath().
protocols - The protocol(s), to provide the servlet for (HTTP, HTTPS, or HTTP | HTTPS).
Throws:
ObjectExistsException - if a servlet has already been published under the same path.
javax.servlet.ServletException - if an exception has occured during servlet initialization.

publish

public static void publish(javax.servlet.Servlet servlet,
                           String servletPath,
                           String servletName,
                           Properties initParams,
                           String basePath,
                           int protocols)
                    throws ObjectExistsException,
                           javax.servlet.ServletException
Publishes a Servlet with the given parameters. The servlet's method init() is invoked automatically before the link(s) to the corresponding web server(s) is/are established.

Parameters:
servletPath - The relative path under which the Servlet will be registered. If null the given the servletName will be used. The servlet URL will then be: (http|https) ://localhost:<webserverPort> /<servletPath>
servletName - The name for the servlet. If this parameter is null, the classname (without package prefix) will be used (see ServletConfig#getServletName()).
initParams - The servlet's init parameters (see ServletConfig#getInitParameter()).
basePath - The servlet specific base path used to construct by ServletContext#getRealPath().
protocols - The protocol(s), to provide the servlet for (HTTP, HTTPS, or HTTP | HTTPS).
Throws:
ObjectExistsException - if a servlet has already been published under the same path.
javax.servlet.ServletException - if an exception has occured during servlet initialization.

retract

public static void retract(String servletPath,
                           int protocols)
                    throws NoSuchObjectException
Retract the servlet registered under the the given path. Dependent of the selected protocol(s), the link(s) to the corresponding web server(s) is/are retracted if existent. In case one servlet instance has been linked to both web servers (HTTP and HTTPS), it is ensured that the servlet's method destroy() is only invoked (once), if both links are retracted.

Parameters:
servletPath - The relative path under which the Servlet will be registered (see publish()).
protocols - The protocol(s), to retract the servlet from (HTTP, HTTPS, or HTTP | HTTPS).
Throws:
NoSuchObjectException - if no servlet is registered under the given path (dependent of the given protocols). This exception is thrown, before the first web server link is rtracted resp. the destroy() method has been called.

servletPaths

public static SortedMap servletPaths(int protocols)
Returns all servlet paths currently registered for the given protocol(s), whereas the paths contain the corresponding web server prefix within the Environment.

Parameters:
protocols - The protocol(s), to list the servlet paths for (HTTP, HTTPS, or HTTP | HTTPS).
Returns:
a sorted map of CanonicalPath/Servlet entries.

main

public static void main(String[] args)
                 throws Exception
Publishes a Servlet with the given parameters.

Parameters:
args - The command line arguments.
Throws:
Exception

getServletInfo

protected static String getServletInfo(javax.servlet.http.HttpServlet servlet)
Returns servlet specific information as String.

Returns:
servlet specific information as String.

printUsage

protected static void printUsage()
Prints usage of the command line parameters to System.out.



Copyright © Fraunhofer Gesellschaft. All Rights Reserved.