Class EmbeddedConnection
- java.lang.Object
-
- com.adaptris.core.AdaptrisConnectionImp
-
- com.adaptris.core.http.jetty.EmbeddedConnection
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisConnection
,ComponentLifecycle
,ComponentLifecycleExtension
,JettyServletRegistrar
,StateManagedComponent
@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
The EmbeddedConnection makes use of the existing Jetty Engine that has been enabled as part of the bootstrap process.This is designed to be a replacement for
HttpConnection
andHttpsConnection
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 theorg.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.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.AdaptrisConnectionImp
log
-
-
Constructor Summary
Constructors Constructor Description EmbeddedConnection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class com.adaptris.core.AdaptrisConnectionImp
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
-
-
-
-
Method Detail
-
closeConnection
protected void closeConnection()
Description copied from class:AdaptrisConnectionImp
Close the underlying connection.- Specified by:
closeConnection
in classAdaptrisConnectionImp
-
initConnection
protected void initConnection() throws CoreException
Description copied from class:AdaptrisConnectionImp
Initialise the underlying connection.- Specified by:
initConnection
in classAdaptrisConnectionImp
- Throws:
CoreException
- wrapping any exception.
-
startConnection
protected void startConnection() throws CoreException
Description copied from class:AdaptrisConnectionImp
Start the underlying connection.- Specified by:
startConnection
in classAdaptrisConnectionImp
- Throws:
CoreException
- wrapping any exception.- See Also:
AdaptrisConnectionImp.startConnection()
-
stopConnection
protected void stopConnection()
Description copied from class:AdaptrisConnectionImp
Stop the underlying connection.- Specified by:
stopConnection
in classAdaptrisConnectionImp
- See Also:
AdaptrisConnectionImp.stopConnection()
-
prepareConnection
protected void prepareConnection() throws CoreException
- Specified by:
prepareConnection
in classAdaptrisConnectionImp
- Throws:
CoreException
-
addServlet
public void addServlet(ServletWrapper wrapper) throws CoreException
Description copied from interface:JettyServletRegistrar
Add a servlet to the jetty engine.- Specified by:
addServlet
in interfaceJettyServletRegistrar
- Throws:
CoreException
-
removeServlet
public void removeServlet(ServletWrapper wrapper) throws CoreException
Description copied from interface:JettyServletRegistrar
Remove a servlet from the jetty engine.- Specified by:
removeServlet
in interfaceJettyServletRegistrar
- Parameters:
wrapper
- the servlet wrapper- Throws:
CoreException
-
getMaxStartupWait
public TimeInterval getMaxStartupWait()
- Returns:
- the maxStartupWait
-
setMaxStartupWait
public void setMaxStartupWait(TimeInterval t)
Specify the maximum wait time for the underlying Jetty Server instance to startup.The adapter cannot be fully initialised until the underlying
Server
is ready to receive messages. We need to ensure that theComponentLifecycle.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.- Parameters:
t
- the maxStartupWait to set, default if not specified is 10 minutes.
-
getSecurityHandler
public SecurityHandlerWrapper getSecurityHandler()
- Returns:
- the securityHandler wrapper implementation
-
setSecurityHandler
public void setSecurityHandler(SecurityHandlerWrapper s)
Specify the SecurityHandler implementation.By specifying a
SecurityHandlerWrapper
implementation you will overwrite whateverSecurityHandler
implementation that is present in theWebAppContext
. If you have multiple instances ofEmbeddedConnection
configured inside your adapter, then results may be undefined; you are advised to configure a singleEmbeddedConnection
as ashared-component
to avoid any issues.- Parameters:
s
- the securityHandler wrapper implementation.
-
-