@ComponentProfile(summary="Connection that uses the embedded Jetty engine management component for requests", tag="connections,http,https,jetty") public class EmbeddedConnection extends AdaptrisConnectionImp implements JettyServletRegistrar
This is designed to be a replacement for HttpConnection
and HttpsConnection
and allows you to configure a single
jetty instance according to your requirements which can be re-used across many channels. Of course if you have not enabled a
global jetty instance, then exceptions will be thrown if you attempt to configure an instance of this class.
If you use this connection; you may have to delete ROOT.war
from the jetty webapps directory. The default servlet that is
registered with the default web application might interfere with the registering of servlets against arbitrary locations; if you
get HTTP 404 errors, then enable logging for the org.eclipse.jetty
category and check how the request is routed by the
Jetty engine.
In the adapter configuration file this class is aliased as jetty-embedded-connection which is the preferred alternative to the fully qualified classname when building your configuration.
log
Constructor and Description |
---|
EmbeddedConnection() |
Modifier and Type | Method and Description |
---|---|
void |
addServlet(ServletWrapper wrapper)
Add a servlet to the jetty engine.
|
protected void |
closeConnection()
Close the underlying connection.
|
TimeInterval |
getMaxStartupWait() |
SecurityHandlerWrapper |
getSecurityHandler() |
protected void |
initConnection()
Initialise the underlying connection.
|
protected void |
prepareConnection() |
void |
removeServlet(ServletWrapper wrapper)
Remove a servlet from the jetty engine.
|
void |
setMaxStartupWait(TimeInterval t)
Specify the maximum wait time for the underlying Jetty Server instance to startup.
|
void |
setSecurityHandler(SecurityHandlerWrapper s)
Specify the SecurityHandler implementation.
|
protected void |
startConnection()
Start the underlying connection.
|
protected void |
stopConnection()
Stop the underlying connection.
|
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, cloneForTesting, close, connectionErrorHandler, getConnectionErrorHandler, getUniqueId, getWorkersFirstOnShutdown, init, prepare, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setUniqueId, setWorkersFirstOnShutdown, start, stop, workersFirstOnShutdown
protected void closeConnection()
AdaptrisConnectionImp
closeConnection
in class AdaptrisConnectionImp
protected void initConnection() throws CoreException
AdaptrisConnectionImp
initConnection
in class AdaptrisConnectionImp
CoreException
- wrapping any exception.protected void startConnection() throws CoreException
AdaptrisConnectionImp
startConnection
in class AdaptrisConnectionImp
CoreException
- wrapping any exception.AdaptrisConnectionImp.startConnection()
protected void stopConnection()
AdaptrisConnectionImp
stopConnection
in class AdaptrisConnectionImp
AdaptrisConnectionImp.stopConnection()
protected void prepareConnection() throws CoreException
prepareConnection
in class AdaptrisConnectionImp
CoreException
public void addServlet(ServletWrapper wrapper) throws CoreException
JettyServletRegistrar
addServlet
in interface JettyServletRegistrar
CoreException
public void removeServlet(ServletWrapper wrapper) throws CoreException
JettyServletRegistrar
removeServlet
in interface JettyServletRegistrar
wrapper
- the servlet wrapperCoreException
public TimeInterval getMaxStartupWait()
public void setMaxStartupWait(TimeInterval t)
The adapter cannot be fully initialised until the underlying Server
is ready to receive
messages. We need to ensure that the ComponentLifecycle.init()
method blocks until the server is ready for registration
of servlets and also ready for incoming HTTP requests. This value controls how long we wait for the server to start up before
throwing an exception.
t
- the maxStartupWait to set, default if not specified is 10 minutes.public SecurityHandlerWrapper getSecurityHandler()
public void setSecurityHandler(SecurityHandlerWrapper s)
By specifying a SecurityHandlerWrapper
implementation you will overwrite whatever SecurityHandler
implementation that is present in the WebAppContext
. If you have multiple instances of EmbeddedConnection
configured inside your adapter, then results may be undefined; you are advised to configure a single EmbeddedConnection
as a shared-component
to avoid any issues.
s
- the securityHandler wrapper implementation.