tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: avoid to make corba mandatory and avoid to fail if ClassHelper cant be overriden in cxf since we have the ClassUnwrapper now
Date Mon, 01 May 2017 18:04:46 GMT
Repository: tomee
Updated Branches:
  refs/heads/master c714f50af -> 4cf62c6b9


avoid to make corba mandatory and avoid to fail if ClassHelper cant be overriden in cxf since
we have the ClassUnwrapper now


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/4cf62c6b
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/4cf62c6b
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/4cf62c6b

Branch: refs/heads/master
Commit: 4cf62c6b9da37506197463013041fc8582a98716
Parents: c714f50
Author: rmannibucau <rmannibucau@apache.org>
Authored: Mon May 1 20:04:36 2017 +0200
Committer: rmannibucau <rmannibucau@apache.org>
Committed: Mon May 1 20:04:36 2017 +0200

----------------------------------------------------------------------
 .../assembler/classic/JndiEncBuilder.java       | 32 +++++-----
 .../org/apache/openejb/client/EJBRequest.java   | 62 ++++++++++++--------
 .../org/apache/openejb/client/JNDIContext.java  | 11 +++-
 .../apache/openejb/server/cxf/rs/CxfHacks.java  | 10 +++-
 4 files changed, 72 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/4cf62c6b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
index ac37574..53bcac8 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
@@ -23,6 +23,7 @@ import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.SystemException;
 import org.apache.openejb.core.CoreUserTransaction;
 import org.apache.openejb.core.JndiFactory;
+import org.apache.openejb.core.ParentClassLoaderFinder;
 import org.apache.openejb.core.TransactionSynchronizationRegistryWrapper;
 import org.apache.openejb.core.ivm.naming.ClassReference;
 import org.apache.openejb.core.ivm.naming.CrossClassLoaderJndiReference;
@@ -51,20 +52,7 @@ import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.InjectableBeanManager;
-import org.omg.CORBA.ORB;
 
-import java.io.Serializable;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TreeMap;
-import java.util.concurrent.Callable;
 import javax.annotation.ManagedBean;
 import javax.ejb.EJBContext;
 import javax.ejb.TimerService;
@@ -94,6 +82,18 @@ import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.Providers;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceContext;
+import java.io.Serializable;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+import java.util.concurrent.Callable;
 
 /**
  * TODO: This class is essentially an over glorified sym-linker.  The names we were linking
to are no longer guaranteed to be what we assume them to be.  We need to come up with a
@@ -554,7 +554,11 @@ public class JndiEncBuilder {
         // bind TransactionSynchronizationRegistry
         bindings.put("comp/TransactionSynchronizationRegistry", new TransactionSynchronizationRegistryWrapper());
 
-        bindings.put("comp/ORB", new SystemComponentReference(ORB.class));
+        try {
+            bindings.put("comp/ORB", new SystemComponentReference(ParentClassLoaderFinder.Helper.get().loadClass("org.omg.CORBA.ORB")));
+        } catch (final NoClassDefFoundError | ClassNotFoundException e) {
+            // no corba, who does recall what it is today anyway :D
+        }
         bindings.put("comp/HandleDelegate", new SystemComponentReference(HandleDelegate.class));
 
         // bind bean validation objects

http://git-wip-us.apache.org/repos/asf/tomee/blob/4cf62c6b/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 4bd698c..1d70b6b 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
@@ -5,9 +5,9 @@
  * 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
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <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.
@@ -18,7 +18,6 @@ package org.apache.openejb.client;
 
 import org.apache.openejb.client.serializer.EJBDSerializer;
 import org.apache.openejb.client.serializer.SerializationWrapper;
-import org.omg.CORBA.ORB;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -28,6 +27,7 @@ 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;
@@ -312,7 +312,7 @@ public class EJBRequest implements ClusterableRequest {
         private static final long serialVersionUID = -5364100745236348268L;
         private transient volatile String toString = null;
         private transient EJBMetaDataImpl ejb;
-        private transient ORB orb;
+        private transient Object orb;
         private transient Method methodInstance;
         private transient Class interfaceClass;
         private transient String methodName;
@@ -561,8 +561,15 @@ public class EJBRequest implements ClusterableRequest {
                         if (tie == null) {
                             throw new IOException("Unable to serialize PortableRemoteObject;
object has not been exported: " + obj);
                         }
-                        final ORB orb = getORB();
-                        tie.orb(orb);
+                        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);
                     }
                     out.write(OBJECT);
@@ -582,17 +589,17 @@ public class EJBRequest implements ClusterableRequest {
          * @return An ORB instance.
          * @throws java.io.IOException On error
          */
-        protected ORB getORB() throws IOException {
+        protected Object getORB() throws IOException {
             // first ORB request?  Check our various sources
             if (orb == null) {
                 try {
                     final Context initialContext = new InitialContext();
-                    orb = (ORB) initialContext.lookup("java:comp/ORB");
+                    orb = initialContext.lookup("java:comp/ORB");
                 } catch (Throwable e) {
                     try {
                         // any orb will do if we can't get a context one.
-                        orb = ORB.init();
-                    } catch (Throwable ex) {
+                        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");
                     }
                 }
@@ -667,8 +674,15 @@ public class EJBRequest implements ClusterableRequest {
                         obj = in.readObject();
                         if (obj instanceof Stub) {
                             final Stub stub = (Stub) obj;
-                            final ORB orb = getORB();
-                            stub.connect(orb);
+                            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());
+                            }
                         }
                         break;
                     default:
@@ -697,17 +711,17 @@ public class EJBRequest implements ClusterableRequest {
         public String toString() {
             if (null == toString) {
                 toString = "Body{" +
-                    "ejb=" + ejb +
-                    ", orb=" + orb +
-                    ", methodInstance=" + methodInstance +
-                    ", interfaceClass=" + interfaceClass +
-                    ", methodName='" + methodName + '\'' +
-                    ", methodParamTypes=" + (methodParamTypes == null ? null : Arrays.asList(methodParamTypes))
+
-                    ", methodParameters=" + (methodParameters == null ? null : Arrays.asList(methodParameters))
+
-                    ", primaryKey=" + primaryKey +
-                    ", requestId='" + requestId + '\'' +
-                    ", version=" + version +
-                    '}';
+                        "ejb=" + ejb +
+                        ", orb=" + orb +
+                        ", methodInstance=" + methodInstance +
+                        ", interfaceClass=" + interfaceClass +
+                        ", methodName='" + methodName + '\'' +
+                        ", methodParamTypes=" + (methodParamTypes == null ? null : Arrays.asList(methodParamTypes))
+
+                        ", methodParameters=" + (methodParameters == null ? null : Arrays.asList(methodParameters))
+
+                        ", primaryKey=" + primaryKey +
+                        ", requestId='" + requestId + '\'' +
+                        ", version=" + version +
+                        '}';
             }
 
             return toString;

http://git-wip-us.apache.org/repos/asf/tomee/blob/4cf62c6b/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
index 1124eb9..dddb478 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
@@ -18,7 +18,6 @@ package org.apache.openejb.client;
 
 import org.apache.openejb.client.event.RemoteInitialContextCreated;
 import org.apache.openejb.client.serializer.EJBDSerializer;
-import org.omg.CORBA.ORB;
 
 import javax.naming.AuthenticationException;
 import javax.naming.Binding;
@@ -592,8 +591,14 @@ public class JNDIContext implements InitialContextFactory, Context {
         }
     }
 
-    private ORB getDefaultOrb() {
-        return ORB.init();
+    private Object getDefaultOrb() {
+        try {
+            return Thread.currentThread().getContextClassLoader().loadClass("org.omg.CORBA.ORB").getMethod("init").invoke(null);
+        } 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());
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/tomee/blob/4cf62c6b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfHacks.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfHacks.java
b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfHacks.java
index 0780e84..054c402 100644
--- a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfHacks.java
+++ b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfHacks.java
@@ -18,7 +18,8 @@ package org.apache.openejb.server.cxf.rs;
 
 import org.apache.cxf.common.util.ClassHelper;
 import org.apache.openejb.loader.SystemInstance;
-import org.apache.openejb.server.cxf.transport.util.CxfUtil;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.reflection.Reflections;
 
 public final class CxfHacks {
@@ -26,7 +27,12 @@ public final class CxfHacks {
         if (!Boolean.parseBoolean(SystemInstance.get().getProperty("openejb.cxf.ClassHelper.patch",
"true"))) {
             return;
         }
-        Reflections.set(ClassHelper.class, null, "HELPER", new OpenEJBClassHelper());
+        try {
+            Reflections.set(ClassHelper.class, null, "HELPER", new OpenEJBClassHelper());
+        } catch (final Throwable throwable) {
+            // no more a big deal normally since CXF uses our ClassUnwrapper
+            Logger.getInstance(LogCategory.CXF, CxfHacks.class).info("Can't set OpenEJBClassHelper.");
+        }
     }
 
     private CxfHacks() {


Mime
View raw message