Class JettyHttpServerRegistry
-
- All Implemented Interfaces:
-
com.google.common.util.concurrent.Service,org.somda.sdc.dpws.http.HttpServerRegistry
public class JettyHttpServerRegistry extends AbstractIdleService implements HttpServerRegistry
HttpServerRegistry implementation based on Jetty HTTP servers.
-
-
Method Summary
Modifier and Type Method Description StringinitHttpServer(String schemeAndAuthority, boolean allowReuse)Creates an HTTP server at given URI. StringregisterContext(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. StringregisterContext(String schemeAndAuthority, boolean allowReuse, String contextPath, @Nullable() String mediaType, @Nullable() CommunicationLogContext communicationLogContext, HttpHandler requestHandler, @Nullable() UnaryOperator<Void> postResponseHandler)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 class com.google.common.util.concurrent.AbstractIdleService
addListener, awaitRunning, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync, toString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
initHttpServer
String initHttpServer(String schemeAndAuthority, boolean allowReuse)
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.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.- Returns:
the actual assigned URI of the HTTP server.
-
registerContext
@Deprecated(forRemoval = true) 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.contextPath- the context path where the given registry shall listen to.mediaType- the media type of the response the handler will produce.communicationLogContext- additional information made available in the communication log of the registered context.handler- 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.
-
registerContext
String registerContext(String schemeAndAuthority, boolean allowReuse, String contextPath, @Nullable() String mediaType, @Nullable() CommunicationLogContext communicationLogContext, HttpHandler requestHandler, @Nullable() UnaryOperator<Void> postResponseHandler)
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.contextPath- the context path where the given registry shall listen to.mediaType- the media type of the response the handler will produce.communicationLogContext- additional information made available in the communication log of the registered context.requestHandler- the handler callback that is invoked on a request to the given context path.postResponseHandler- optional callback that is invoked after the transmission of the response concluded- Returns:
the actual full path of the HTTP server address the given handler listens to.
-
unregisterContext
void unregisterContext(String schemeAndAuthority, String contextPath)
Removes a handler for the given scheme, authority and context path.
handle 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.
-
-
-
-