You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2017/05/01 19:31:43 UTC
tomee git commit: extracting corba rmi types in an utility class for
now
Repository: tomee
Updated Branches:
refs/heads/master 4cf62c6b9 -> 49b1d1469
extracting corba rmi types in an utility class for now
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/49b1d146
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/49b1d146
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/49b1d146
Branch: refs/heads/master
Commit: 49b1d14698838c45c8b67f02b8dd23a1d0e485e8
Parents: 4cf62c6
Author: rmannibucau <rm...@apache.org>
Authored: Mon May 1 21:31:37 2017 +0200
Committer: rmannibucau <rm...@apache.org>
Committed: Mon May 1 21:31:37 2017 +0200
----------------------------------------------------------------------
.../org/apache/openejb/config/RemoteServer.java | 3 +-
.../org/apache/openejb/client/EJBRequest.java | 64 +------------------
.../org/apache/openejb/client/corba/Corbas.java | 67 ++++++++++++++++++++
3 files changed, 72 insertions(+), 62 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/49b1d146/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
index 8fad3ff..a42ae71 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java
@@ -302,7 +302,8 @@ public class RemoteServer {
if (!addedArgs.containsKey("-Djava.io.tmpdir")) {
argsList.add("-Djava.io.tmpdir=" + temp.getAbsolutePath());
}
- if (!javaVersion.startsWith("1.9") && !addedArgs.containsKey("-Djava.endorsed.dirs")) {
+ if ((javaVersion.startsWith("1.7") || javaVersion.startsWith("1.8")) && // java 9 dropped endorsed folder
+ !addedArgs.containsKey("-Djava.endorsed.dirs") && endorsed.exists()) {
argsList.add("-Djava.endorsed.dirs=" + endorsed.getAbsolutePath());
}
if (!addedArgs.containsKey("-Dcatalina.base")) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/49b1d146/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java b/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
index 1d70b6b..b2ee800 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/EJBRequest.java
@@ -16,20 +16,14 @@
*/
package org.apache.openejb.client;
+import org.apache.openejb.client.corba.Corbas;
import org.apache.openejb.client.serializer.EJBDSerializer;
import org.apache.openejb.client.serializer.SerializationWrapper;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.rmi.CORBA.Stub;
-import javax.rmi.CORBA.Tie;
-import javax.rmi.PortableRemoteObject;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.rmi.Remote;
import java.util.Arrays;
public class EJBRequest implements ClusterableRequest {
@@ -556,22 +550,7 @@ public class EJBRequest implements ClusterableRequest {
throw new IOException("Unkown primitive type: " + clazz);
}
} else {
- if (obj instanceof PortableRemoteObject && obj instanceof Remote) {
- final Tie tie = javax.rmi.CORBA.Util.getTie((Remote) obj);
- if (tie == null) {
- throw new IOException("Unable to serialize PortableRemoteObject; object has not been exported: " + obj);
- }
- final Object orb = getORB();
- try {
- tie.getClass().getMethod("orb", Thread.currentThread().getContextClassLoader().loadClass("org.omg.CORBA.ORB"))
- .invoke(tie, orb);
- } catch (final ClassNotFoundException | IllegalAccessException | NoSuchMethodException e) {
- throw new IllegalStateException("No CORBA available", e);
- } catch (final InvocationTargetException e) {
- throw new IllegalStateException("No CORBA available", e.getCause());
- }
- obj = PortableRemoteObject.toStub((Remote) obj);
- }
+ obj = Corbas.toStub(obj);
out.write(OBJECT);
out.writeObject(clazz);
out.writeObject(obj);
@@ -583,31 +562,6 @@ public class EJBRequest implements ClusterableRequest {
static final Object[] noArgsO = new Object[0];
/**
- * Obtain an ORB instance for this request to activate remote
- * arguments and return results.
- *
- * @return An ORB instance.
- * @throws java.io.IOException On error
- */
- protected Object getORB() throws IOException {
- // first ORB request? Check our various sources
- if (orb == null) {
- try {
- final Context initialContext = new InitialContext();
- orb = initialContext.lookup("java:comp/ORB");
- } catch (Throwable e) {
- try {
- // any orb will do if we can't get a context one.
- orb = Thread.currentThread().getContextClassLoader().loadClass("org.omg.CORBA.ORB").getMethod("init").invoke(null);
- } catch (final Throwable ex) {
- throw new IOException("Unable to connect PortableRemoteObject stub to an ORB, no ORB bound to java:comp/ORB");
- }
- }
- }
- return orb;
- }
-
- /**
* Changes to this method must observe the optional {@link #metaData} version
*/
protected void readMethodParameters(final ObjectInput in) throws IOException, ClassNotFoundException {
@@ -671,19 +625,7 @@ public class EJBRequest implements ClusterableRequest {
case OBJECT:
clazz = (Class) in.readObject();
- obj = in.readObject();
- if (obj instanceof Stub) {
- final Stub stub = (Stub) obj;
- final Object orb = getORB();
- try {
- stub.getClass().getMethod("connect", Thread.currentThread().getContextClassLoader().loadClass("org.omg.CORBA.ORB"))
- .invoke(stub, orb);
- } catch (final ClassNotFoundException | IllegalAccessException | NoSuchMethodException e) {
- throw new IllegalStateException("No CORBA available", e);
- } catch (final InvocationTargetException e) {
- throw new IllegalStateException("No CORBA available", e.getCause());
- }
- }
+ obj = Corbas.connect(in.readObject());
break;
default:
throw new IOException("Unkown data type: " + type);
http://git-wip-us.apache.org/repos/asf/tomee/blob/49b1d146/server/openejb-client/src/main/java/org/apache/openejb/client/corba/Corbas.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/corba/Corbas.java b/server/openejb-client/src/main/java/org/apache/openejb/client/corba/Corbas.java
new file mode 100644
index 0000000..2d765e3
--- /dev/null
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/corba/Corbas.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.client.corba;
+
+import org.omg.CORBA.ORB;
+
+import javax.naming.InitialContext;
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Tie;
+import javax.rmi.PortableRemoteObject;
+import java.io.IOException;
+import java.rmi.Remote;
+
+public class Corbas {
+ private Corbas() {
+ // no-op
+ }
+
+ public static Object toStub(final Object obj) throws IOException {
+ if (obj instanceof PortableRemoteObject && obj instanceof Remote) {
+ final Tie tie = javax.rmi.CORBA.Util.getTie((Remote) obj);
+ if (tie == null) {
+ throw new IOException("Unable to serialize PortableRemoteObject; object has not been exported: " + obj);
+ }
+ final ORB orb = getORB();
+ tie.orb(orb);
+ return PortableRemoteObject.toStub((Remote) obj);
+ }
+ return obj;
+ }
+
+ private static ORB getORB() throws IOException { // note: we can cache it if needed but needs to be contextual
+ try {
+ return ORB.class.cast(new InitialContext().lookup("java:comp/ORB"));
+ } catch (final Throwable e) {
+ try {
+ // any orb will do if we can't get a context one.
+ return ORB.init();
+ } catch (final Throwable ex) {
+ throw new IOException("Unable to connect PortableRemoteObject stub to an ORB, no ORB bound to java:comp/ORB");
+ }
+ }
+ }
+
+ public static Object connect(final Object obj) throws IOException {
+ if (obj instanceof Stub) {
+ final Stub stub = (Stub) obj;
+ final ORB orb = getORB();
+ stub.connect(orb);
+ }
+ return obj;
+ }
+}