Search in sources :

Example 1 with ActiveMQEndpointWorker

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

the class ActiveMQResourceAdapter method addJMxControl.

private void addJMxControl(final BeanContext current, final String name) throws ResourceException {
    if (name == null || "false".equalsIgnoreCase(name)) {
        return;
    }
    final ActiveMQEndpointWorker worker = getWorker(current);
    final ObjectName jmxName;
    try {
        jmxName = "true".equalsIgnoreCase(name) ? new ObjectNameBuilder().set("J2EEServer", "openejb").set("J2EEApplication", null).set("EJBModule", current.getModuleID()).set("StatelessSessionBean", current.getEjbName()).set("j2eeType", "control").set("name", current.getEjbName()).build() : new ObjectName(name);
    } catch (final MalformedObjectNameException e) {
        throw new IllegalArgumentException(e);
    }
    mbeanNames.put(current, jmxName);
    LocalMBeanServer.registerSilently(new MdbJmxControl(worker), jmxName);
    log.info("Deployed MDB control for " + current.getDeploymentID() + " on " + jmxName);
}
Also used : ActiveMQEndpointWorker(org.apache.activemq.ra.ActiveMQEndpointWorker) ObjectNameBuilder(org.apache.openejb.monitoring.ObjectNameBuilder) MalformedObjectNameException(javax.management.MalformedObjectNameException) ObjectName(javax.management.ObjectName)

Example 2 with ActiveMQEndpointWorker

use of org.apache.activemq.ra.ActiveMQEndpointWorker 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

ActiveMQEndpointWorker (org.apache.activemq.ra.ActiveMQEndpointWorker)2 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 ObjectName (javax.management.ObjectName)1 NotSupportedException (javax.resource.NotSupportedException)1 ResourceException (javax.resource.ResourceException)1 ActiveMQEndpointActivationKey (org.apache.activemq.ra.ActiveMQEndpointActivationKey)1 MessageActivationSpec (org.apache.activemq.ra.MessageActivationSpec)1 BeanContext (org.apache.openejb.BeanContext)1 ObjectNameBuilder (org.apache.openejb.monitoring.ObjectNameBuilder)1