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.Connection
connection
-
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 boolean
additionalDebug()
java.lang.String
brokerDetailsForLogging()
JmsConnection
cloneForTesting()
Make a copy of this object for test purposes.protected void
closeConnection()
Close the underlying connection.java.lang.String
configuredClientId()
The client id.java.lang.String
configuredPassword()
The password.java.lang.String
configuredUserName()
The username.VendorImplementation
configuredVendorImplementation()
The vendor specific implementation.boolean
connectionEquals(JmsConnection connection)
ConnectionErrorHandler
connectionErrorHandler()
Returns the currently activeConnectionErrorHandler
protected void
createConnection(javax.jms.ConnectionFactory factory)
javax.jms.Session
createSession(boolean transacted, int acknowledgeMode)
Creates a newSession
on the underlying JMSConnection
.javax.jms.Connection
currentConnection()
java.lang.Boolean
getAdditionalDebug()
java.lang.String
getClientId()
Sets the broker connection client ID.java.lang.String
getPassword()
Sets the broker password.java.lang.String
getUserName()
Returns the broker user name.VendorImplementation
getVendorImplementation()
Sets theVendorImplementation
to use.protected void
initConnection()
Initialise the underlying connection.javax.jms.ConnectionFactory
obtainConnectionFactory()
protected void
prepareConnection()
void
setAdditionalDebug(java.lang.Boolean b)
Whether or not to generate additional TRACE level debug when attempting connections.void
setClientId(java.lang.String s)
Returns the broker connection client ID.void
setPassword(java.lang.String s)
Sets the broker password.void
setUserName(java.lang.String s)
Sets the broker user name.void
setVendorImplementation(VendorImplementation imp)
Returns theVendorImplementation
to use.protected void
startConnection()
Start the underlying connection.protected void
stopConnection()
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 CoreException
Description copied from class:AdaptrisConnectionImp
Initialise the underlying connection.- Specified by:
initConnection
in classAdaptrisConnectionImp
- Throws:
CoreException
- wrapping any exception.- See Also:
AdaptrisConnectionImp.initConnection()
-
currentConnection
public javax.jms.Connection currentConnection()
-
connectionErrorHandler
public ConnectionErrorHandler connectionErrorHandler()
Description copied from interface:AdaptrisConnection
Returns the currently activeConnectionErrorHandler
- Specified by:
connectionErrorHandler
in interfaceAdaptrisConnection
- Overrides:
connectionErrorHandler
in classAdaptrisConnectionImp
- Returns:
- the active
ConnectionErrorHandler
, which may not be the same as the configured...
-
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()
-
closeConnection
protected void closeConnection()
Description copied from class:AdaptrisConnectionImp
Close the underlying connection.- Specified by:
closeConnection
in classAdaptrisConnectionImp
- See Also:
AdaptrisConnectionImp.closeConnection()
-
createSession
public javax.jms.Session createSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
Creates a new
Session
on 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:
prepareConnection
in classAdaptrisConnectionImp
- Throws:
CoreException
-
connectionEquals
public boolean connectionEquals(JmsConnection connection)
- Specified by:
connectionEquals
in 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
VendorImplementation
to use.- Returns:
- the
VendorImplementation
to use
-
setVendorImplementation
public void setVendorImplementation(VendorImplementation imp)
Returns the
VendorImplementation
to use.- Parameters:
imp
- theVendorImplementation
to 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:JmsConnectionConfig
The client id.- Specified by:
configuredClientId
in interfaceJmsConnectionConfig
- Returns:
- the client id
-
configuredPassword
public java.lang.String configuredPassword()
Description copied from interface:JmsConnectionConfig
The password.- Specified by:
configuredPassword
in interfaceJmsConnectionConfig
- Returns:
- the password
-
configuredUserName
public java.lang.String configuredUserName()
Description copied from interface:JmsConnectionConfig
The username.- Specified by:
configuredUserName
in interfaceJmsConnectionConfig
- Returns:
- the username
-
configuredVendorImplementation
public VendorImplementation configuredVendorImplementation()
Description copied from interface:JmsConnectionConfig
The vendor specific implementation.- Specified by:
configuredVendorImplementation
in interfaceJmsConnectionConfig
- Returns:
- the vendor specific implementation
-
cloneForTesting
public JmsConnection cloneForTesting() throws CoreException
Description copied from interface:AdaptrisConnection
Make a copy of this object for test purposes.- Specified by:
cloneForTesting
in interfaceAdaptrisConnection
- Overrides:
cloneForTesting
in classAdaptrisConnectionImp
- Returns:
- a copy of this object
- Throws:
CoreException
- wrapping any exceptions
-
-