Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6582F184D6 for ; Wed, 2 Sep 2015 20:09:43 +0000 (UTC) Received: (qmail 43784 invoked by uid 500); 2 Sep 2015 20:09:40 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 43692 invoked by uid 500); 2 Sep 2015 20:09:40 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 43622 invoked by uid 99); 2 Sep 2015 20:09:40 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2015 20:09:40 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 246A6DFC88; Wed, 2 Sep 2015 20:09:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cshannon@apache.org To: commits@activemq.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: activemq git commit: https://issues.apache.org/jira/browse/AMQ-5941 Date: Wed, 2 Sep 2015 20:09:40 +0000 (UTC) Repository: activemq Updated Branches: refs/heads/activemq-5.12.x 3619724d9 -> b5663bb0a https://issues.apache.org/jira/browse/AMQ-5941 Modifying ActiveMQResourceAdapter to implement Serializable to support WebLogic. (cherry picked from commit d983d525ce22025dd6ad4b27e729e1a1917f06f5) Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/b5663bb0 Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/b5663bb0 Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/b5663bb0 Branch: refs/heads/activemq-5.12.x Commit: b5663bb0a97353f6c5b3f5365f1aea67fc150b55 Parents: 3619724 Author: Christopher L. Shannon (cshannon) Authored: Mon Aug 24 13:02:02 2015 +0000 Committer: Christopher L. Shannon (cshannon) Committed: Wed Sep 2 20:09:00 2015 +0000 ---------------------------------------------------------------------- .../activemq/ra/ActiveMQResourceAdapter.java | 44 ++++++++++++-------- 1 file changed, 27 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/b5663bb0/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java ---------------------------------------------------------------------- diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java index 8c5d4ca..fd16603 100644 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java @@ -16,6 +16,7 @@ */ package org.apache.activemq.ra; +import java.io.Serializable; import java.net.URI; import java.util.HashMap; @@ -28,8 +29,8 @@ import javax.resource.spi.ResourceAdapterInternalException; import javax.resource.spi.endpoint.MessageEndpointFactory; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; - import javax.transaction.xa.Xid; + import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.RedeliveryPolicy; @@ -44,23 +45,24 @@ import org.slf4j.LoggerFactory; * Knows how to connect to one ActiveMQ server. It can then activate endpoints * and deliver messages to those end points using the connection configure in * the resource adapter.

Must override equals and hashCode (JCA spec 16.4) - * + * * @org.apache.xbean.XBean element="resourceAdapter" rootElement="true" * description="The JCA Resource Adaptor for ActiveMQ" - * + * */ -public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implements MessageResourceAdapter { +public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implements Serializable, MessageResourceAdapter { + private static final long serialVersionUID = 360805587169336959L; private static final Logger LOG = LoggerFactory.getLogger(ActiveMQResourceAdapter.class); - private final HashMap endpointWorkers = new HashMap(); + private transient final HashMap endpointWorkers = new HashMap(); - private BootstrapContext bootstrapContext; + private transient BootstrapContext bootstrapContext; private String brokerXmlConfig; - private BrokerService broker; - private Thread brokerStartThread; + private transient BrokerService broker; + private transient Thread brokerStartThread; private ActiveMQConnectionFactory connectionFactory; - + /** - * + * */ public ActiveMQResourceAdapter() { super(); @@ -69,6 +71,7 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement /** * @see javax.resource.spi.ResourceAdapter#start(javax.resource.spi.BootstrapContext) */ + @Override public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException { this.bootstrapContext = bootstrapContext; if (brokerXmlConfig != null && brokerXmlConfig.trim().length() > 0) { @@ -80,7 +83,7 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement log.debug("original thread context classLoader: " + Thread.currentThread().getContextClassLoader()); Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); log.debug("current (from getClass()) thread context classLoader: " + Thread.currentThread().getContextClassLoader()); - + synchronized( ActiveMQResourceAdapter.this ) { broker = BrokerFactory.createBroker(new URI(brokerXmlConfig)); } @@ -97,13 +100,13 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement }; brokerStartThread.setDaemon(true); brokerStartThread.start(); - + // Wait up to 5 seconds for the broker to start up in the async thread.. otherwise keep going without it.. try { brokerStartThread.join(1000*5); } catch (InterruptedException e) { Thread.currentThread().interrupt(); - } + } } } @@ -118,6 +121,7 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement /** * @param activationSpec */ + @Override public ActiveMQConnection makeConnection(MessageActivationSpec activationSpec) throws JMSException { ActiveMQConnectionFactory cf = getConnectionFactory(); if (cf == null) { @@ -146,6 +150,7 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement /** * @see javax.resource.spi.ResourceAdapter#stop() */ + @Override public void stop() { synchronized (endpointWorkers) { while (endpointWorkers.size() > 0) { @@ -153,7 +158,7 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement endpointDeactivation(key.getMessageEndpointFactory(), key.getActivationSpec()); } } - + synchronized( this ) { if (broker != null) { if( brokerStartThread.isAlive() ) { @@ -163,13 +168,14 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement broker = null; } } - + this.bootstrapContext = null; } /** * @see org.apache.activemq.ra.MessageResourceAdapter#getBootstrapContext() */ + @Override public BootstrapContext getBootstrapContext() { return bootstrapContext; } @@ -178,6 +184,7 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement * @see javax.resource.spi.ResourceAdapter#endpointActivation(javax.resource.spi.endpoint.MessageEndpointFactory, * javax.resource.spi.ActivationSpec) */ + @Override public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec activationSpec) throws ResourceException { // spec section 5.3.3 @@ -206,6 +213,7 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement * @see javax.resource.spi.ResourceAdapter#endpointDeactivation(javax.resource.spi.endpoint.MessageEndpointFactory, * javax.resource.spi.ActivationSpec) */ + @Override public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec activationSpec) { if (activationSpec instanceof MessageActivationSpec) { ActiveMQEndpointActivationKey key = new ActiveMQEndpointActivationKey(endpointFactory, (MessageActivationSpec)activationSpec); @@ -236,9 +244,10 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement /** * We only connect to one resource manager per ResourceAdapter instance, so * any ActivationSpec will return the same XAResource. - * + * * @see javax.resource.spi.ResourceAdapter#getXAResources(javax.resource.spi.ActivationSpec[]) */ + @Override public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException { try { return new XAResource[]{ @@ -376,6 +385,7 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement /** * @see org.apache.activemq.ra.MessageResourceAdapter#getBrokerXmlConfig() */ + @Override public String getBrokerXmlConfig() { return brokerXmlConfig; } @@ -384,7 +394,7 @@ public class ActiveMQResourceAdapter extends ActiveMQConnectionSupport implement * Sets the XML * configuration file used to configure the ActiveMQ broker via Spring * if using embedded mode. - * + * * @param brokerXmlConfig is the filename which is assumed to be on the * classpath unless a URL is specified. So a value of * foo/bar.xml would be assumed to be on the