This is an automated email from the ASF dual-hosted git repository.
magicaltrout pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/oodt.git
The following commit(s) were added to refs/heads/master by this push:
new b975a47 [OODT-1009] Replace CORBA dependencies with reflection (#94)
b975a47 is described below
commit b975a475ff10c7113bff2b1e3ca7a2beeb8d3264
Author: Yasith Jayawardana <[email protected]>
AuthorDate: Fri Aug 16 04:39:48 2019 -0400
[OODT-1009] Replace CORBA dependencies with reflection (#94)
---
.../org/apache/oodt/commons/AvroExecServer.java | 27 +++++++++++++++-------
.../java/org/apache/oodt/commons/ExecServer.java | 26 ++++++++++++++-------
2 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/commons/src/main/java/org/apache/oodt/commons/AvroExecServer.java
b/commons/src/main/java/org/apache/oodt/commons/AvroExecServer.java
index c779acd..34be998 100644
--- a/commons/src/main/java/org/apache/oodt/commons/AvroExecServer.java
+++ b/commons/src/main/java/org/apache/oodt/commons/AvroExecServer.java
@@ -33,6 +33,7 @@ import java.io.IOException;
import java.io.ObjectOutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.rmi.server.RemoteObject;
@@ -229,9 +230,14 @@ public class AvroExecServer {
objOut.flush();
System.out.println();
} else {
- org.omg.PortableServer.Servant
servant=(org.omg.PortableServer.Servant)server.getServant();
- org.omg.CORBA.ORB orb = servant._orb();
-
System.out.println(orb.object_to_string(servant._this_object(orb)));
+ Class<?> servantClass =
Class.forName("org.omg.PortableServer.Servant");
+ Class<?> orbClass = Class.forName("org.omg.CORBA.ORB");
+ Class<?> corbaObjectClass =
Class.forName("org.omg.CORBA.Object");
+
+ Object servant = servantClass.cast(server.getServant());
+ Object orb =
orbClass.cast(servantClass.getDeclaredMethod("_orb").invoke(servant));
+ Object object =
corbaObjectClass.cast(servantClass.getDeclaredMethod("_this_object",
orbClass).invoke(servant, orb));
+
System.out.println(orbClass.getDeclaredMethod("object_to_string",
corbaObjectClass).invoke(orb, object));
}
System.out.flush();
}
@@ -332,13 +338,18 @@ public class AvroExecServer {
} catch (NamingException ignore) {}
// Kill the ORB. YEAH! KILL IT, KILL IT, KIIIIIIIIIIIIIIL
IIIIIIIIT!!!!!!!1
+ // Replace org.omg dependent code with reflection (to make it
compatible with Java 11 (LTS))
try {
- if (servant instanceof org.omg.PortableServer.Servant) {
- org.omg.PortableServer.Servant s =
(org.omg.PortableServer.Servant) servant;
- org.omg.CORBA.ORB orb = s._orb();
- orb.shutdown(false/*=>terminate without waiting for reqs to
complete*/);
+ Class<?> servantClass =
Class.forName("org.omg.PortableServer.Servant");
+ Class<?> orbClass = Class.forName("org.omg.CORBA.ORB");
+ if (servantClass.isInstance(servant)) {
+ Object s = servantClass.cast(servant);
+ Object orb =
orbClass.cast(servantClass.getDeclaredMethod("_orb").invoke(s));
+ orbClass.getDeclaredMethod("shutdown", boolean.class)
+ .invoke(orb, false/*=>terminate without waiting for
reqs to complete*/);
}
- } catch (Throwable ignore) {}
+ } catch (Exception ignore) {
+ }
}
/** Get my name.
diff --git a/commons/src/main/java/org/apache/oodt/commons/ExecServer.java
b/commons/src/main/java/org/apache/oodt/commons/ExecServer.java
index ef68d51..1a91320 100644
--- a/commons/src/main/java/org/apache/oodt/commons/ExecServer.java
+++ b/commons/src/main/java/org/apache/oodt/commons/ExecServer.java
@@ -37,6 +37,7 @@ import java.io.IOException;
import java.io.ObjectOutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.rmi.server.RemoteObject;
@@ -118,9 +119,14 @@ public class ExecServer {
objOut.flush();
System.out.println();
} else {
- org.omg.PortableServer.Servant
servant=(org.omg.PortableServer.Servant)server.getServant();
- org.omg.CORBA.ORB orb = servant._orb();
-
System.out.println(orb.object_to_string(servant._this_object(orb)));
+ Class<?> servantClass =
Class.forName("org.omg.PortableServer.Servant");
+ Class<?> orbClass = Class.forName("org.omg.CORBA.ORB");
+ Class<?> corbaObjectClass =
Class.forName("org.omg.CORBA.Object");
+
+ Object servant = servantClass.cast(server.getServant());
+ Object orb =
orbClass.cast(servantClass.getDeclaredMethod("_orb").invoke(servant));
+ Object object =
corbaObjectClass.cast(servantClass.getDeclaredMethod("_this_object",
orbClass).invoke(servant, orb));
+
System.out.println(orbClass.getDeclaredMethod("object_to_string",
corbaObjectClass).invoke(orb, object));
}
System.out.flush();
}
@@ -165,7 +171,7 @@ public class ExecServer {
System.err.println("Exception " +
ex.getClass().getName() + " initializing server \"" + name
+ "\" with class \"" + className + "\": " +
ex.getMessage());
ex.printStackTrace();
- }
+ }
System.exit(1);
}
@@ -372,11 +378,15 @@ public class ExecServer {
}
// Kill the ORB. YEAH! KILL IT, KILL IT, KIIIIIIIIIIIIIIL
IIIIIIIIT!!!!!!!1
+ // Replace org.omg dependent code with reflection (to make it
compatible with Java 11 (LTS))
try {
- if (servant instanceof org.omg.PortableServer.Servant) {
- org.omg.PortableServer.Servant s =
(org.omg.PortableServer.Servant) servant;
- org.omg.CORBA.ORB orb = s._orb();
- orb.shutdown(false/*=>terminate without waiting
for reqs to complete*/);
+ Class<?> servantClass =
Class.forName("org.omg.PortableServer.Servant");
+ Class<?> orbClass = Class.forName("org.omg.CORBA.ORB");
+ if (servantClass.isInstance(servant)) {
+ Object s = servantClass.cast(servant);
+ Object orb =
orbClass.cast(servantClass.getDeclaredMethod("_orb").invoke(s));
+ orbClass.getDeclaredMethod("shutdown",
boolean.class)
+ .invoke(orb, false/*=>terminate
without waiting for reqs to complete*/);
}
} catch (Exception ignore) {
}