Package io.bdeploy.jersey
Class JerseyServer
java.lang.Object
io.bdeploy.jersey.JerseyServer
- All Implemented Interfaces:
RegistrationTarget,AutoCloseable
Encapsulates required functionality from the Grizzly HttpServer with the
Jersey handlers.
Use register(Object) to register additional resource, filters and
providers before starting the server.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHandler(org.glassfish.grizzly.http.server.HttpHandler handler, org.glassfish.grizzly.http.server.HttpHandlerRegistration registration) voidclose()booleanbooleanjoin()voidRegisters a class or an instance to be used in this server.voidregisterDefaultResources(org.glassfish.jersey.server.ResourceConfig config) voidregisterResource(AutoCloseable closeable) Registers a resource that will be closed when the server is stopped.voidregisterWebsocketApplication(String urlMapping, org.glassfish.grizzly.websockets.WebSocketApplication wsa) Registers a WebSocket application.voidremoveHandler(org.glassfish.grizzly.http.server.HttpHandler handler) voidsetAuditor(Auditor auditor) Sets the auditor that will be used by the server to log requests.voidvoidstart()Start the server as configured.static void
-
Field Details
-
START_TIME
- See Also:
-
BROADCAST_EXECUTOR
- See Also:
-
FILE_SYSTEM_MIN_SPACE
- See Also:
-
-
Constructor Details
-
JerseyServer
- Parameters:
port- the port to listen onstore- the keystore carrying the private certificate/key material for SSL.passphrase- the passphrase for the keystore.
-
-
Method Details
-
getKeyStore
- Specified by:
getKeyStorein interfaceRegistrationTarget- Returns:
- the
KeyStorewhich can be used to perform token validation.
-
afterStartup
- Specified by:
afterStartupin interfaceRegistrationTarget- Returns:
- a
CompletableFuturewhich is completed after the server has completed startup.
-
getRemoteActivityReporter
- Returns:
- an
ActivityReporterwhich can broadcast to remote.
-
setAuditor
Sets the auditor that will be used by the server to log requests. The auditor will be closed when the server is terminated.- Parameters:
auditor- auditor to log requests
-
setUserValidator
- Parameters:
validator- a validator which can verify a user exists and is allowed to proceed.
-
registerResource
Description copied from interface:RegistrationTargetRegisters a resource that will be closed when the server is stopped.- Specified by:
registerResourcein interfaceRegistrationTarget- Parameters:
closeable- resource to close
-
register
Registers a class or an instance to be used in this server.- Specified by:
registerin interfaceRegistrationTarget- Parameters:
provider- aClassorObjectinstance to register. Also supports registration of customBinderinstances which allow custom dependency injection in services.
-
addHandler
public void addHandler(org.glassfish.grizzly.http.server.HttpHandler handler, org.glassfish.grizzly.http.server.HttpHandlerRegistration registration) - Specified by:
addHandlerin interfaceRegistrationTarget- Parameters:
handler- register an additional handler at the given location. passHttpHandlerRegistration.ROOTto register at the root of the server (e.g. the root web resources).
-
removeHandler
public void removeHandler(org.glassfish.grizzly.http.server.HttpHandler handler) - Specified by:
removeHandlerin interfaceRegistrationTarget- Parameters:
handler- a previously registered handler.
-
registerWebsocketApplication
public void registerWebsocketApplication(String urlMapping, org.glassfish.grizzly.websockets.WebSocketApplication wsa) Description copied from interface:RegistrationTargetRegisters a WebSocket application.Note: All
WebSocketApplications are registered in the '/ws' context path.- Specified by:
registerWebsocketApplicationin interfaceRegistrationTarget- Parameters:
urlMapping- the path where to host the application. May contain wildcards.wsa- the WebSocketApplication
-
updateLogging
public static void updateLogging() -
start
public void start()Start the server as configured. -
registerDefaultResources
public void registerDefaultResources(org.glassfish.jersey.server.ResourceConfig config) - Parameters:
config- a ResourceConfig to enrich with all the default resources and features used by the BDeploy JAX-RS infrastructure. Allows to create additional JAX-RS applications which use the same setup as BDeploy itself. This is useful e.g. for plugins which should use the same filters/features as BDeploy.
-
isRunning
public boolean isRunning()- Returns:
- whether the server is running.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
join
public boolean join()
-