Package org.somda.sdc.dpws.http
Interface HttpServerRegistry
- All Superinterfaces:
com.google.common.util.concurrent.Service
- All Known Implementing Classes:
JettyHttpServerRegistry
public interface HttpServerRegistry
extends com.google.common.util.concurrent.Service
Simple HTTP server registry service.
Creates HTTP servers and registers handlers for context paths.
For proper shutdown of all servers Service.stopAsync() should be called.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State -
Method Summary
Modifier and TypeMethodDescriptioninitHttpServer(String schemeAndAuthority, boolean allowReuse) Creates an HTTP server at given URI.registerContext(String schemeAndAuthority, boolean allowReuse, String contextPath, String mediaType, CommunicationLogContext communicationLogContext, HttpHandler handler) Registers a handler for HTTP requests destined to the given scheme, authority and context path.voidunregisterContext(String schemeAndAuthority, String contextPath) Removes a handler for the given scheme, authority and context path.Methods inherited from interface com.google.common.util.concurrent.Service
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync
-
Method Details
-
initHttpServer
Creates an HTTP server at given URI.If there was no running HTTP server found under the passed scheme and authority, this function starts a new one. If the HTTP server supports both http and https schemes, the return value scheme will match the requested value.
- Parameters:
schemeAndAuthority- the scheme and authority where to access the HTTP server. If port number is 0, then a random open port is selected and will be part of the returned URI.allowReuse- if the port given in schemeAndAuthority is 0, setting this to true will allow returning any already running server, while false will create a new server. Has no effect if port is not 0.- Returns:
- the actual assigned URI of the HTTP server.
-
registerContext
String registerContext(String schemeAndAuthority, boolean allowReuse, String contextPath, @Nullable String mediaType, @Nullable CommunicationLogContext communicationLogContext, HttpHandler handler) Registers a handler for HTTP requests destined to the given scheme, authority and context path.If the HTTP server supports both http and https schemes, the return value scheme will match the requested value.
- Parameters:
schemeAndAuthority- scheme and authority used to start a new or re-use an existing HTTP server.allowReuse- if the port given in schemeAndAuthority is 0, settings this to true will allow returning any already running server, while false will create a new server. Has no effect if port is not 0.contextPath- the context path where the given registry shall listen to.
Important note: the context path needs to start with a slash.mediaType- the media type of the response the handler will produce. Null defaults toSoapConstants.MEDIA_TYPE_SOAP.communicationLogContext- additional information made available in the communication log of the registered context. Only has an effect ifDpwsConfig.HTTP_SERVER_COMMLOG_IN_HANDLERis enabledhandler- the handler callback that is invoked on a request to the given context path.- Returns:
- the actual full path of the HTTP server address the given handler listens to.
- See Also:
-
unregisterContext
Removes a handler for the given scheme, authority and context path.HttpHandler.handle(InputStream, OutputStream, CommunicationContext)will not be called for any request destined to the corresponding handler. Requests to the corresponding are answered with an HTTP 404.- Parameters:
schemeAndAuthority- scheme and authority where the context shall be removed.contextPath- the context path to remove. The context path needs to start with a slash.
-