use of org.eclipse.persistence.sessions.coordination.TransportManager in project eclipselink by eclipse-ee4j.
the class SessionsFactory method buildUserDefinedTransportManagerConfig.
/**
* INTERNAL:
*/
protected void buildUserDefinedTransportManagerConfig(UserDefinedTransportManagerConfig tmConfig, RemoteCommandManager rcm) {
TransportManager tm = null;
// Transport class
String transportManagerClassName = tmConfig.getTransportClass();
if (transportManagerClassName != null) {
try {
@SuppressWarnings({ "unchecked" }) Class<TransportManager> transportManagerClass = (Class<TransportManager>) m_classLoader.loadClass(transportManagerClassName);
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
tm = AccessController.doPrivileged(new PrivilegedNewInstanceFromClass<>(transportManagerClass));
} else {
tm = PrivilegedAccessHelper.newInstanceFromClass(transportManagerClass);
}
} catch (Exception exception) {
throw SessionLoaderException.failedToLoadTag("transport-class", transportManagerClassName, exception);
}
// Set the transport manager. This will initialize the DiscoveryManager
rcm.setTransportManager(tm);
// Process the common elements in TransportManagerConfig
processTransportManagerConfig(tmConfig, tm);
}
}
use of org.eclipse.persistence.sessions.coordination.TransportManager in project eclipselink by eclipse-ee4j.
the class JGroupsConfigurationTest method test.
@Override
protected void test() throws Throwable {
AbstractSession session = getAbstractSession();
RemoteCommandManager rcm = new RemoteCommandManager(session);
TransportManager transport = (TransportManager) Class.forName("org.eclipse.persistence.sessions.coordination.jgroups.JGroupsTransportManager").getConstructor().newInstance();
rcm.setTransportManager(transport);
transport.createLocalConnection();
RemoteConnection connection = transport.getConnectionToLocalHost();
try {
int multicastPort = getMulticastPort(connection);
Assert.assertEquals("Default multicast port different than expected", 45588, multicastPort);
} catch (Exception x) {
Assert.fail("Failed to retrieve multicast port: " + x.getMessage());
} finally {
connection.close();
}
rcm = new RemoteCommandManager(session);
transport = (TransportManager) Class.forName("org.eclipse.persistence.sessions.coordination.jgroups.JGroupsTransportManager").getConstructor().newInstance();
transport.setConfig("org/eclipse/persistence/testing/config/distributedservers/rcm/jgroups/jgroups-udp-config.xml");
rcm.setTransportManager(transport);
transport.createLocalConnection();
connection = transport.getConnectionToLocalHost();
try {
int multicastPort = getMulticastPort(connection);
Assert.assertEquals("Configured multicast port different than expected", 45678, multicastPort);
} catch (Exception x) {
Assert.fail("Failed to retrieve multicast port: " + x.getMessage());
} finally {
connection.close();
}
}
use of org.eclipse.persistence.sessions.coordination.TransportManager in project eclipselink by eclipse-ee4j.
the class JGroupsSetupHelper method createTransportManager.
@Override
protected void createTransportManager(RemoteCommandManager rcm) {
try {
TransportManager transport = (TransportManager) Class.forName("org.eclipse.persistence.sessions.coordination.jgroups.JGroupsTransportManager").getConstructor().newInstance();
rcm.setTransportManager(transport);
} catch (Exception exception) {
throw new RuntimeException(exception);
}
}
use of org.eclipse.persistence.sessions.coordination.TransportManager in project eclipselink by eclipse-ee4j.
the class RcmEncryptedPasswordTest method verify.
@Override
public void verify() {
TransportManager transportMgr = ((AbstractSession) loadedSession).getCommandManager().getTransportManager();
String encryptedPassword = transportMgr.getPassword();
if (!encryptedPassword.equals("do-not-encrypt-me")) {
throw new TestErrorException("Encrypted password [" + encryptedPassword + "] does not match.");
}
// test if encryption-class-name is processed
transportMgr.setPassword("encrypt-me");
CustomEncryption encryptionObject = new CustomEncryption();
if (!encryptionObject.decryptPassword(transportMgr.getPassword()).equals("encrypt-me")) {
throw new TestErrorException("Custom encryption class is not used.");
}
}
use of org.eclipse.persistence.sessions.coordination.TransportManager in project eclipselink by eclipse-ee4j.
the class RcmWithRmiAndJndiTest method verify.
@Override
public void verify() {
RemoteCommandManager rcm = (RemoteCommandManager) ((AbstractSession) loadedSession).getCommandManager();
TransportManager transportMgr = rcm.getTransportManager();
Vector errors = new Vector();
if (!rcm.getChannel().equals("new_channel")) {
errors.add("channel = " + rcm.getChannel());
}
if (!((AbstractSession) loadedSession).shouldPropagateChanges()) {
errors.add("cache sync is not enable");
}
if (rcm.getTransportManager().shouldRemoveConnectionOnError()) {
errors.add("remove connection on error");
}
if (rcm.shouldPropagateAsynchronously()) {
errors.add("send mode is asynchronous");
}
// test Discovery Manager settings
if (!rcm.getDiscoveryManager().getMulticastGroupAddress().equals("new_address")) {
errors.add("DM multicast address = " + rcm.getDiscoveryManager().getMulticastGroupAddress());
}
if (rcm.getDiscoveryManager().getMulticastPort() != 3333) {
errors.add("DM multicast port = " + rcm.getDiscoveryManager().getMulticastPort());
}
if (rcm.getDiscoveryManager().getAnnouncementDelay() != 1111) {
errors.add("DM announcement delay = " + rcm.getDiscoveryManager().getAnnouncementDelay());
}
// naming services
if (transportMgr.getNamingServiceType() != TransportManager.JNDI_NAMING_SERVICE) {
errors.add("Naming service type (not JNDI) = " + transportMgr.getNamingServiceType());
}
if (!rcm.getUrl().equals("new_jndi_url")) {
errors.add("Url = " + rcm.getUrl());
}
// transport manager
String userName = (String) transportMgr.getRemoteContextProperties().get(Context.SECURITY_PRINCIPAL);
if (userName == null || !userName.equals("new_user_name")) {
errors.add("user name = " + userName);
}
String password = (String) transportMgr.getRemoteContextProperties().get(Context.SECURITY_CREDENTIALS);
// decrypt password using default encryption
password = new SecurableObjectHolder().getSecurableObject().decryptPassword(password);
if (password == null || !password.equals("new_password")) {
errors.add("password = " + password);
}
String contextFactory = (String) transportMgr.getRemoteContextProperties().get(Context.INITIAL_CONTEXT_FACTORY);
if (contextFactory == null || !contextFactory.equals("new_initial_context_factory_name")) {
errors.add("initial context factory name = " + contextFactory);
}
// extra properties
String propertyValue1 = (String) transportMgr.getRemoteContextProperties().get("name1");
String propertyValue2 = (String) transportMgr.getRemoteContextProperties().get("name2");
if (propertyValue1 == null || !propertyValue1.equals("value1")) {
errors.add("extra property name = name1, value = " + propertyValue1);
}
if (propertyValue2 == null || !propertyValue2.equals("value2")) {
errors.add("extra property name = name2, value = " + propertyValue2);
}
if (!errors.isEmpty()) {
String errorString = "The following RCM elements's value do not match their expected values:";
for (Enumeration enumtr = errors.elements(); enumtr.hasMoreElements(); ) {
errorString += "\n " + enumtr.nextElement();
}
throw new TestErrorException(errorString);
}
}
Aggregations