)
Nested Class Summary |
static class |
HttpServer.StackServlet
A very simple servlet to serve up a text representation of the current
stack traces. |
Field Summary |
protected java.util.Map<org.mortbay.jetty.servlet.Context,java.lang.Boolean> |
defaultContexts
|
protected java.util.List<java.lang.String> |
filterNames
|
protected boolean |
findPort
|
protected org.mortbay.jetty.Connector |
listener
|
static org.apache.commons.logging.Log |
LOG
|
protected org.mortbay.jetty.webapp.WebAppContext |
webAppContext
|
protected org.mortbay.jetty.Server |
webServer
|
Constructor Summary |
HttpServer(java.lang.String name,
java.lang.String bindAddress,
int port,
boolean findPort)
Same as this(name, bindAddress, port, findPort, null); |
HttpServer(java.lang.String name,
java.lang.String bindAddress,
int port,
boolean findPort,
Configuration conf)
Create a status server on the given port. |
Method Summary |
void |
addContext(org.mortbay.jetty.servlet.Context ctxt,
boolean isFiltered)
|
protected void |
addContext(java.lang.String pathSpec,
java.lang.String dir,
boolean isFiltered)
Add a context |
protected void |
addDefaultApps(org.mortbay.jetty.handler.ContextHandlerCollection parent,
java.lang.String appDir)
Add default apps. |
protected void |
addDefaultServlets()
Add default servlets. |
void |
addFilter(java.lang.String name,
java.lang.String classname,
java.util.Map<java.lang.String,java.lang.String> parameters)
Add a filter to the container. |
protected void |
addFilterPathMapping(java.lang.String pathSpec,
org.mortbay.jetty.servlet.Context webAppCtx)
Add the path spec to the filter path mapping. |
void |
addGlobalFilter(java.lang.String name,
java.lang.String classname,
java.util.Map<java.lang.String,java.lang.String> parameters)
Add a global filter to the container. |
void |
addInternalServlet(java.lang.String name,
java.lang.String pathSpec,
java.lang.Class<? extends javax.servlet.http.HttpServlet> clazz)
Deprecated. this is a temporary method |
void |
addServlet(java.lang.String name,
java.lang.String pathSpec,
java.lang.Class<? extends javax.servlet.http.HttpServlet> clazz)
Add a servlet in the server. |
void |
addSslListener(java.net.InetSocketAddress addr,
Configuration sslConf,
boolean needClientAuth)
Configure an ssl listener on the server. |
void |
addSslListener(java.net.InetSocketAddress addr,
java.lang.String keystore,
java.lang.String storPass,
java.lang.String keyPass)
Deprecated. Use addSslListener(InetSocketAddress, Configuration, boolean) |
protected org.mortbay.jetty.Connector |
createBaseListener(Configuration conf)
Create a required listener for the Jetty instance listening on the port
provided. |
protected void |
defineFilter(org.mortbay.jetty.servlet.Context ctx,
java.lang.String name,
java.lang.String classname,
java.util.Map<java.lang.String,java.lang.String> parameters,
java.lang.String[] urls)
Define a filter for a context and set up default url mappings. |
java.lang.Object |
getAttribute(java.lang.String name)
Get the value in the webapp context. |
int |
getPort()
Get the port that the server is on |
protected java.lang.String |
getWebAppsPath()
Get the pathname to the webapps files. |
void |
join()
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Set a value in the webapp context. |
void |
setThreads(int min,
int max)
Set the min, max number of worker threads (simultaneous connections). |
void |
start()
Start the server. |
void |
stop()
stop the server |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOG
public static final org.apache.commons.logging.Log LOG
webServer
protected final org.mortbay.jetty.Server webServer
listener
protected final org.mortbay.jetty.Connector listener
webAppContext
protected final org.mortbay.jetty.webapp.WebAppContext webAppContext
findPort
protected final boolean findPort
defaultContexts
protected final java.util.Map<org.mortbay.jetty.servlet.Context,java.lang.Boolean> defaultContexts
filterNames
protected final java.util.List<java.lang.String> filterNames
HttpServer
public HttpServer(java.lang.String name,
java.lang.String bindAddress,
int port,
boolean findPort)
throws java.io.IOException
- Same as this(name, bindAddress, port, findPort, null);
- Throws:
java.io.IOException
HttpServer
public HttpServer(java.lang.String name,
java.lang.String bindAddress,
int port,
boolean findPort,
Configuration conf)
throws java.io.IOException
- Create a status server on the given port.
The jsp scripts are taken from src/webapps/.
- Parameters:
name
- The name of the serverport
- The port to use on the serverfindPort
- whether the server should start at the given port and
increment by 1 until it finds a free port.conf
- Configuration
- Throws:
java.io.IOException
createBaseListener
protected org.mortbay.jetty.Connector createBaseListener(Configuration conf)
throws java.io.IOException
- Create a required listener for the Jetty instance listening on the port
provided. This wrapper and all subclasses must create at least one
listener.
- Throws:
java.io.IOException
addDefaultApps
protected void addDefaultApps(org.mortbay.jetty.handler.ContextHandlerCollection parent,
java.lang.String appDir)
throws java.io.IOException
- Add default apps.
- Parameters:
appDir
- The application directory
- Throws:
java.io.IOException
addDefaultServlets
protected void addDefaultServlets()
- Add default servlets.
addContext
public void addContext(org.mortbay.jetty.servlet.Context ctxt,
boolean isFiltered)
throws java.io.IOException
- Throws:
java.io.IOException
addContext
protected void addContext(java.lang.String pathSpec,
java.lang.String dir,
boolean isFiltered)
throws java.io.IOException
- Add a context
- Parameters:
pathSpec
- The path spec for the contextdir
- The directory containing the contextisFiltered
- if true, the servlet is added to the filter path mapping
- Throws:
java.io.IOException
setAttribute
public void setAttribute(java.lang.String name,
java.lang.Object value)
- Set a value in the webapp context. These values are available to the jsp
pages as "application.getAttribute(name)".
- Parameters:
name
- The name of the attributevalue
- The value of the attribute
addServlet
public void addServlet(java.lang.String name,
java.lang.String pathSpec,
java.lang.Class<? extends javax.servlet.http.HttpServlet> clazz)
- Add a servlet in the server.
- Parameters:
name
- The name of the servlet (can be passed as null)pathSpec
- The path spec for the servletclazz
- The servlet class
addInternalServlet
@Deprecated
public void addInternalServlet(java.lang.String name,
java.lang.String pathSpec,
java.lang.Class<? extends javax.servlet.http.HttpServlet> clazz)
- Deprecated. this is a temporary method
- Add an internal servlet in the server.
- Parameters:
name
- The name of the servlet (can be passed as null)pathSpec
- The path spec for the servletclazz
- The servlet class
addFilter
public void addFilter(java.lang.String name,
java.lang.String classname,
java.util.Map<java.lang.String,java.lang.String> parameters)
- Add a filter to the container.
- Specified by:
addFilter
in interface FilterContainer
- Parameters:
name
- Filter nameclassname
- Filter class nameparameters
- a map from parameter names to initial values
addGlobalFilter
public void addGlobalFilter(java.lang.String name,
java.lang.String classname,
java.util.Map<java.lang.String,java.lang.String> parameters)
- Add a global filter to the container.
- Specified by:
addGlobalFilter
in interface FilterContainer
- Parameters:
name
- filter nameclassname
- filter class nameparameters
- a map from parameter names to initial values
defineFilter
protected void defineFilter(org.mortbay.jetty.servlet.Context ctx,
java.lang.String name,
java.lang.String classname,
java.util.Map<java.lang.String,java.lang.String> parameters,
java.lang.String[] urls)
- Define a filter for a context and set up default url mappings.
addFilterPathMapping
protected void addFilterPathMapping(java.lang.String pathSpec,
org.mortbay.jetty.servlet.Context webAppCtx)
- Add the path spec to the filter path mapping.
- Parameters:
pathSpec
- The path specwebAppCtx
- The WebApplicationContext to add to
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Get the value in the webapp context.
- Parameters:
name
- The name of the attribute
- Returns:
- The value of the attribute
getWebAppsPath
protected java.lang.String getWebAppsPath()
throws java.io.IOException
- Get the pathname to the webapps files.
- Returns:
- the pathname as a URL
- Throws:
java.io.IOException
- if 'webapps' directory cannot be found on CLASSPATH.
getPort
public int getPort()
- Get the port that the server is on
- Returns:
- the port
setThreads
public void setThreads(int min,
int max)
- Set the min, max number of worker threads (simultaneous connections).
addSslListener
@Deprecated
public void addSslListener(java.net.InetSocketAddress addr,
java.lang.String keystore,
java.lang.String storPass,
java.lang.String keyPass)
throws java.io.IOException
- Deprecated. Use
addSslListener(InetSocketAddress, Configuration, boolean)
- Configure an ssl listener on the server.
- Parameters:
addr
- address to listen onkeystore
- location of the keystorestorPass
- password for the keystorekeyPass
- password for the key
- Throws:
java.io.IOException
addSslListener
public void addSslListener(java.net.InetSocketAddress addr,
Configuration sslConf,
boolean needClientAuth)
throws java.io.IOException
- Configure an ssl listener on the server.
- Parameters:
addr
- address to listen onsslConf
- conf to retrieve ssl optionsneedClientAuth
- whether client authentication is required
- Throws:
java.io.IOException
start
public void start()
throws java.io.IOException
- Start the server. Does not wait for the server to start.
- Throws:
java.io.IOException
stop
public void stop()
throws java.lang.Exception
- stop the server
- Throws:
java.lang.Exception
join
public void join()
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
Copyright © 2009 The Apache Software Foundation