Revert "Changing the way to interact with JGroups in the ResourceAdapter"
This reverts commit 2493158d11
.
This is causing some problems with the classloader used in the RA,
resulting in NPEs. Reverting this. We can revist when we have a more
stable solution.
This commit is contained in:
parent
16eca68bff
commit
fcce3bac2a
|
@ -27,7 +27,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
|
import org.jgroups.JChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Various utility functions
|
* 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
|
* 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
|
* 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 BroadcastEndpointFactory object to be located.
|
* JCA, we use this method to allow a JChannel object to be located.
|
||||||
*/
|
*/
|
||||||
public static BroadcastEndpointFactory locateBroadcastEndpointFactory(final String locatorClass, final String name) {
|
public static JChannel locateJGroupsChannel(final String locatorClass, final String name) {
|
||||||
return AccessController.doPrivileged(new PrivilegedAction<BroadcastEndpointFactory>() {
|
return AccessController.doPrivileged(new PrivilegedAction<JChannel>() {
|
||||||
@Override
|
@Override
|
||||||
public BroadcastEndpointFactory run() {
|
public JChannel run() {
|
||||||
try {
|
try {
|
||||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
Class<?> aClass = loader.loadClass(locatorClass);
|
Class<?> aClass = loader.loadClass(locatorClass);
|
||||||
Object o = aClass.newInstance();
|
Object o = aClass.newInstance();
|
||||||
Method m = aClass.getMethod("locateBroadcastEndpointFactory", new Class[]{String.class});
|
Method m = aClass.getMethod("locateChannel", new Class[]{String.class});
|
||||||
return (BroadcastEndpointFactory) m.invoke(o, name);
|
return (JChannel) m.invoke(o, name);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
ActiveMQRALogger.LOGGER.debug(e.getMessage(), e);
|
ActiveMQRALogger.LOGGER.debug(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -42,6 +42,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||||
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
|
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.DiscoveryGroupConfiguration;
|
||||||
import org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory;
|
import org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory;
|
||||||
import org.apache.activemq.artemis.api.core.Pair;
|
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.service.extensions.xa.recovery.XARecoveryConfig;
|
||||||
import org.apache.activemq.artemis.utils.SensitiveDataCodec;
|
import org.apache.activemq.artemis.utils.SensitiveDataCodec;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
import org.jgroups.JChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The resource adapter for ActiveMQ
|
* The resource adapter for ActiveMQ
|
||||||
|
@ -1714,7 +1716,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable {
|
||||||
|
|
||||||
if (jgroupsLocatorClassName != null) {
|
if (jgroupsLocatorClassName != null) {
|
||||||
String jchannelRefName = raProperties.getJgroupsChannelRefName();
|
String jchannelRefName = raProperties.getJgroupsChannelRefName();
|
||||||
endpointFactory = ActiveMQRaUtils.locateBroadcastEndpointFactory(jgroupsLocatorClassName, jchannelRefName);
|
JChannel jchannel = ActiveMQRaUtils.locateJGroupsChannel(jgroupsLocatorClassName, jchannelRefName);
|
||||||
|
endpointFactory = new ChannelBroadcastEndpointFactory(jchannel, jgroupsChannel);
|
||||||
} else if (discoveryAddress != null) {
|
} else if (discoveryAddress != null) {
|
||||||
Integer discoveryPort = overrideProperties.getDiscoveryPort() != null ? overrideProperties.getDiscoveryPort() : getDiscoveryPort();
|
Integer discoveryPort = overrideProperties.getDiscoveryPort() != null ? overrideProperties.getDiscoveryPort() : getDiscoveryPort();
|
||||||
if (discoveryPort == null) {
|
if (discoveryPort == null) {
|
||||||
|
@ -1814,7 +1817,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable {
|
||||||
String jgroupsLocatorClass = raProperties.getJgroupsChannelLocatorClass();
|
String jgroupsLocatorClass = raProperties.getJgroupsChannelLocatorClass();
|
||||||
if (jgroupsLocatorClass != null) {
|
if (jgroupsLocatorClass != null) {
|
||||||
String jgroupsChannelRefName = raProperties.getJgroupsChannelRefName();
|
String jgroupsChannelRefName = raProperties.getJgroupsChannelRefName();
|
||||||
endpointFactory = ActiveMQRaUtils.locateBroadcastEndpointFactory(jgroupsLocatorClass, jgroupsChannelRefName);
|
JChannel jchannel = ActiveMQRaUtils.locateJGroupsChannel(jgroupsLocatorClass, jgroupsChannelRefName);
|
||||||
|
endpointFactory = new ChannelBroadcastEndpointFactory(jchannel, jgroupsChannel);
|
||||||
}
|
}
|
||||||
if (endpointFactory == null) {
|
if (endpointFactory == null) {
|
||||||
throw new IllegalArgumentException("must provide either TransportType or DiscoveryGroupAddress and DiscoveryGroupPort for ResourceAdapter Connection Factory");
|
throw new IllegalArgumentException("must provide either TransportType or DiscoveryGroupAddress and DiscoveryGroupPort for ResourceAdapter Connection Factory");
|
||||||
|
|
Loading…
Reference in New Issue