merge #23 - Add Service Extension Component
This commit is contained in:
commit
5996d697cd
|
@ -52,20 +52,15 @@
|
|||
<artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.ironjacamar</groupId>
|
||||
<artifactId>ironjacamar-core-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-ejb_3.0_spec</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss</groupId>
|
||||
<artifactId>jboss-transaction-spi</artifactId>
|
||||
<scope>provided</scope>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-service-extensions</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -35,8 +35,10 @@ import javax.transaction.xa.XAResource;
|
|||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -46,6 +48,9 @@ import org.apache.activemq.core.client.impl.ClientSessionInternal;
|
|||
import org.apache.activemq.jms.client.ActiveMQConnection;
|
||||
import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.jms.client.ActiveMQXAConnection;
|
||||
import org.apache.activemq.service.extensions.ServiceUtils;
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapper;
|
||||
import org.apache.activemq.utils.VersionLoader;
|
||||
|
||||
/**
|
||||
* The managed connection
|
||||
|
@ -531,7 +536,12 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
|
|||
{
|
||||
ClientSessionInternal csi = (ClientSessionInternal) xaSession.getXAResource();
|
||||
ActiveMQRAXAResource activeMQRAXAResource = new ActiveMQRAXAResource(this, xaSession.getXAResource());
|
||||
xaResource = new ActiveMQXAResourceWrapper(activeMQRAXAResource, ra.getJndiName(), csi.getNodeId());
|
||||
Map<String, Object> xaResourceProperties = new HashMap<String, Object>();
|
||||
xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_JNDI_NAME, ra.getJndiName());
|
||||
xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_NODE_ID, csi.getNodeId());
|
||||
xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_PRODUCT_NAME, ActiveMQResourceAdapter.PRODUCT_NAME);
|
||||
xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_PRODUCT_VERSION, VersionLoader.getVersion().getFullVersion());
|
||||
xaResource = ServiceUtils.wrapXAResource(activeMQRAXAResource, xaResourceProperties);
|
||||
}
|
||||
|
||||
if (ActiveMQRAManagedConnection.trace)
|
||||
|
|
|
@ -19,6 +19,8 @@ import javax.resource.spi.endpoint.MessageEndpointFactory;
|
|||
import javax.transaction.Transaction;
|
||||
import javax.transaction.TransactionManager;
|
||||
import javax.transaction.xa.XAResource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.activemq.api.core.ActiveMQException;
|
||||
|
@ -34,8 +36,10 @@ import org.apache.activemq.jms.client.ActiveMQDestination;
|
|||
import org.apache.activemq.jms.client.ActiveMQMessage;
|
||||
import org.apache.activemq.ra.ActiveMQRALogger;
|
||||
import org.apache.activemq.ra.ActiveMQResourceAdapter;
|
||||
import org.apache.activemq.ra.ActiveMQXAResourceWrapper;
|
||||
import org.apache.activemq.service.extensions.ServiceUtils;
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapper;
|
||||
import org.apache.activemq.utils.FutureLatch;
|
||||
import org.apache.activemq.utils.VersionLoader;
|
||||
|
||||
/**
|
||||
* The message handler
|
||||
|
@ -191,9 +195,13 @@ public class ActiveMQMessageHandler implements MessageHandler
|
|||
transacted = activation.isDeliveryTransacted();
|
||||
if (activation.isDeliveryTransacted() && !activation.getActivationSpec().isUseLocalTx())
|
||||
{
|
||||
XAResource xaResource = new ActiveMQXAResourceWrapper(session,
|
||||
((ActiveMQResourceAdapter) spec.getResourceAdapter()).getJndiName(),
|
||||
((ClientSessionFactoryInternal) cf).getLiveNodeId());
|
||||
Map<String, Object> xaResourceProperties = new HashMap<String, Object>();
|
||||
xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_JNDI_NAME, ((ActiveMQResourceAdapter) spec.getResourceAdapter()).getJndiName());
|
||||
xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_NODE_ID, ((ClientSessionFactoryInternal) cf).getLiveNodeId());
|
||||
xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_PRODUCT_NAME, ActiveMQResourceAdapter.PRODUCT_NAME);
|
||||
xaResourceProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_PRODUCT_VERSION, VersionLoader.getVersion().getFullVersion());
|
||||
XAResource xaResource = ServiceUtils.wrapXAResource(session, xaResourceProperties);
|
||||
|
||||
endpoint = endpointFactory.createEndpoint(xaResource);
|
||||
useXA = true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-pom</artifactId>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>activemq-service-extensions</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>ActiveMQ6 Service Extensions</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-core-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.logging</groupId>
|
||||
<artifactId>jboss-logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.logging</groupId>
|
||||
<artifactId>jboss-logging-processor</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<activemq.basedir>${project.basedir}/..</activemq.basedir>
|
||||
</properties>
|
||||
</project>
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2005-2014 Red Hat, Inc.
|
||||
* Red Hat licenses this file to you under the Apache License, version
|
||||
* 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.service.extensions;
|
||||
|
||||
import javax.transaction.xa.XAResource;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapper;
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapperFactory;
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapperFactoryImpl;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mtaylor@redhat.com">Martyn Taylor</a>
|
||||
*/
|
||||
|
||||
public class ServiceUtils
|
||||
{
|
||||
private static ActiveMQXAResourceWrapperFactory activeMQXAResourceWrapperFactory;
|
||||
|
||||
private static ActiveMQXAResourceWrapperFactory getActiveMQXAResourceWrapperFactory()
|
||||
{
|
||||
if (activeMQXAResourceWrapperFactory == null)
|
||||
{
|
||||
setActiveMQXAResourceWrapperFactory(ServiceLoader.load(ActiveMQXAResourceWrapperFactory.class));
|
||||
}
|
||||
return activeMQXAResourceWrapperFactory;
|
||||
}
|
||||
|
||||
public static ActiveMQXAResourceWrapper wrapXAResource(XAResource xaResource, Map<String, Object> properties)
|
||||
{
|
||||
return getActiveMQXAResourceWrapperFactory().wrap(xaResource, properties);
|
||||
}
|
||||
|
||||
private static void setActiveMQXAResourceWrapperFactory(Iterable<ActiveMQXAResourceWrapperFactory> iterable)
|
||||
{
|
||||
if (iterable.iterator().hasNext())
|
||||
{
|
||||
activeMQXAResourceWrapperFactory = iterable.iterator().next();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeMQXAResourceWrapperFactory = new ActiveMQXAResourceWrapperFactoryImpl();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2005-2014 Red Hat, Inc.
|
||||
* Red Hat licenses this file to you under the Apache License, version
|
||||
* 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.service.extensions.xa;
|
||||
|
||||
import javax.transaction.xa.XAResource;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mtaylor@redhat.com">Martyn Taylor</a>
|
||||
*/
|
||||
|
||||
public interface ActiveMQXAResourceWrapper extends XAResource
|
||||
{
|
||||
// List of supported properties
|
||||
String ACTIVEMQ_JNDI_NAME = "ACTIVEMQ_JNDI_ID";
|
||||
|
||||
String ACTIVEMQ_PRODUCT_NAME = "ACTIVEMQ_PRODUCT_NAME";
|
||||
|
||||
String ACTIVEMQ_PRODUCT_VERSION = "ACTIVEMQ_PRODUCT_VERSION";
|
||||
|
||||
String ACTIVEMQ_NODE_ID = "ACTIVEMQ_NODE_ID";
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright 2005-2014 Red Hat, Inc.
|
||||
* Red Hat licenses this file to you under the Apache License, version
|
||||
* 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.service.extensions.xa;
|
||||
|
||||
import javax.transaction.xa.XAResource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mtaylor@redhat.com">Martyn Taylor</a>
|
||||
*/
|
||||
|
||||
public interface ActiveMQXAResourceWrapperFactory
|
||||
{
|
||||
ActiveMQXAResourceWrapper wrap(XAResource xaResource, Map<String, Object> properties);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright 2005-2014 Red Hat, Inc.
|
||||
* Red Hat licenses this file to you under the Apache License, version
|
||||
* 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.service.extensions.xa;
|
||||
|
||||
import javax.transaction.xa.XAResource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mtaylor@redhat.com">Martyn Taylor</a>
|
||||
*/
|
||||
|
||||
public class ActiveMQXAResourceWrapperFactoryImpl implements ActiveMQXAResourceWrapperFactory
|
||||
{
|
||||
|
||||
@Override
|
||||
public ActiveMQXAResourceWrapper wrap(XAResource xaResource, Map<String, Object> properties)
|
||||
{
|
||||
return new ActiveMQXAResourceWrapperImpl(xaResource, properties);
|
||||
}
|
||||
}
|
|
@ -11,23 +11,18 @@
|
|||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.ra;
|
||||
package org.apache.activemq.service.extensions.xa;
|
||||
|
||||
import javax.transaction.xa.XAException;
|
||||
import javax.transaction.xa.XAResource;
|
||||
import javax.transaction.xa.Xid;
|
||||
|
||||
import org.apache.activemq.core.client.impl.ActiveMQXAResource;
|
||||
import org.apache.activemq.utils.VersionLoader;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mtaylor@redhat.com">Martyn Taylor</a>
|
||||
*
|
||||
* Wraps XAResource with org.jboss.tm.XAResourceWrapper. This adds extra meta-data to to the XAResource used by
|
||||
* Transaction Manager for recovery scenarios.
|
||||
*/
|
||||
|
||||
public class ActiveMQXAResourceWrapper implements org.jboss.tm.XAResourceWrapper, org.jboss.jca.core.spi.transaction.xa.XAResourceWrapper, ActiveMQXAResource
|
||||
public class ActiveMQXAResourceWrapperImpl implements ActiveMQXAResourceWrapper
|
||||
{
|
||||
private final XAResource xaResource;
|
||||
|
||||
|
@ -46,35 +41,35 @@ public class ActiveMQXAResourceWrapper implements org.jboss.tm.XAResourceWrapper
|
|||
* from relevant recovery scenarios.
|
||||
*
|
||||
* @param xaResource
|
||||
* @param jndiName
|
||||
* @param properties
|
||||
*/
|
||||
public ActiveMQXAResourceWrapper(XAResource xaResource, String jndiName, String nodeId)
|
||||
public ActiveMQXAResourceWrapperImpl(XAResource xaResource, Map<String, Object> properties)
|
||||
{
|
||||
this.xaResource = xaResource;
|
||||
this.productName = ActiveMQResourceAdapter.PRODUCT_NAME;
|
||||
this.productVersion = VersionLoader.getVersion().getFullVersion();
|
||||
this.jndiNameNodeId = jndiName + " NodeId:" + nodeId;
|
||||
//this.productName = ActiveMQResourceAdapter.PRODUCT_NAME;
|
||||
this.productName = (String) properties.get(ActiveMQXAResourceWrapper.ACTIVEMQ_PRODUCT_NAME);
|
||||
//this.productVersion = VersionLoader.getVersion().getFullVersion();
|
||||
this.productVersion = (String) properties.get(ActiveMQXAResourceWrapper.ACTIVEMQ_PRODUCT_VERSION);
|
||||
|
||||
this.jndiNameNodeId = properties.get(ActiveMQXAResourceWrapper.ACTIVEMQ_JNDI_NAME) +
|
||||
" NodeId:" + properties.get(ActiveMQXAResourceWrapper.ACTIVEMQ_NODE_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XAResource getResource()
|
||||
{
|
||||
return xaResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProductName()
|
||||
{
|
||||
return productName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProductVersion()
|
||||
{
|
||||
return productVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJndiName()
|
||||
{
|
||||
return jndiNameNodeId;
|
|
@ -11,33 +11,41 @@
|
|||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.tests.unit.xa;
|
||||
package org.apache.activemq.service.extensions.tests.xa;
|
||||
|
||||
import javax.transaction.xa.XAResource;
|
||||
|
||||
import org.apache.activemq.ra.ActiveMQRAXAResource;
|
||||
import org.apache.activemq.ra.ActiveMQXAResourceWrapper;
|
||||
import org.apache.activemq.tests.util.UnitTestCase;
|
||||
import org.jboss.tm.XAResourceWrapper;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapper;
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapperImpl;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.jgroups.util.Util.assertEquals;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mtaylor@redhat.com">Martyn Taylor</a>
|
||||
*/
|
||||
|
||||
public class XAResourceWrapperTest extends UnitTestCase
|
||||
public class ActiveMQXAResourceWrapperImplTest
|
||||
{
|
||||
@Test
|
||||
public void testXAResourceWrapper()
|
||||
{
|
||||
String jndiName = "java://jmsXA";
|
||||
String nodeId = "0";
|
||||
XAResource xaResource = new ActiveMQRAXAResource(null, null);
|
||||
XAResourceWrapper xaResourceWrapper = new ActiveMQXAResourceWrapper(xaResource, jndiName, nodeId);
|
||||
XAResource xaResource = new MockXAResource();
|
||||
|
||||
assertEquals(xaResource, xaResourceWrapper.getResource());
|
||||
Map<String, Object> xaResourceWrapperProperties = new HashMap<String, Object>();
|
||||
xaResourceWrapperProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_JNDI_NAME, jndiName);
|
||||
xaResourceWrapperProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_NODE_ID, nodeId);
|
||||
xaResourceWrapperProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_PRODUCT_VERSION, "6");
|
||||
xaResourceWrapperProperties.put(ActiveMQXAResourceWrapper.ACTIVEMQ_PRODUCT_NAME, "ActiveMQ");
|
||||
ActiveMQXAResourceWrapperImpl xaResourceWrapper = new ActiveMQXAResourceWrapperImpl(xaResource, xaResourceWrapperProperties);
|
||||
|
||||
String expectedJndiNodeId = jndiName + " NodeId:" + nodeId;
|
||||
assertEquals(xaResource, xaResourceWrapper.getResource());
|
||||
assertEquals(expectedJndiNodeId, xaResourceWrapper.getJndiName());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2005-2014 Red Hat, Inc.
|
||||
* Red Hat licenses this file to you under the Apache License, version
|
||||
* 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.service.extensions.tests.xa;
|
||||
|
||||
import javax.transaction.xa.XAResource;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapper;
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapperFactory;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mtaylor@redhat.com">Martyn Taylor</a>
|
||||
*/
|
||||
|
||||
public class MockActiveMQResourceWrapperFactory implements ActiveMQXAResourceWrapperFactory
|
||||
{
|
||||
@Override
|
||||
public ActiveMQXAResourceWrapper wrap(XAResource xaResource, Map<String, Object> properties)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright 2005-2014 Red Hat, Inc.
|
||||
* Red Hat licenses this file to you under the Apache License, version
|
||||
* 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.service.extensions.tests.xa;
|
||||
|
||||
import javax.transaction.xa.XAException;
|
||||
import javax.transaction.xa.XAResource;
|
||||
import javax.transaction.xa.Xid;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mtaylor@redhat.com">Martyn Taylor</a>
|
||||
*/
|
||||
|
||||
public class MockXAResource implements XAResource
|
||||
{
|
||||
@Override
|
||||
public void commit(Xid xid, boolean b) throws XAException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(Xid xid, int i) throws XAException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forget(Xid xid) throws XAException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransactionTimeout() throws XAException
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameRM(XAResource xaResource) throws XAException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int prepare(Xid xid) throws XAException
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Xid[] recover(int i) throws XAException
|
||||
{
|
||||
return new Xid[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(Xid xid) throws XAException
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setTransactionTimeout(int i) throws XAException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Xid xid, int i) throws XAException
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright 2005-2014 Red Hat, Inc.
|
||||
* Red Hat licenses this file to you under the Apache License, version
|
||||
* 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.service.extensions.tests.xa;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.activemq.service.extensions.ServiceUtils;
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapperFactory;
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapperFactoryImpl;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.jgroups.util.Util.assertTrue;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:mtaylor@redhat.com">Martyn Taylor</a>
|
||||
*/
|
||||
|
||||
public class ServiceUtilsTest
|
||||
{
|
||||
@Test
|
||||
public void testSetActiveMQXAResourceWrapperFactorySetsDefaultImplWhenNoOther() throws Exception
|
||||
{
|
||||
List<ActiveMQXAResourceWrapperFactory> factories = new ArrayList<ActiveMQXAResourceWrapperFactory>();
|
||||
|
||||
Method method = ServiceUtils.class.getDeclaredMethod("setActiveMQXAResourceWrapperFactory", Iterable.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(null, factories);
|
||||
|
||||
Field field = ServiceUtils.class.getDeclaredField("activeMQXAResourceWrapperFactory");
|
||||
field.setAccessible(true);
|
||||
assertTrue(field.get(null) instanceof ActiveMQXAResourceWrapperFactoryImpl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetActiveMQXAResourceWrapperFactorySetsExtensionImplWhenSupplied() throws Exception
|
||||
{
|
||||
List<ActiveMQXAResourceWrapperFactory> factories = new ArrayList<ActiveMQXAResourceWrapperFactory>();
|
||||
factories.add(new MockActiveMQResourceWrapperFactory());
|
||||
|
||||
Method method = ServiceUtils.class.getDeclaredMethod("setActiveMQXAResourceWrapperFactory", Iterable.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(null, factories);
|
||||
|
||||
Field field = ServiceUtils.class.getDeclaredField("activeMQXAResourceWrapperFactory");
|
||||
field.setAccessible(true);
|
||||
assertTrue(field.get(null) instanceof MockActiveMQResourceWrapperFactory);
|
||||
}
|
||||
}
|
12
pom.xml
12
pom.xml
|
@ -242,12 +242,6 @@
|
|||
<artifactId>jbossjts-jacorb</artifactId>
|
||||
<version>4.17.13.Final</version>
|
||||
</dependency>
|
||||
<!-- this for Ironjacamar SPI XAResourceWrapper implementation -->
|
||||
<dependency>
|
||||
<groupId>org.jboss.ironjacamar</groupId>
|
||||
<artifactId>ironjacamar-core-api</artifactId>
|
||||
<version>1.2.0.Beta2</version>
|
||||
</dependency>
|
||||
<!--needed to compile security-->
|
||||
<dependency>
|
||||
<groupId>org.jboss.security</groupId>
|
||||
|
@ -489,6 +483,7 @@
|
|||
<module>activemq-ra</module>
|
||||
<module>activemq-rest</module>
|
||||
<module>activemq-tools</module>
|
||||
<module>activemq-service-extensions</module>
|
||||
<!-- <module>integration/activemq-jboss-as-integration</module> -->
|
||||
<module>integration/activemq-spring-integration</module>
|
||||
<module>integration/activemq-twitter-integration</module>
|
||||
|
@ -513,6 +508,7 @@
|
|||
<module>activemq-ra</module>
|
||||
<module>activemq-rest</module>
|
||||
<module>activemq-tools</module>
|
||||
<module>activemq-service-extensions</module>
|
||||
<module>integration/activemq-jboss-as-integration</module>
|
||||
<module>integration/activemq-spring-integration</module>
|
||||
<module>integration/activemq-twitter-integration</module>
|
||||
|
@ -537,6 +533,7 @@
|
|||
<module>activemq-ra</module>
|
||||
<module>activemq-rest</module>
|
||||
<module>activemq-tools</module>
|
||||
<module>activemq-service-extensions</module>
|
||||
<module>integration/activemq-jboss-as-integration</module>
|
||||
<module>integration/activemq-spring-integration</module>
|
||||
<module>integration/activemq-twitter-integration</module>
|
||||
|
@ -563,6 +560,7 @@
|
|||
<module>activemq-ra</module>
|
||||
<module>activemq-rest</module>
|
||||
<module>activemq-tools</module>
|
||||
<module>activemq-service-extensions</module>
|
||||
<module>integration/activemq-jboss-as-integration</module>
|
||||
<module>integration/activemq-spring-integration</module>
|
||||
<module>integration/activemq-twitter-integration</module>
|
||||
|
@ -600,6 +598,7 @@
|
|||
<module>activemq-ra</module>
|
||||
<module>activemq-rest</module>
|
||||
<module>activemq-tools</module>
|
||||
<module>activemq-service-extensions</module>
|
||||
<module>integration/activemq-jboss-as-integration</module>
|
||||
<module>integration/activemq-spring-integration</module>
|
||||
<module>integration/activemq-twitter-integration</module>
|
||||
|
@ -633,6 +632,7 @@
|
|||
<module>activemq-ra</module>
|
||||
<module>activemq-rest</module>
|
||||
<module>activemq-tools</module>
|
||||
<module>activemq-service-extensions</module>
|
||||
<module>integration/activemq-jboss-as-integration</module>
|
||||
<module>integration/activemq-spring-integration</module>
|
||||
<module>integration/activemq-twitter-integration</module>
|
||||
|
|
|
@ -220,11 +220,6 @@
|
|||
<version>1.0.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.ironjacamar</groupId>
|
||||
<artifactId>ironjacamar-core-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -49,8 +49,9 @@ import org.apache.activemq.ra.ActiveMQRAConnectionManager;
|
|||
import org.apache.activemq.ra.ActiveMQRAManagedConnectionFactory;
|
||||
import org.apache.activemq.ra.ActiveMQRASession;
|
||||
import org.apache.activemq.ra.ActiveMQResourceAdapter;
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapper;
|
||||
import org.apache.activemq.service.extensions.xa.ActiveMQXAResourceWrapperImpl;
|
||||
import org.apache.activemq.utils.UUIDGenerator;
|
||||
import org.apache.activemq.ra.ActiveMQXAResourceWrapper;
|
||||
import org.apache.activemq.utils.VersionLoader;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -525,7 +526,7 @@ public class OutgoingConnectionTest extends ActiveMQRATestBase
|
|||
XAResource resource = s.getXAResource();
|
||||
assertTrue(resource instanceof ActiveMQXAResourceWrapper);
|
||||
|
||||
ActiveMQXAResourceWrapper xaResourceWrapper = (ActiveMQXAResourceWrapper) resource;
|
||||
ActiveMQXAResourceWrapperImpl xaResourceWrapper = (ActiveMQXAResourceWrapperImpl) resource;
|
||||
assertTrue(xaResourceWrapper.getJndiName().equals("java://jmsXA NodeId:" + server.getNodeID()));
|
||||
assertTrue(xaResourceWrapper.getProductVersion().equals(VersionLoader.getVersion().getFullVersion()));
|
||||
assertTrue(xaResourceWrapper.getProductName().equals(ActiveMQResourceAdapter.PRODUCT_NAME));
|
||||
|
|
|
@ -75,11 +75,6 @@
|
|||
<groupId>org.jboss.logging</groupId>
|
||||
<artifactId>jboss-logging-processor</artifactId>
|
||||
</dependency>
|
||||
<!-- this for Ironjacamar SPI XAResourceWrapper implementation -->
|
||||
<dependency>
|
||||
<groupId>org.jboss.ironjacamar</groupId>
|
||||
<artifactId>ironjacamar-core-api</artifactId>
|
||||
</dependency>
|
||||
<!--
|
||||
JBoss Logging
|
||||
-->
|
||||
|
|
Loading…
Reference in New Issue