Skip to content

Commit

Permalink
remove direct dependency on javax.rmi from core
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Jun 22, 2022
1 parent 8f124cc commit bc8b2c6
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 240 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/

package org.eclipse.persistence.sessions.remote.rmi.iiop;

import org.eclipse.persistence.exceptions.RemoteCommandManagerException;
import org.eclipse.persistence.internal.sessions.coordination.RemoteConnection;
import org.eclipse.persistence.internal.sessions.coordination.rmi.RMIRemoteCommandConnection;
import org.eclipse.persistence.internal.sessions.coordination.rmi.RMIRemoteCommandConnectionImpl;
import org.eclipse.persistence.internal.sessions.coordination.rmi.RMIRemoteConnection;
import org.eclipse.persistence.sessions.coordination.RemoteCommandManager;
import org.eclipse.persistence.sessions.coordination.rmi.RMITransportManager;

import javax.naming.Context;
import java.io.IOException;
import java.net.InetAddress;
import javax.rmi.PortableRemoteObject;

/**
* <p>
* <b>Purpose</b>: Provide an RMI-IIOP transport implementation for RCM.
* </p><p>
* <b>Description</b>: This class manages the RMI remote connections to other
* RCM service instances and posts the local RMI connection to this service instance
* in a name service so that other RCM service instances can connect to it.
* </p>
*/
public class RMIIIOPTransportManager extends RMITransportManager {

public RMIIIOPTransportManager(RemoteCommandManager rcm) {
super(rcm);
}

/**
* INTERNAL:
* Look the specified remote object up in JNDI and return a Connection to it.
*/
protected RemoteConnection createConnectionFromJNDI(String remoteObjectIdentifier, String hostURL) {
Object[] args = { remoteObjectIdentifier, hostURL };
rcm.logDebug("looking_up_remote_conn_in_jndi", args);
try {
Context context = getRemoteHostContext(hostURL);
return new RMIRemoteConnection((RMIRemoteCommandConnection) PortableRemoteObject.narrow(
context.lookup(remoteObjectIdentifier), RMIRemoteCommandConnection.class));
} catch (Exception e) {
try {
rcm.handleException(RemoteCommandManagerException.errorLookingUpRemoteConnection(remoteObjectIdentifier, hostURL, e));
} catch (Exception ex2) {
// Must catch this exception and log a debug message
rcm.logDebug("unable_to_look_up_remote_conn_in_jndi", args);
}
}
return null;
}

/**
* INTERNAL:
* Put the local command connection of this transport in JNDI and return it
*/
protected void createLocalConnectionInJNDI() {
try {
// Register the remote connection in JNDI naming service
RMIRemoteCommandConnection remoteConnectionObject = new RMIRemoteCommandConnectionImpl(rcm);
Object[] args = { rcm.getServiceId().getId() };
rcm.logDebug("register_local_connection_in_jndi", args);
getLocalHostContext().rebind(rcm.getServiceId().getId(), remoteConnectionObject);
localConnection = new RMIRemoteConnection(remoteConnectionObject);
} catch (Exception exception) {
rcm.handleException(RemoteCommandManagerException.errorBindingConnection(rcm.getServiceId().toString(), exception));
}
}

/**
* INTERNAL:
* Return the default local URL for JNDI lookups
*/
public String getDefaultLocalUrl() {
try {
// Look up the local host name and paste it in a default URL
String localHost = InetAddress.getLocalHost().getHostName();
return DEFAULT_IIOP_URL_PROTOCOL + "::" + localHost + ":" + DEFAULT_IIOP_URL_PORT;
} catch (IOException exception) {
throw RemoteCommandManagerException.errorGettingHostName(exception);
}
}

}
28 changes: 1 addition & 27 deletions foundation/org.eclipse.persistence.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.glassfish.corba</groupId>
<artifactId>glassfish-corba-omgapi</artifactId>
<optional>true</optional>
</dependency>
<!--Test dependencies-->
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -190,15 +185,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<compilerArgs>
<arg>--add-reads</arg>
<arg>org.eclipse.persistence.core=ALL-UNNAMED</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<configuration>
Expand Down Expand Up @@ -297,13 +283,8 @@
</Export-Package>
<Import-Package>
org.eclipse.persistence.internal.libraries.asm*;version="${version;==;${@}}",
javax.rmi;version=!;resolution:=optional,
javax.rmi.CORBA;version=!;resolution:=optional,
org.omg.CORBA;version=!;resolution:=optional,
org.omg.CORBA.portable;version=!;resolution:=optional,
org.omg.CORBA_2_3.portable;version=!;resolution:=optional,
org.eclipse.persistence.eis.adapters.xmlfile;resolution:=optional,
org.eclipse.persistence.internal.sessions.coordination.rmi.iiop;resolution:=optional,
org.eclipse.persistence.sessions.coordination.rmi.iiop;resolution:=optional,
org.eclipse.persistence.sessions.coordination.corba.sun;resolution:=optional,
com.sun.xml.bind;version=!;resolution:=optional,
org.glassfish.jaxb.runtime;version=!;resolution:=optional,
Expand All @@ -315,13 +296,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalOptions>--add-reads org.eclipse.persistence.core=ALL-UNNAMED</additionalOptions>
</configuration>
</plugin>
<!--Pack test classes due dependency to other modules (Corba...)-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
requires static jakarta.interceptor;
requires static jakarta.messaging;
requires static jakarta.resource;
// requires glassfish.corba.omgapi;

exports org.eclipse.persistence;
exports org.eclipse.persistence.annotations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public boolean usesBinding(AbstractSession session) {
* <p>
* Defaults behavior to the databasePlatform if this call does not have a preference; if
* {@link org.eclipse.persistence.internal.databaseaccess.DatasourceCall#usesBinding} is not set
* <p>
*
* @see org.eclipse.persistence.internal.databaseaccess.DatabasePlatform#shouldBindAllParameters()
*/
public boolean usesBinding(DatabasePlatform databasePlatform) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -949,7 +949,9 @@ protected void buildTransportManager(TransportManagerConfig tmConfig, RemoteComm
* INTERNAL:
*/
protected void buildRMITransportManagerConfig(RMITransportManagerConfig tmConfig, RemoteCommandManager rcm) {
RMITransportManager tm = new RMITransportManager(rcm);
RMITransportManager tm = (tmConfig instanceof RMIIIOPTransportManagerConfig)
? (RMITransportManager) TransportManager.newTransportManager("org.eclipse.persistence.sessions.remote.rmi.iiop.RMIIIOPTransportManager", rcm)
: new RMITransportManager(rcm);

// Set the transport manager. This will initialize the DiscoveryManager
// This needs to be done before we process the DiscoveryConfig.
Expand All @@ -971,8 +973,6 @@ protected void buildRMITransportManagerConfig(RMITransportManagerConfig tmConfig
processRMIRegistryNamingServiceConfig(tmConfig.getRMIRegistryNamingServiceConfig(), tm);
}

tm.setIsRMIOverIIOP(tmConfig instanceof RMIIIOPTransportManagerConfig);

// Send mode - Can only be Asynchronous (true) or Synchronous (false), validated by the schema
// XML Schema default is Asynchronous
rcm.setShouldPropagateAsynchronously(tmConfig.getSendMode().equals("Asynchronous"));
Expand Down Expand Up @@ -1321,7 +1321,7 @@ protected void processLogConfig(LogConfig logConfig, SessionLog log) {
* Builds a Sun CORBA transport manager with the given remote command manager
*/
protected void buildSunCORBATransportManagerConfig(SunCORBATransportManagerConfig tmConfig, RemoteCommandManager rcm) {
TransportManager tm = TransportManager.newSunCORBATransportManager(rcm);
TransportManager tm = TransportManager.newTransportManager("org.eclipse.persistence.sessions.coordination.corba.sun.SunCORBATransportManager", rcm);

// Set the transport manager. This will initialize the DiscoveryManager
rcm.setTransportManager(tm);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -504,15 +504,15 @@ public void setConfig(String config) {
* @param rcm cache coordination manager
* @return new instance of RMI transport manager implementation
*/
public static TransportManager newSunCORBATransportManager(final RemoteCommandManager rcm) {
public static TransportManager newTransportManager(final String transportManagerClassName, final RemoteCommandManager rcm) {
try {
return (TransportManager) PrivilegedAccessHelper.invokeConstructor(
PrivilegedAccessHelper.getConstructorFor(
Class.forName("org.eclipse.persistence.sessions.coordination.corba.sun.SunCORBATransportManager"),
Class.forName(transportManagerClassName),
new Class<?>[] { RemoteCommandManager.class }, false),
new Object[] { rcm });
} catch (ReflectiveOperationException e) {
throw RemoteCommandManagerException.errorInitCorba("org.eclipse.persistence.sessions.coordination.corba.sun.SunCORBATransportManager", e);
throw RemoteCommandManagerException.errorInitCorba(transportManagerClassName, e);
}
}

Expand Down

0 comments on commit bc8b2c6

Please sign in to comment.