Package org.glassfish.jersey.jetty
Class JettyHttpContainer
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.server.handler.AbstractHandler
-
- org.glassfish.jersey.jetty.JettyHttpContainer
-
- All Implemented Interfaces:
org.eclipse.jetty.server.Handler
,org.eclipse.jetty.util.component.Container
,org.eclipse.jetty.util.component.Destroyable
,org.eclipse.jetty.util.component.Dumpable
,org.eclipse.jetty.util.component.Dumpable.DumpableContainer
,org.eclipse.jetty.util.component.LifeCycle
,Container
public final class JettyHttpContainer extends org.eclipse.jetty.server.handler.AbstractHandler implements Container
JerseyContainer
implementation based on JettyHandler
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
JettyHttpContainer.JettyBinder
An internal binder to enable Jetty HTTP container specific types injection.private static class
JettyHttpContainer.JettyRequestReferencingFactory
Referencing factory for Jetty request.private static class
JettyHttpContainer.JettyResponseReferencingFactory
Referencing factory for Jetty response.private static class
JettyHttpContainer.ResponseWriter
-
Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.AbstractHandler
org.eclipse.jetty.server.handler.AbstractHandler.ErrorDispatchHandler
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
-
-
Field Summary
Fields Modifier and Type Field Description private ApplicationHandler
appHandler
private boolean
configSetStatusOverSendError
Cached value of configuration propertyServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR
.private static int
INTERNAL_SERVER_ERROR
private static ExtendedLogger
LOGGER
private static java.lang.reflect.Type
REQUEST_TYPE
private static java.lang.reflect.Type
RESPONSE_TYPE
-
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
-
Fields inherited from interface org.glassfish.jersey.server.spi.Container
DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT
-
-
Constructor Summary
Constructors Constructor Description JettyHttpContainer(javax.ws.rs.core.Application application)
Create a new Jetty HTTP container.JettyHttpContainer(javax.ws.rs.core.Application application, java.lang.Object parentContext)
Create a new Jetty HTTP container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
cacheConfigSetStatusOverSendError()
The method reads and caches value of configuration propertyServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR
for future purposes.protected void
doStart()
Inform this container that the server has been started.void
doStop()
Inform this container that the server is being stopped.ApplicationHandler
getApplicationHandler()
Get the Jersey server-side application handler associated with the container.private java.lang.String
getBasePath(org.eclipse.jetty.server.Request request)
private java.net.URI
getBaseUri(org.eclipse.jetty.server.Request request)
ResourceConfig
getConfiguration()
Return an immutable representation of the currentconfiguration
.private java.net.URI
getRequestUri(org.eclipse.jetty.server.Request request, java.net.URI baseUri)
private javax.ws.rs.core.SecurityContext
getSecurityContext(org.eclipse.jetty.server.Request request)
private java.lang.String
getServerAddress(java.net.URI baseUri)
void
handle(java.lang.String target, org.eclipse.jetty.server.Request request, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)
void
reload()
Reload the hosted Jersey application using the currentconfiguration
.void
reload(ResourceConfig configuration)
Reload the hosted Jersey application using a newconfiguration
.-
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler
destroy, doError, getServer, setServer
-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
LOGGER
private static final ExtendedLogger LOGGER
-
REQUEST_TYPE
private static final java.lang.reflect.Type REQUEST_TYPE
-
RESPONSE_TYPE
private static final java.lang.reflect.Type RESPONSE_TYPE
-
INTERNAL_SERVER_ERROR
private static final int INTERNAL_SERVER_ERROR
-
configSetStatusOverSendError
private boolean configSetStatusOverSendError
Cached value of configuration propertyServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR
. Iftrue
methodHttpServletResponse.setStatus(int)
is used overHttpServletResponse.sendError(int, java.lang.String)
.
-
appHandler
private volatile ApplicationHandler appHandler
-
-
Constructor Detail
-
JettyHttpContainer
JettyHttpContainer(javax.ws.rs.core.Application application, java.lang.Object parentContext)
Create a new Jetty HTTP container.- Parameters:
application
- JAX-RS / Jersey application to be deployed on Jetty HTTP container.parentContext
- DI provider specific context with application's registered bindings.
-
JettyHttpContainer
JettyHttpContainer(javax.ws.rs.core.Application application)
Create a new Jetty HTTP container.- Parameters:
application
- JAX-RS / Jersey application to be deployed on Jetty HTTP container.
-
-
Method Detail
-
handle
public void handle(java.lang.String target, org.eclipse.jetty.server.Request request, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws java.io.IOException, javax.servlet.ServletException
- Specified by:
handle
in interfaceorg.eclipse.jetty.server.Handler
- Specified by:
handle
in classorg.eclipse.jetty.server.handler.AbstractHandler
- Throws:
java.io.IOException
javax.servlet.ServletException
-
getRequestUri
private java.net.URI getRequestUri(org.eclipse.jetty.server.Request request, java.net.URI baseUri)
-
getServerAddress
private java.lang.String getServerAddress(java.net.URI baseUri)
-
getSecurityContext
private javax.ws.rs.core.SecurityContext getSecurityContext(org.eclipse.jetty.server.Request request)
-
getBaseUri
private java.net.URI getBaseUri(org.eclipse.jetty.server.Request request)
-
getBasePath
private java.lang.String getBasePath(org.eclipse.jetty.server.Request request)
-
getConfiguration
public ResourceConfig getConfiguration()
Description copied from interface:Container
Return an immutable representation of the currentconfiguration
.- Specified by:
getConfiguration
in interfaceContainer
- Returns:
- current configuration of the hosted Jersey application.
-
reload
public void reload()
Description copied from interface:Container
Reload the hosted Jersey application using the currentconfiguration
.
-
reload
public void reload(ResourceConfig configuration)
Description copied from interface:Container
Reload the hosted Jersey application using a newconfiguration
.
-
getApplicationHandler
public ApplicationHandler getApplicationHandler()
Description copied from interface:Container
Get the Jersey server-side application handler associated with the container.- Specified by:
getApplicationHandler
in interfaceContainer
- Returns:
- Jersey server-side application handler associated with the container.
-
doStart
protected void doStart() throws java.lang.Exception
Inform this container that the server has been started. This method must be implicitly called after the server containing this container is started.- Overrides:
doStart
in classorg.eclipse.jetty.server.handler.AbstractHandler
- Throws:
java.lang.Exception
- if a problem occurred during server startup.
-
doStop
public void doStop() throws java.lang.Exception
Inform this container that the server is being stopped. This method must be implicitly called before the server containing this container is stopped.- Overrides:
doStop
in classorg.eclipse.jetty.server.handler.AbstractHandler
- Throws:
java.lang.Exception
- if a problem occurred during server shutdown.
-
cacheConfigSetStatusOverSendError
private void cacheConfigSetStatusOverSendError()
The method reads and caches value of configuration propertyServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR
for future purposes.
-
-