Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq.ra
Class ActiveMQResourceAdapter  view ActiveMQResourceAdapter download ActiveMQResourceAdapter.java

java.lang.Object
  extended byorg.activemq.ra.ActiveMQResourceAdapter
All Implemented Interfaces:
javax.resource.spi.ResourceAdapter

public class ActiveMQResourceAdapter
extends java.lang.Object
implements javax.resource.spi.ResourceAdapter

Knows how to connect to one ActiveMQ server. It can then activate endpoints and deliver messages to those enpoints using the connection configure in the resource adapter.

Must override equals and hashCode (JCA spec 16.4)

Version:
$Revision: 1.2 $

Field Summary
private static java.lang.String ASF_ENDPOINT_WORKER_TYPE
           
private  javax.resource.spi.BootstrapContext bootstrapContext
           
private  java.lang.String brokerXmlConfig
           
private  org.activemq.ActiveMQConnectionFactory connectionFactory
           
private  java.util.HashMap connectionFactoryMap
           
private  org.activemq.broker.BrokerContainer container
           
private  java.util.HashMap endpointWorkers
           
private  java.lang.String endpointWorkerType
           
private  ActiveMQConnectionRequestInfo info
           
private static org.apache.commons.logging.Log log
           
private static java.lang.String POLLING_ENDPOINT_WORKER_TYPE
           
private  java.lang.Boolean useEmbeddedBroker
           
 
Constructor Summary
ActiveMQResourceAdapter()
           
 
Method Summary
private  void createBroker()
           
private  java.lang.String defaultValue(java.lang.String value, java.lang.String defaultValue)
           
private  java.lang.String emptyToNull(java.lang.String value)
           
 void endpointActivation(javax.resource.spi.endpoint.MessageEndpointFactory endpointFactory, javax.resource.spi.ActivationSpec activationSpec)
           
 void endpointDeactivation(javax.resource.spi.endpoint.MessageEndpointFactory endpointFactory, javax.resource.spi.ActivationSpec activationSpec)
           
 boolean equals(java.lang.Object o)
          Determine whether this Object is semantically equal to another Object.
 javax.resource.spi.BootstrapContext getBootstrapContext()
           
 java.lang.String getBrokerXmlConfig()
           
 java.lang.String getClientid()
           
private  org.activemq.ActiveMQConnectionFactory getConnectionFactory(ActiveMQConnectionRequestInfo crInfo)
          Returns a connection factory given a connection configuration.
 java.lang.String getEndpointWorkerType()
           
 ActiveMQConnectionRequestInfo getInfo()
           
 java.lang.String getPassword()
           
 java.lang.String getServerUrl()
           
 java.lang.Boolean getUseEmbeddedBroker()
           
 java.lang.Boolean getUseInboundSession()
           
 java.lang.String getUserName()
           
 javax.transaction.xa.XAResource[] getXAResources(javax.resource.spi.ActivationSpec[] activationSpecs)
          We only connect to one resource manager per ResourceAdapter instance, so any ActivationSpec will return the same XAResource.
 int hashCode()
          Get a value that represents this Object, as uniquely as possible within the confines of an int.
 java.lang.Boolean isUseEmbeddedBroker()
           
 org.activemq.ActiveMQConnection makeConnection()
          Return a connection using the default connection request info from the RAR deployment.
 org.activemq.ActiveMQConnection makeConnection(ActiveMQActivationSpec activationSpec)
           
 org.activemq.ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo crInfo)
          Return a connection using a specific connection request info.
private  boolean notEqual(java.lang.Object o1, java.lang.Object o2)
           
 void setBrokerXmlConfig(java.lang.String brokerXmlConfig)
          Sets the XML configuration file used to configure the ActiveMQ broker via Spring if using embedded mode.
 void setClientid(java.lang.String clientid)
           
 void setEndpointWorkerType(java.lang.String endpointWorkerType)
           
 void setPassword(java.lang.String password)
           
 void setServerUrl(java.lang.String url)
           
 void setUseEmbeddedBroker(java.lang.Boolean useEmbeddedBroker)
           
 void setUseInboundSession(java.lang.Boolean useInboundSession)
           
 void setUserName(java.lang.String userid)
           
 void start(javax.resource.spi.BootstrapContext bootstrapContext)
           
 void stop()
           
private  void stopBroker()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

ASF_ENDPOINT_WORKER_TYPE

private static final java.lang.String ASF_ENDPOINT_WORKER_TYPE
See Also:
Constant Field Values

POLLING_ENDPOINT_WORKER_TYPE

private static final java.lang.String POLLING_ENDPOINT_WORKER_TYPE
See Also:
Constant Field Values

bootstrapContext

private javax.resource.spi.BootstrapContext bootstrapContext

endpointWorkers

private java.util.HashMap endpointWorkers

info

private final ActiveMQConnectionRequestInfo info

endpointWorkerType

private java.lang.String endpointWorkerType

connectionFactory

private org.activemq.ActiveMQConnectionFactory connectionFactory

container

private org.activemq.broker.BrokerContainer container

useEmbeddedBroker

private java.lang.Boolean useEmbeddedBroker

brokerXmlConfig

private java.lang.String brokerXmlConfig

connectionFactoryMap

private java.util.HashMap connectionFactoryMap
Constructor Detail

ActiveMQResourceAdapter

public ActiveMQResourceAdapter()
Method Detail

start

public void start(javax.resource.spi.BootstrapContext bootstrapContext)
           throws javax.resource.spi.ResourceAdapterInternalException
Specified by:
start in interface javax.resource.spi.ResourceAdapter

createBroker

private void createBroker()
                   throws javax.resource.spi.ResourceAdapterInternalException

makeConnection

public org.activemq.ActiveMQConnection makeConnection()
                                               throws javax.jms.JMSException
Return a connection using the default connection request info from the RAR deployment.


makeConnection

public org.activemq.ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo crInfo)
                                               throws javax.jms.JMSException
Return a connection using a specific connection request info.


makeConnection

public org.activemq.ActiveMQConnection makeConnection(ActiveMQActivationSpec activationSpec)
                                               throws javax.jms.JMSException

getConnectionFactory

private org.activemq.ActiveMQConnectionFactory getConnectionFactory(ActiveMQConnectionRequestInfo crInfo)
Returns a connection factory given a connection configuration. The implementation of this method treats the factories as singletons only creating one factory for a given set of configuration data.


defaultValue

private java.lang.String defaultValue(java.lang.String value,
                                      java.lang.String defaultValue)

stop

public void stop()
Specified by:
stop in interface javax.resource.spi.ResourceAdapter

stopBroker

private void stopBroker()

getBootstrapContext

public javax.resource.spi.BootstrapContext getBootstrapContext()

endpointActivation

public void endpointActivation(javax.resource.spi.endpoint.MessageEndpointFactory endpointFactory,
                               javax.resource.spi.ActivationSpec activationSpec)
                        throws javax.resource.ResourceException
Specified by:
endpointActivation in interface javax.resource.spi.ResourceAdapter

endpointDeactivation

public void endpointDeactivation(javax.resource.spi.endpoint.MessageEndpointFactory endpointFactory,
                                 javax.resource.spi.ActivationSpec activationSpec)
Specified by:
endpointDeactivation in interface javax.resource.spi.ResourceAdapter

getXAResources

public javax.transaction.xa.XAResource[] getXAResources(javax.resource.spi.ActivationSpec[] activationSpecs)
                                                 throws javax.resource.ResourceException
We only connect to one resource manager per ResourceAdapter instance, so any ActivationSpec will return the same XAResource.

Specified by:
getXAResources in interface javax.resource.spi.ResourceAdapter

getClientid

public java.lang.String getClientid()

getPassword

public java.lang.String getPassword()

getServerUrl

public java.lang.String getServerUrl()

getUserName

public java.lang.String getUserName()

setClientid

public void setClientid(java.lang.String clientid)

setPassword

public void setPassword(java.lang.String password)

setServerUrl

public void setServerUrl(java.lang.String url)

setUserName

public void setUserName(java.lang.String userid)

getEndpointWorkerType

public java.lang.String getEndpointWorkerType()

setEndpointWorkerType

public void setEndpointWorkerType(java.lang.String endpointWorkerType)

getBrokerXmlConfig

public java.lang.String getBrokerXmlConfig()

setBrokerXmlConfig

public void setBrokerXmlConfig(java.lang.String brokerXmlConfig)
Sets the XML configuration file used to configure the ActiveMQ broker via Spring if using embedded mode.


isUseEmbeddedBroker

public java.lang.Boolean isUseEmbeddedBroker()

setUseEmbeddedBroker

public void setUseEmbeddedBroker(java.lang.Boolean useEmbeddedBroker)

getInfo

public ActiveMQConnectionRequestInfo getInfo()

equals

public boolean equals(java.lang.Object o)
Description copied from class: java.lang.Object
Determine whether this Object is semantically equal to another Object.

There are some fairly strict requirements on this method which subclasses must follow:

  • It must be transitive. If a.equals(b) and b.equals(c), then a.equals(c) must be true as well.
  • It must be symmetric. a.equals(b) and b.equals(a) must have the same value.
  • It must be reflexive. a.equals(a) must always be true.
  • It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
  • a.equals(null) must be false.
  • It must be consistent with hashCode(). That is, a.equals(b) must imply a.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.

This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for a.equals(b) to be true even though a.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.

In general, the Collections API (java.util) use the equals method rather than the == operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.

The default implementation returns this == o.


notEqual

private boolean notEqual(java.lang.Object o1,
                         java.lang.Object o2)

hashCode

public int hashCode()
Description copied from class: java.lang.Object
Get a value that represents this Object, as uniquely as possible within the confines of an int.

There are some requirements on this method which subclasses must follow:

  • Semantic equality implies identical hashcodes. In other words, if a.equals(b) is true, then a.hashCode() == b.hashCode() must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal.
  • It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.

Notice that since hashCode is used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.

The default implementation returns System.identityHashCode(this)


emptyToNull

private java.lang.String emptyToNull(java.lang.String value)

getUseEmbeddedBroker

public java.lang.Boolean getUseEmbeddedBroker()

getUseInboundSession

public java.lang.Boolean getUseInboundSession()

setUseInboundSession

public void setUseInboundSession(java.lang.Boolean useInboundSession)