public class EmbeddedServletContainer extends Object
Constructor and Description |
---|
EmbeddedServletContainer(String contextPath)
Create a servlet container.
|
Modifier and Type | Method and Description |
---|---|
void |
addFilter(String filterPath,
Class filterClass)
Add a filter to the container.
|
void |
addServletEndpoint(String servletPath,
Class servletClass)
Add a servlet to the container.
|
void |
addServletEndpoint(String servletPath,
Class servletClass,
Map<String,String> initParams)
Add a servlet to the container.
|
String |
getContextURL()
Return the full URL (including protocol, host, port, context path, servlet path) for the context path.
|
String |
getHost()
Return the hostname the servlet container is bound to.
|
int |
getPort()
Return the port number the servlet container is bound to.
|
String |
getServletURL(String servletPath)
Return the full URL (including protocol, host, port, context path, servlet path) for a servlet path.
|
void |
start()
Start the servlet container.
|
void |
stop()
Stop the servlet container.
|
public EmbeddedServletContainer(String contextPath)
contextPath
- context path for the servlet, it must not be prefixed or append with "/", for the default
context use ""public void addServletEndpoint(String servletPath, Class servletClass, Map<String,String> initParams)
servletPath
- servlet path for the servlet, it should be prefixed with '/", it may contain a wild card at
the end.servletClass
- servlet classinitParams
- a mapping of init parameters for the servlet, or nullpublic void addServletEndpoint(String servletPath, Class servletClass)
servletPath
- servlet path for the servlet, it should be prefixed with '/", it may contain a wild card at
the end.servletClass
- servlet classpublic void addFilter(String filterPath, Class filterClass)
filterPath
- path for the filter, it should be prefixed with '/", it may contain a wild card at
the end.filterClass
- servlet classpublic void start() throws Exception
Exception
- thrown if the container could not start.public String getHost()
public int getPort()
public String getContextURL()
public String getServletURL(String servletPath)
servletPath
- the path which will be expanded to a full URL.public void stop()
Copyright © 2015 Apache Software Foundation. All Rights Reserved.