public class HTTPServletHandler extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PORT_NUMBER
The default port number is 8080.
|
Constructor and Description |
---|
HTTPServletHandler(File warFile)
Creates a new
HTTPServletHandler . |
HTTPServletHandler(File warFile,
int port,
boolean daemon)
Creates a new
HTTPSevletHandler . |
HTTPServletHandler(int port,
boolean daemon)
Creates a new HTTPSevletHandler with no Servlet.
|
HTTPServletHandler(String servletClassName)
Creates a new HTTPSevletHandler.
|
HTTPServletHandler(String servletClassName,
int port,
boolean daemon)
Creates a new HTTPSevletHandler.
|
Modifier and Type | Method and Description |
---|---|
void |
addServlet(String servletClassName,
String virtualPath)
Adds a new servlet.
|
void |
addWAR(File warFile,
String virtualPath)
Adds a WAR file to the server.
|
void |
close()
Disposes the servlet and stops the web server.
|
int |
getPort()
Returns the port the server is accepting connections on.
|
void |
removeServlet(String virtualPath)
Remove a servlet from the server.
|
void |
startServer(int port,
boolean daemon)
Starts the web server.
|
public static final int DEFAULT_PORT_NUMBER
public HTTPServletHandler(int port, boolean daemon) throws IOException
port
- The port of the servlet server.daemon
- true
if the thread listening to connection should be a
daemon thread, false
otherwise.IOException
- if the servlet container cannot be started.public HTTPServletHandler(File warFile) throws ServletException, IOException
HTTPServletHandler
. This servlet handler
starts a web server on port 8080 and wait for calls from the
XINSServiceCaller
.
Note that all the libraries used by this WAR file should already be in the classpath.
warFile
- the war file of the application to deploy, cannot be
null
.ServletException
- if the servlet cannot be initialized.IOException
- if the servlet container cannot be started.public HTTPServletHandler(File warFile, int port, boolean daemon) throws ServletException, IOException
HTTPSevletHandler
. This servlet handler
starts a web server on the specified port and waits for calls from the XINSServiceCaller.
Note that all the libraries used by this WAR file should already be in
the classpath.warFile
- the war file of the application to deploy, cannot be
null
.port
- The port of the servlet server.daemon
- true
if the thread listening to connection should be a
daemon thread, false
otherwise.ServletException
- if the servlet cannot be initialized.IOException
- if the servlet container cannot be started.public HTTPServletHandler(String servletClassName) throws ServletException, IOException
servletClassName
- The name of the servlet's class to load, cannot be null
.ServletException
- if the servlet cannot be initialized.IOException
- if the servlet container cannot be started.public HTTPServletHandler(String servletClassName, int port, boolean daemon) throws ServletException, IOException
servletClassName
- The name of the servlet's class to load, cannot be null
.port
- The port of the servlet server.daemon
- true
if the thread listening to connection should be a
daemon thread, false
otherwise.ServletException
- if the servlet cannot be initialized.IOException
- if the servlet container cannot be started.public void addWAR(File warFile, String virtualPath) throws ServletException
warFile
- The war file of the application to deploy, cannot be null
.virtualPath
- The virtual path of the HTTP server that links to this WAR file, cannot be null
.ServletException
- if the servlet cannot be initialized.public void addServlet(String servletClassName, String virtualPath) throws ServletException
servletClassName
- The name of the servlet's class to load, cannot be null
.virtualPath
- The virtual path of the HTTP server that links to this WAR file, cannot be null
.ServletException
- if the servlet cannot be initialized.public void removeServlet(String virtualPath)
virtualPath
- The virtual path of the servlet to remove, cannot be null
.public void startServer(int port, boolean daemon) throws IOException
port
- the port of the servlet server.daemon
- true
if the thread listening to connection should be a
daemon thread, false
otherwise.IOException
- if the web server cannot be started.public int getPort() throws IllegalStateException
8080
.IllegalStateException
- if the port cannot be determined, for example because the server is
not started.public void close()
See http://www.xins.org/.