Package cloud.piranha.appserver.impl
Class DefaultWebApplicationServer
- java.lang.Object
-
- cloud.piranha.appserver.impl.DefaultWebApplicationServer
-
- All Implemented Interfaces:
WebApplicationServer
,HttpServerProcessor
public class DefaultWebApplicationServer extends Object implements HttpServerProcessor, WebApplicationServer
The default WebApplicationServer.- Author:
- Manfred Riem ([email protected])
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
async
Stores the async boolean.protected WebApplicationServerRequestMapper
requestMapper
Stores the request mapper.protected HashMap<String,WebApplication>
webApplications
Stores the web applications.
-
Constructor Summary
Constructors Constructor Description DefaultWebApplicationServer()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMapping(String servletContextName, String contextPath)
Add a context path mapping.void
addWebApplication(WebApplication webApplication)
Add the web application.WebApplicationServerResponse
createResponse(HttpServerResponse httpResponse)
Create the web application server response.WebApplicationServerRequestMapper
getRequestMapper()
Get the request mapper.void
initialize()
Initialize the server.boolean
isAsync()
Are we processing the request asynchronously.void
process(HttpServerRequest request, HttpServerResponse response)
Process the request.void
service(WebApplicationServerRequest request, WebApplicationServerResponse response)
Service method.void
setRequestMapper(WebApplicationServerRequestMapper requestMapper)
Set the request mapper.void
start()
Start the server.void
stop()
Stop the server.
-
-
-
Field Detail
-
async
protected boolean async
Stores the async boolean.
-
requestMapper
protected WebApplicationServerRequestMapper requestMapper
Stores the request mapper.
-
webApplications
protected final HashMap<String,WebApplication> webApplications
Stores the web applications.
-
-
Method Detail
-
addMapping
public void addMapping(String servletContextName, String contextPath)
Add a context path mapping.- Parameters:
servletContextName
- the servlet context name.contextPath
- the context path.
-
addWebApplication
public void addWebApplication(WebApplication webApplication)
Add the web application.- Specified by:
addWebApplication
in interfaceWebApplicationServer
- Parameters:
webApplication
- the web application.
-
createResponse
public WebApplicationServerResponse createResponse(HttpServerResponse httpResponse)
Create the web application server response.- Parameters:
httpResponse
- the HTTP server response.- Returns:
- the web application server response.
-
getRequestMapper
public WebApplicationServerRequestMapper getRequestMapper()
Get the request mapper.- Specified by:
getRequestMapper
in interfaceWebApplicationServer
- Returns:
- the request mapper.
-
initialize
public void initialize()
Initialize the server.- Specified by:
initialize
in interfaceWebApplicationServer
-
isAsync
public boolean isAsync()
Are we processing the request asynchronously.- Specified by:
isAsync
in interfaceHttpServerProcessor
- Returns:
- true if we are, false otherwise.
-
process
public void process(HttpServerRequest request, HttpServerResponse response)
Process the request.- Specified by:
process
in interfaceHttpServerProcessor
- Parameters:
request
- the request.response
- the response.
-
service
public void service(WebApplicationServerRequest request, WebApplicationServerResponse response) throws IOException, ServletException
Service method.- Specified by:
service
in interfaceWebApplicationServer
- Parameters:
request
- the request.response
- the response.- Throws:
IOException
- when an I/O error occurs.ServletException
- when a servlet error occurs.
-
setRequestMapper
public void setRequestMapper(WebApplicationServerRequestMapper requestMapper)
Set the request mapper.- Specified by:
setRequestMapper
in interfaceWebApplicationServer
- Parameters:
requestMapper
- the request mapper.
-
start
public void start()
Start the server.- Specified by:
start
in interfaceWebApplicationServer
-
stop
public void stop()
Stop the server.- Specified by:
stop
in interfaceWebApplicationServer
-
-