geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r946727 - in /geronimo/server/trunk/plugins/openejb: geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ geronimo-openejb/src/test/java/org/apache/geronimo/openejb/ openejb/src/main/plan/
Date Thu, 20 May 2010 17:57:57 GMT
Author: djencks
Date: Thu May 20 17:57:57 2010
New Revision: 946727

URL: http://svn.apache.org/viewvc?rev=946727&view=rev
Log:
GERONIMO-5025 try to integrate openejb's context additions to our java: namespace federation

Added:
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/DeepBindableContext.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/test/java/org/apache/geronimo/openejb/DeepBindableContextTest.java
    geronimo/server/trunk/plugins/openejb/openejb/src/main/plan/plan.xml

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/DeepBindableContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/DeepBindableContext.java?rev=946727&r1=946726&r2=946727&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/DeepBindableContext.java
(original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/DeepBindableContext.java
Thu May 20 17:57:57 2010
@@ -25,6 +25,7 @@ import org.apache.geronimo.gbean.annotat
 import org.apache.openejb.SystemException;
 import org.apache.openejb.core.JndiFactory;
 import org.apache.xbean.naming.context.ContextAccess;
+import org.apache.xbean.naming.context.ContextFlyweight;
 import org.apache.xbean.naming.context.WritableContext;
 import org.apache.xbean.naming.global.GlobalContextManager;
 
@@ -42,6 +43,7 @@ import java.util.Hashtable;
 import java.util.Map;
 
 /**
+ * Not currently used as a gbean so the annotations could be removed.
  * @version $Rev$ $Date$
  */
 @GBean
@@ -63,39 +65,8 @@ public class DeepBindableContext extends
         removeDeepBinding(name, true, false);
     }
 
-    public JndiFactory newJndiFactory() throws NamingException {
-        return new XBeanJndiFactory();
-    }
-
-    class XBeanJndiFactory implements JndiFactory {
-        private final Context rootContext;
-
-        XBeanJndiFactory() throws NamingException {
-            rootContext = new ContextWrapper(DeepBindableContext.this);
-        }
-
-        public Context createComponentContext(Map<String, Object> bindings) throws
SystemException {
-            boolean hasEnv = false;
-            for (String name : bindings.keySet()) {
-                if (name.startsWith("java:comp/env")) {
-                    hasEnv = true;
-                    break;
-                }
-            }
-            if (!hasEnv) bindings.put("java:comp/env/dummy", "dummy");
-
-            WritableContext context = null;
-            try {
-                context = new WritableContext("", bindings);
-            } catch (NamingException e) {
-                throw new IllegalStateException(e);
-            }
-            return context;
-        }
-
-        public Context createRootContext() {
-            return rootContext;
-        }
+    ContextWrapper newContextWrapper() throws NamingException {
+        return new ContextWrapper(this);
     }
 
     class ContextWrapper implements Context {

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java?rev=946727&r1=946726&r2=946727&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java
(original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java
Thu May 20 17:57:57 2010
@@ -49,6 +49,8 @@ import org.apache.openejb.InterfaceType;
 import org.apache.openejb.core.CoreDeploymentInfo;
 import org.apache.openejb.core.ivm.EjbObjectProxyHandler;
 import org.apache.openejb.core.transaction.TransactionType;
+import org.apache.xbean.naming.context.ContextFederation;
+import org.apache.xbean.naming.context.ImmutableFederatedContext;
 
 public class EjbDeployment implements EJB, EjbDeploymentIdAccessor {
     private final String objectName;
@@ -292,19 +294,20 @@ public class EjbDeployment implements EJ
     }
 
     protected EjbDeployment initialize(CoreDeploymentInfo deploymentInfo) {
-//        try {
+        try {
 //            javaCompSubContext = (Context) deploymentInfo.getJndiEnc().lookup("java:comp");
 //            if (componentContext != null) {
 //                javaCompSubContext.bind("geronimo", componentContext);
 //            }
-        deploymentInfo.set(EjbDeployment.class, this);
+            ((ImmutableFederatedContext) componentContext).federateContext(deploymentInfo.getJndiEnc());
+            deploymentInfo.set(EjbDeployment.class, this);
 
-        this.deploymentInfo.set(deploymentInfo);
+            this.deploymentInfo.set(deploymentInfo);
 
-        return this;
-//        } catch (NamingException e) {
-//            throw new IllegalStateException("Unable to complete EjbDeployment initialization",
e);
-//        }
+            return this;
+        } catch (NamingException e) {
+            throw new IllegalStateException("Unable to complete EjbDeployment initialization",
e);
+        }
     }
 
     protected void destroy() {

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java?rev=946727&r1=946726&r2=946727&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java
(original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/OpenEjbSystemGBean.java
Thu May 20 17:57:57 2010
@@ -97,13 +97,13 @@ public class OpenEjbSystemGBean implemen
     private Properties properties; 
     
     public OpenEjbSystemGBean(TransactionManager transactionManager) throws Exception {
-        this(transactionManager, null, null, new DeepBindableContext("java:openejb", false,
true, true, false), null, OpenEjbSystemGBean.class.getClassLoader(), new Properties());
+        this(transactionManager, null, null, null, OpenEjbSystemGBean.class.getClassLoader(),
new Properties());
     }
 
     public OpenEjbSystemGBean(@ParamReference(name = "TransactionManager", namingType = NameFactory.JTA_RESOURCE)
TransactionManager transactionManager,
                               @ParamReference(name = "ResourceAdapterWrappers", namingType
= NameFactory.JCA_RESOURCE_ADAPTER) Collection<ResourceAdapterWrapper> resourceAdapters,
                               @ParamReference(name = "PersistenceUnitGBeans", namingType
= NameFactory.PERSISTENCE_UNIT) Collection<PersistenceUnitGBean> persistenceUnitGBeans,
-                              @ParamReference(name = "OpenEjbContext")DeepBindableContext
openejbContext,
+//                              @ParamReference(name = "OpenEjbContext")DeepBindableContext
openejbContext,
                               @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
                               @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader
classLoader,
                               @ParamAttribute(name = "properties") Properties properties)
throws Exception {
@@ -126,7 +126,7 @@ public class OpenEjbSystemGBean implemen
 //        System.setProperty("openejb.naming", "xbean");
         boolean offline = true;
         configurationFactory = new ConfigurationFactory(offline);
-        assembler = new Assembler(openejbContext.newJndiFactory());
+        assembler = new Assembler(new XBeanJndiFactory());
 
         // install application server
         ApplicationServer applicationServer = new ServerFederation();

Added: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java?rev=946727&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java
(added)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java
Thu May 20 17:57:57 2010
@@ -0,0 +1,72 @@
+/*
+ * 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
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.geronimo.openejb;
+
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import org.apache.openejb.SystemException;
+import org.apache.openejb.core.JndiFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class XBeanJndiFactory implements JndiFactory {
+    private final Context rootContext;
+
+    XBeanJndiFactory() throws NamingException {
+        DeepBindableContext context = new DeepBindableContext("openejb", false, true, true,
false);
+        rootContext = context.newContextWrapper();
+    }
+
+    @Override
+    public Context createComponentContext(Map<String, Object> bindings) throws SystemException
{
+        try {
+            DeepBindableContext context = new DeepBindableContext("", false, true, true,
false);
+            return context.newContextWrapper();
+        } catch (NamingException e) {
+            throw new IllegalStateException(e);
+        }
+//            boolean hasEnv = false;
+//            for (String name : bindings.keySet()) {
+//                if (name.startsWith("java:comp/env")) {
+//                    hasEnv = true;
+//                    break;
+//                }
+//            }
+//            if (!hasEnv) bindings.put("java:comp/env/dummy", "dummy");
+//
+//            WritableContext context = null;
+//            try {
+//                context = new WritableContext("", bindings);
+//            } catch (NamingException e) {
+//                throw new IllegalStateException(e);
+//            }
+//            return context;
+    }
+
+    @Override
+    public Context createRootContext() {
+        return rootContext;
+    }
+}
+

Propchange: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/XBeanJndiFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/test/java/org/apache/geronimo/openejb/DeepBindableContextTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/test/java/org/apache/geronimo/openejb/DeepBindableContextTest.java?rev=946727&r1=946726&r2=946727&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/test/java/org/apache/geronimo/openejb/DeepBindableContextTest.java
(original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/test/java/org/apache/geronimo/openejb/DeepBindableContextTest.java
Thu May 20 17:57:57 2010
@@ -39,7 +39,7 @@ public class DeepBindableContextTest ext
         DeepBindableContext context = new DeepBindableContext("openejb", false, true, false,
false);
         globalContext.bind("openejb", context);
 
-        Context contextWrapper = context.newJndiFactory().createRootContext();
+        Context contextWrapper = context.newContextWrapper();
         testBindUnbind(context, contextWrapper, "openejb/foo/bar", "");
         testBindUnbind(context, contextWrapper, "java:openejb/foo/bar", "java:");
 

Modified: geronimo/server/trunk/plugins/openejb/openejb/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/openejb/src/main/plan/plan.xml?rev=946727&r1=946726&r2=946727&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/openejb/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/openejb/openejb/src/main/plan/plan.xml Thu May 20 17:57:57
2010
@@ -27,23 +27,12 @@
         </attribute>
     </gbean>
 
-    <gbean name="OpenEjbContext" class="org.apache.geronimo.openejb.DeepBindableContext">
-        <attribute name="nameInNamespace">openejb</attribute>
-        <attribute name="cacheReferences">false</attribute>
-        <attribute name="supportReferenceable">true</attribute>
-        <attribute name="checkDereferenceDifferent">true</attribute>
-        <attribute name="assumeDereferenceBound">false</attribute>
-    </gbean>
-
     <gbean name="OpenEjbSystem" class="org.apache.geronimo.openejb.OpenEjbSystemGBean">
         <reference name="TransactionManager">
             <name>TransactionManager</name>
         </reference>
         <reference name="ResourceAdapterWrappers"/>
         <reference name="PersistenceUnitGBeans"/>
-        <reference name="OpenEjbContext">
-            <name>OpenEjbContext</name>
-        </reference>
     </gbean>
 
     <gbean name="ExtendedEntityManagerRegistry" class="org.apache.geronimo.openejb.EntityManagerRegistryImpl">



Mime
View raw message