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 JettyServletRegistrarThe 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
HttpConnectionandHttpsConnectionand 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.warfrom 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.jettycategory 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 voidaddServlet(ServletWrapper wrapper)Add a servlet to the jetty engine.protected voidcloseConnection()Close the underlying connection.TimeIntervalgetMaxStartupWait()SecurityHandlerWrappergetSecurityHandler()protected voidinitConnection()Initialise the underlying connection.protected voidprepareConnection()voidremoveServlet(ServletWrapper wrapper)Remove a servlet from the jetty engine.voidsetMaxStartupWait(TimeInterval t)Specify the maximum wait time for the underlying Jetty Server instance to startup.voidsetSecurityHandler(SecurityHandlerWrapper s)Specify the SecurityHandler implementation.protected voidstartConnection()Start the underlying connection.protected voidstopConnection()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:AdaptrisConnectionImpClose the underlying connection.- Specified by:
closeConnectionin classAdaptrisConnectionImp
-
initConnection
protected void initConnection() throws CoreExceptionDescription copied from class:AdaptrisConnectionImpInitialise the underlying connection.- Specified by:
initConnectionin classAdaptrisConnectionImp- Throws:
CoreException- wrapping any exception.
-
startConnection
protected void startConnection() throws CoreExceptionDescription copied from class:AdaptrisConnectionImpStart the underlying connection.- Specified by:
startConnectionin classAdaptrisConnectionImp- Throws:
CoreException- wrapping any exception.- See Also:
AdaptrisConnectionImp.startConnection()
-
stopConnection
protected void stopConnection()
Description copied from class:AdaptrisConnectionImpStop the underlying connection.- Specified by:
stopConnectionin classAdaptrisConnectionImp- See Also:
AdaptrisConnectionImp.stopConnection()
-
prepareConnection
protected void prepareConnection() throws CoreException- Specified by:
prepareConnectionin classAdaptrisConnectionImp- Throws:
CoreException
-
addServlet
public void addServlet(ServletWrapper wrapper) throws CoreException
Description copied from interface:JettyServletRegistrarAdd a servlet to the jetty engine.- Specified by:
addServletin interfaceJettyServletRegistrar- Throws:
CoreException
-
removeServlet
public void removeServlet(ServletWrapper wrapper) throws CoreException
Description copied from interface:JettyServletRegistrarRemove a servlet from the jetty engine.- Specified by:
removeServletin 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
Serveris 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
SecurityHandlerWrapperimplementation you will overwrite whateverSecurityHandlerimplementation that is present in theWebAppContext. If you have multiple instances ofEmbeddedConnectionconfigured inside your adapter, then results may be undefined; you are advised to configure a singleEmbeddedConnectionas ashared-componentto avoid any issues.- Parameters:
s- the securityHandler wrapper implementation.
-
-