Class JmsConnection
- java.lang.Object
-
- com.adaptris.core.AdaptrisConnectionImp
-
- com.adaptris.core.AllowsRetriesConnection
-
- com.adaptris.core.jms.JmsConnection
-
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisConnection,ComponentLifecycle,ComponentLifecycleExtension,ConnectionComparator<JmsConnection>,JmsConnectionConfig,StateManagedComponent
- Direct Known Subclasses:
FailoverJmsConnection
@ComponentProfile(summary="Connect to a JMS 1.1 broker", tag="connections,jms") public class JmsConnection extends AllowsRetriesConnection implements JmsConnectionConfig, ConnectionComparator<JmsConnection>JMS 1.1 standard JMS connection.In the adapter configuration file this class is aliased as jms-connection which is the preferred alternative to the fully qualified classname when building your configuration.
In the adapter configuration file this class is aliased as jms-connection which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.jms.Connectionconnection-
Fields inherited from class com.adaptris.core.AdaptrisConnectionImp
log
-
-
Constructor Summary
Constructors Constructor Description JmsConnection()Create a new instance.JmsConnection(VendorImplementation impl)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanadditionalDebug()java.lang.StringbrokerDetailsForLogging()JmsConnectioncloneForTesting()Make a copy of this object for test purposes.protected voidcloseConnection()Close the underlying connection.java.lang.StringconfiguredClientId()The client id.java.lang.StringconfiguredPassword()The password.java.lang.StringconfiguredUserName()The username.VendorImplementationconfiguredVendorImplementation()The vendor specific implementation.booleanconnectionEquals(JmsConnection connection)ConnectionErrorHandlerconnectionErrorHandler()Returns the currently activeConnectionErrorHandlerprotected voidcreateConnection(javax.jms.ConnectionFactory factory)javax.jms.SessioncreateSession(boolean transacted, int acknowledgeMode)Creates a newSessionon the underlying JMSConnection.javax.jms.ConnectioncurrentConnection()java.lang.BooleangetAdditionalDebug()java.lang.StringgetClientId()Sets the broker connection client ID.java.lang.StringgetPassword()Sets the broker password.java.lang.StringgetUserName()Returns the broker user name.VendorImplementationgetVendorImplementation()Sets theVendorImplementationto use.protected voidinitConnection()Initialise the underlying connection.javax.jms.ConnectionFactoryobtainConnectionFactory()protected voidprepareConnection()voidsetAdditionalDebug(java.lang.Boolean b)Whether or not to generate additional TRACE level debug when attempting connections.voidsetClientId(java.lang.String s)Returns the broker connection client ID.voidsetPassword(java.lang.String s)Sets the broker password.voidsetUserName(java.lang.String s)Sets the broker user name.voidsetVendorImplementation(VendorImplementation imp)Returns theVendorImplementationto use.protected voidstartConnection()Start the underlying connection.protected voidstopConnection()Stop the underlying connection.-
Methods inherited from class com.adaptris.core.AllowsRetriesConnection
connectionAttempts, connectionRetryInterval, createLoggingStatement, getConnectionAttempts, getConnectionRetryInterval, logWarning, setConnectionAttempts, setConnectionRetryInterval
-
Methods inherited from class com.adaptris.core.AdaptrisConnectionImp
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, close, getConnectionErrorHandler, getUniqueId, getWorkersFirstOnShutdown, init, prepare, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setUniqueId, setWorkersFirstOnShutdown, start, stop, workersFirstOnShutdown
-
-
-
-
Constructor Detail
-
JmsConnection
public JmsConnection()
Create a new instance. Default settings are:
- vendor-implementation - StandardJndiImplementation
- username - "" (i.e. blank)
-
JmsConnection
public JmsConnection(VendorImplementation impl)
-
-
Method Detail
-
initConnection
protected void initConnection() throws CoreExceptionDescription copied from class:AdaptrisConnectionImpInitialise the underlying connection.- Specified by:
initConnectionin classAdaptrisConnectionImp- Throws:
CoreException- wrapping any exception.- See Also:
AdaptrisConnectionImp.initConnection()
-
currentConnection
public javax.jms.Connection currentConnection()
-
connectionErrorHandler
public ConnectionErrorHandler connectionErrorHandler()
Description copied from interface:AdaptrisConnectionReturns the currently activeConnectionErrorHandler- Specified by:
connectionErrorHandlerin interfaceAdaptrisConnection- Overrides:
connectionErrorHandlerin classAdaptrisConnectionImp- Returns:
- the active
ConnectionErrorHandler, which may not be the same as the configured...
-
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()
-
closeConnection
protected void closeConnection()
Description copied from class:AdaptrisConnectionImpClose the underlying connection.- Specified by:
closeConnectionin classAdaptrisConnectionImp- See Also:
AdaptrisConnectionImp.closeConnection()
-
createSession
public javax.jms.Session createSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSExceptionCreates a new
Sessionon the underlying JMSConnection.- Parameters:
transacted- true if transactedacknowledgeMode- acknowledge mode- Returns:
- a new
Session - Throws:
javax.jms.JMSException- if any occurs
-
obtainConnectionFactory
public javax.jms.ConnectionFactory obtainConnectionFactory() throws java.lang.Exception- Throws:
java.lang.Exception
-
brokerDetailsForLogging
public java.lang.String brokerDetailsForLogging()
-
createConnection
protected void createConnection(javax.jms.ConnectionFactory factory) throws java.lang.Exception- Throws:
java.lang.Exception
-
prepareConnection
protected void prepareConnection() throws CoreException- Specified by:
prepareConnectionin classAdaptrisConnectionImp- Throws:
CoreException
-
connectionEquals
public boolean connectionEquals(JmsConnection connection)
- Specified by:
connectionEqualsin interfaceConnectionComparator<JmsConnection>
-
getUserName
public java.lang.String getUserName()
Returns the broker user name.
- Returns:
- the broker user name
-
setUserName
public void setUserName(java.lang.String s)
Sets the broker user name.
- Parameters:
s- the broker user name
-
getPassword
public java.lang.String getPassword()
Sets the broker password.
- Returns:
- the broker password
-
setPassword
public void setPassword(java.lang.String s)
Sets the broker password.
In additional to plain text passwords, the passwords can also be encoded using the appropriate
Password- Parameters:
s- the broker password
-
getClientId
public java.lang.String getClientId()
Sets the broker connection client ID.
- Returns:
- the broker connection client ID
-
setClientId
public void setClientId(java.lang.String s)
Returns the broker connection client ID.
- Parameters:
s- the broker connection client ID
-
getVendorImplementation
public VendorImplementation getVendorImplementation()
Sets the
VendorImplementationto use.- Returns:
- the
VendorImplementationto use
-
setVendorImplementation
public void setVendorImplementation(VendorImplementation imp)
Returns the
VendorImplementationto use.- Parameters:
imp- theVendorImplementationto use
-
getAdditionalDebug
public java.lang.Boolean getAdditionalDebug()
-
setAdditionalDebug
public void setAdditionalDebug(java.lang.Boolean b)
Whether or not to generate additional TRACE level debug when attempting connections.- Parameters:
b- true to enable additional logging; default false.
-
additionalDebug
protected boolean additionalDebug()
-
configuredClientId
public java.lang.String configuredClientId()
Description copied from interface:JmsConnectionConfigThe client id.- Specified by:
configuredClientIdin interfaceJmsConnectionConfig- Returns:
- the client id
-
configuredPassword
public java.lang.String configuredPassword()
Description copied from interface:JmsConnectionConfigThe password.- Specified by:
configuredPasswordin interfaceJmsConnectionConfig- Returns:
- the password
-
configuredUserName
public java.lang.String configuredUserName()
Description copied from interface:JmsConnectionConfigThe username.- Specified by:
configuredUserNamein interfaceJmsConnectionConfig- Returns:
- the username
-
configuredVendorImplementation
public VendorImplementation configuredVendorImplementation()
Description copied from interface:JmsConnectionConfigThe vendor specific implementation.- Specified by:
configuredVendorImplementationin interfaceJmsConnectionConfig- Returns:
- the vendor specific implementation
-
cloneForTesting
public JmsConnection cloneForTesting() throws CoreException
Description copied from interface:AdaptrisConnectionMake a copy of this object for test purposes.- Specified by:
cloneForTestingin interfaceAdaptrisConnection- Overrides:
cloneForTestingin classAdaptrisConnectionImp- Returns:
- a copy of this object
- Throws:
CoreException- wrapping any exceptions
-
-