public class AristaFlowHTTPService extends javax.servlet.http.HttpServlet implements HTTPService, DynamicServlet
| Modifier and Type | Field and Description |
|---|---|
protected java.util.logging.Logger |
logger
My logger.
|
protected java.util.Map<java.lang.String,HTTPReplyHandler> |
replyHandlers
The reply handlers to which HTTP-requests are forwarded after the decoding.
|
protected java.lang.String |
servletName
The name of the servlet if dynamically deployed,
null
otherwise. |
protected java.util.Map<java.util.UUID,java.lang.String> |
sessions
Own session IDs.
|
| Constructor and Description |
|---|
AristaFlowHTTPService()
Constructor for initialisation via Extension Point (must not have any
parameters).
|
AristaFlowHTTPService(java.lang.String servletName)
Constructor providing a servlet name for dynamic servlet deployment.
|
| Modifier and Type | Method and Description |
|---|---|
void |
deregisterReplyHandler(SessionToken session,
java.lang.String sessionID)
Deregisters a reply handler for the activity with the designated
sessionID. |
protected void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
protected void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
protected java.util.List<java.lang.String> |
getListValue(java.lang.Object o)
Returns the string list value for the given object, or null if the object
is not a representation of a list-valued string value.
|
java.net.URI[] |
getLocalUris()
Returns the URIs under which the service is locally exported.
|
protected void |
getParameterAttachments(java.util.List<org.apache.commons.fileupload.FileItem> items,
java.util.Map<java.lang.String,HTMLContext.Attachment> attachments,
java.util.Map<java.lang.String,java.util.List<HTMLContext.Attachment>> attachmentLists)
Fills
attachments and attachmentLists with
the attachment parameters and the list-valued attachment parameters. |
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getParameterLists(javax.servlet.http.HttpServletRequest request)
Retrieves all list-valued parameters from the request and returns them as
map.
|
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getParameterLists(java.util.List<org.apache.commons.fileupload.FileItem> items)
Returns all list valued string parameters.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getParameters(javax.servlet.http.HttpServletRequest request)
Retrieves all non-list-valued and non-attachment parameters from the
request and returns them as map.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getParameters(java.util.List<org.apache.commons.fileupload.FileItem> items)
Returns all non-list-valued string parameters.
|
SerialisablePair<java.lang.String,java.lang.String> |
getRelease()
This service is started outside of the platform and therefore does not support the methods of
ADEPT2Service. |
java.lang.String[] |
getRuntimeRequiredServices()
Returns a list of service types, which are requested when needed at
runtime.
|
SerialisableTriple<java.lang.String,java.lang.String,java.lang.String> |
getServiceInstanceName()
This service is started outside of the platform and therefore does not support the methods of
ADEPT2Service. |
java.lang.String |
getServletName()
Gets the name of the servlet.
|
java.lang.String[] |
getStartupRequiredServices()
Returns a list of service types, which are required for executing the
service.
|
protected java.lang.String |
getStringValue(java.lang.Object o)
Returns the string value for the given object, or null if the object
is not a representation of a (non-list-valued) string value.
|
java.net.URI[] |
getURIs()
Returns the URIs which are set for this service in
ADEPT2Service.init(URI[], URI[]). |
void |
init(java.net.URI[] localExportedUris,
java.net.URI[] globalExportedUris)
Not forwarded since no client component should control the service.
|
long |
ping()
Gets whether the service is running and accepts requests or not and since when.
|
void |
preShutdown(boolean emergency)
Not forwarded since no client component should control the service.
|
void |
registerReplyHandler(SessionToken session,
java.lang.String sessionID,
HTTPReplyHandler replyHandler)
Registers a reply handler for the activity with the designated
sessionID. |
void |
servletDeployed(javax.servlet.ServletContext context,
java.lang.String urlPattern)
Notifies the servlet that it has been deployed with the designated context
and the designated patterns.
|
void |
servletUndeployed(javax.servlet.ServletContext context)
Notifies the servlet that it has been undeployed.
|
void |
setURL(java.net.URL myURL)
Set the URL to be used for the HTML contexts.
|
void |
shutdown(boolean emergency)
Not forwarded since no client component should control the service.
|
void |
start()
Not forwarded since no client component should control the service.
|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, servicedestroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, init, log, logprotected final transient java.util.logging.Logger logger
protected final java.util.Map<java.lang.String,HTTPReplyHandler> replyHandlers
protected final java.util.Map<java.util.UUID,java.lang.String> sessions
protected java.lang.String servletName
null
otherwise.public AristaFlowHTTPService()
public AristaFlowHTTPService(java.lang.String servletName)
servletName - The name of the servlet if dynamically deployed,
null otherwise.public void setURL(java.net.URL myURL)
myURL - protected void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
doGet in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionjava.io.IOExceptionprotected void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
doPost in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionjava.io.IOExceptionpublic void deregisterReplyHandler(SessionToken session, java.lang.String sessionID)
HTTPServicesessionID. A reply handler may be deregistered any time. In
case a reply handling is currently running, it will be allowed to finish.deregisterReplyHandler in interface HTTPServicesession - The session which is used to check for access rights on this
method.sessionID - The session ID identifying the executed activity and
therefore also the handler for the reply sent via HTTP.public void registerReplyHandler(SessionToken session, java.lang.String sessionID, HTTPReplyHandler replyHandler) throws java.net.MalformedURLException
HTTPServicesessionID. This creates an own URL for the reply handler.
It will be called as soon as a HTTP-request (the reply for the activity) is
received by this HTTP-service.registerReplyHandler in interface HTTPServicesession - The session which is used to check for access rights on this
method.sessionID - The session ID for the executed activity. It is used to
create an appropriate URL.replyHandler - The handler for the HTTP-replies sent to this service.java.net.MalformedURLException - If the designated sessionID does not allow to
create a valid URL, a MalformedURLException will
be thrown.protected java.util.Map<java.lang.String,java.lang.String> getParameters(javax.servlet.http.HttpServletRequest request)
request - protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getParameterLists(javax.servlet.http.HttpServletRequest request)
request - protected java.util.Map<java.lang.String,java.lang.String> getParameters(java.util.List<org.apache.commons.fileupload.FileItem> items)
items - protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getParameterLists(java.util.List<org.apache.commons.fileupload.FileItem> items)
items - protected void getParameterAttachments(java.util.List<org.apache.commons.fileupload.FileItem> items,
java.util.Map<java.lang.String,HTMLContext.Attachment> attachments,
java.util.Map<java.lang.String,java.util.List<HTMLContext.Attachment>> attachmentLists)
attachments and attachmentLists with
the attachment parameters and the list-valued attachment parameters.items - attachments - attachmentLists - protected java.lang.String getStringValue(java.lang.Object o)
o - protected java.util.List<java.lang.String> getListValue(java.lang.Object o)
o - public long ping()
ADEPT2Serviceping in interface ADEPT2Service0 for a service that has not been started,
-1 for a service that has been shut down. boolean logic use 0 < ping().public SerialisablePair<java.lang.String,java.lang.String> getRelease()
ADEPT2Service.getRelease in interface ADEPT2Service<unknown> for all elements of the triple.public SerialisableTriple<java.lang.String,java.lang.String,java.lang.String> getServiceInstanceName()
ADEPT2Service.getServiceInstanceName in interface ADEPT2Servicenull for the cluster name, <unknown> for the other
elements of the triple.public java.lang.String[] getStartupRequiredServices()
ADEPT2ServiceRegistry for
implementations of this type during ADEPT2Service.init(URI[], URI[]) or to
ADEPT2Service.start() the service. ADEPT2Service.init(URI[], URI[]) is not called before the required
services are started. The order in the array is not relevant since the
dependencies of the required services are also inspected and respected.
getStartupRequiredServices in interface ADEPT2Servicepublic java.lang.String[] getRuntimeRequiredServices()
ADEPT2ServiceADEPT2Service.init(URI[], URI[]) as well as ADEPT2Service.start() have to be returned. When
starting another thread, this has to be synchronised correctly. All services required at startup should not be returned again here.
getRuntimeRequiredServices in interface ADEPT2Servicepublic java.net.URI[] getLocalUris()
ADEPT2ServicegetLocalUris in interface ADEPT2Servicepublic java.net.URI[] getURIs()
ADEPT2ServiceADEPT2Service.init(URI[], URI[]).
For a published service these are the global URIs, otherwise the method
will return the local URIs.getURIs in interface ADEPT2Servicepublic void init(java.net.URI[] localExportedUris,
java.net.URI[] globalExportedUris)
throws AbortServiceException
ADEPT2Service.init(URI[], URI[]), the service must be ready
for ADEPT2Service.start().init in interface ADEPT2ServicelocalExportedUris - The URIs with which this service is exported
locally or a local URI or an empty array for internal services.globalExportedUris - The URIs with which this service is published
globally or null in case the service is not
published.AbortServiceException - If this service cannot be initialised due to
a severe problem, an AbortServiceException will be
thrown. ADEPT2Service.shutdown(boolean) will not be called when aborting; the
service has to shut down itself/clean up before throwing the
exception.public void start()
After returning from ADEPT2Service.start(), the service must be ready to
receive any API call. This implicates for instance, that the thread calling
this method may not leave the method before a server thread is actually
ready to receive requests.
start in interface ADEPT2Servicepublic void preShutdown(boolean emergency)
ADEPT2Service.shutdown(boolean). All startup required services are available in pre shutdown, runtime
services may already be shut down. preShutdown in interface ADEPT2Serviceemergency - Whether the shutdown will be an emergency shutdown. Normally a service should
not do anything in pre-shutdown in case of an emergency.public void shutdown(boolean emergency)
ServiceThreadHandling. shutdown in interface ADEPT2Serviceemergency - Whether the shutdown will be an emergency shutdown.public java.lang.String getServletName()
DynamicServletDynamicServlet, the servlet name has to be provided
explicitly.getServletName in interface DynamicServletgetServletName in interface javax.servlet.ServletConfiggetServletName in class javax.servlet.GenericServletpublic void servletDeployed(javax.servlet.ServletContext context,
java.lang.String urlPattern)
DynamicServletservletDeployed in interface DynamicServletcontext - The servlet context of this servlet.urlPattern - The URL pattern (mapping) this servlet has been
deployed with.public void servletUndeployed(javax.servlet.ServletContext context)
DynamicServletservletUndeployed in interface DynamicServletcontext - The servlet context of this servlet.