diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java index 47c95bfe2a..bc2b42f5f6 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRaUtils.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory; +import org.jgroups.JChannel; /** * Various utility functions @@ -236,19 +236,19 @@ public final class ActiveMQRaUtils { /** * Within AS7 the RA is loaded by JCA. properties can only be passed in String form. However if - * RA is configured using jgroups stack, we need to pass a BroadcastEndpointFactory object. As is impossible with - * JCA, we use this method to allow a BroadcastEndpointFactory object to be located. + * RA is configured using jgroups stack, we need to pass a Channel object. As is impossible with + * JCA, we use this method to allow a JChannel object to be located. */ - public static BroadcastEndpointFactory locateBroadcastEndpointFactory(final String locatorClass, final String name) { - return AccessController.doPrivileged(new PrivilegedAction() { + public static JChannel locateJGroupsChannel(final String locatorClass, final String name) { + return AccessController.doPrivileged(new PrivilegedAction() { @Override - public BroadcastEndpointFactory run() { + public JChannel run() { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class aClass = loader.loadClass(locatorClass); Object o = aClass.newInstance(); - Method m = aClass.getMethod("locateBroadcastEndpointFactory", new Class[]{String.class}); - return (BroadcastEndpointFactory) m.invoke(o, name); + Method m = aClass.getMethod("locateChannel", new Class[]{String.class}); + return (JChannel) m.invoke(o, name); } catch (Throwable e) { ActiveMQRALogger.LOGGER.debug(e.getMessage(), e); return null; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java index 98129804cd..bd4b8c919d 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java @@ -42,6 +42,7 @@ import java.util.regex.Pattern; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory; +import org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory; import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration; import org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory; import org.apache.activemq.artemis.api.core.Pair; @@ -60,6 +61,7 @@ import org.apache.activemq.artemis.service.extensions.ServiceUtils; import org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig; import org.apache.activemq.artemis.utils.SensitiveDataCodec; import org.jboss.logging.Logger; +import org.jgroups.JChannel; /** * The resource adapter for ActiveMQ @@ -1714,7 +1716,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { if (jgroupsLocatorClassName != null) { String jchannelRefName = raProperties.getJgroupsChannelRefName(); - endpointFactory = ActiveMQRaUtils.locateBroadcastEndpointFactory(jgroupsLocatorClassName, jchannelRefName); + JChannel jchannel = ActiveMQRaUtils.locateJGroupsChannel(jgroupsLocatorClassName, jchannelRefName); + endpointFactory = new ChannelBroadcastEndpointFactory(jchannel, jgroupsChannel); } else if (discoveryAddress != null) { Integer discoveryPort = overrideProperties.getDiscoveryPort() != null ? overrideProperties.getDiscoveryPort() : getDiscoveryPort(); if (discoveryPort == null) { @@ -1814,7 +1817,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { String jgroupsLocatorClass = raProperties.getJgroupsChannelLocatorClass(); if (jgroupsLocatorClass != null) { String jgroupsChannelRefName = raProperties.getJgroupsChannelRefName(); - endpointFactory = ActiveMQRaUtils.locateBroadcastEndpointFactory(jgroupsLocatorClass, jgroupsChannelRefName); + JChannel jchannel = ActiveMQRaUtils.locateJGroupsChannel(jgroupsLocatorClass, jgroupsChannelRefName); + endpointFactory = new ChannelBroadcastEndpointFactory(jchannel, jgroupsChannel); } if (endpointFactory == null) { throw new IllegalArgumentException("must provide either TransportType or DiscoveryGroupAddress and DiscoveryGroupPort for ResourceAdapter Connection Factory");