Search in sources :

Example 1 with ActiveMQEndpointActivationKey

use of org.apache.activemq.ra.ActiveMQEndpointActivationKey in project tomee by apache.

the class ActiveMQResourceAdapter method endpointActivation.

@Override
public void endpointActivation(final MessageEndpointFactory endpointFactory, final ActivationSpec activationSpec) throws ResourceException {
    final BeanContext current = MdbContainer.current();
    if (current != null && "false".equalsIgnoreCase(current.getProperties().getProperty("MdbActiveOnStartup"))) {
        if (!equals(activationSpec.getResourceAdapter())) {
            throw new ResourceException("Activation spec not initialized with this ResourceAdapter instance (" + activationSpec.getResourceAdapter() + " != " + this + ")");
        }
        if (!(activationSpec instanceof MessageActivationSpec)) {
            throw new NotSupportedException("That type of ActivationSpec not supported: " + activationSpec.getClass());
        }
        final ActiveMQEndpointActivationKey key = new ActiveMQEndpointActivationKey(endpointFactory, MessageActivationSpec.class.cast(activationSpec));
        Map.class.cast(Reflections.get(this, "endpointWorkers")).put(key, new ActiveMQEndpointWorker(this, key) {
        });
    // we dont want that worker.start();
    } else {
        super.endpointActivation(endpointFactory, activationSpec);
    }
    if (current != null) {
        addJMxControl(current, current.getProperties().getProperty("MdbJMXControl"));
    }
}
Also used : ActiveMQEndpointWorker(org.apache.activemq.ra.ActiveMQEndpointWorker) BeanContext(org.apache.openejb.BeanContext) ResourceException(javax.resource.ResourceException) MessageActivationSpec(org.apache.activemq.ra.MessageActivationSpec) NotSupportedException(javax.resource.NotSupportedException) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ActiveMQEndpointActivationKey(org.apache.activemq.ra.ActiveMQEndpointActivationKey)

Aggregations

Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 NotSupportedException (javax.resource.NotSupportedException)1 ResourceException (javax.resource.ResourceException)1 ActiveMQEndpointActivationKey (org.apache.activemq.ra.ActiveMQEndpointActivationKey)1 ActiveMQEndpointWorker (org.apache.activemq.ra.ActiveMQEndpointWorker)1 MessageActivationSpec (org.apache.activemq.ra.MessageActivationSpec)1 BeanContext (org.apache.openejb.BeanContext)1