geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r901935 [2/3] - in /geronimo/server/trunk: framework/configs/karaf-framework/src/main/filtered-resources/etc/ framework/configs/rmi-naming/src/main/plan/ framework/modules/geronimo-core/src/main/java/org/apache/geronimo/validator/ framework...
Date Fri, 22 Jan 2010 00:10:56 GMT
Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java Fri Jan 22 00:10:53 2010
@@ -65,6 +65,9 @@
 import org.apache.geronimo.gbean.annotation.ParamSpecial;
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.jndi.ApplicationJndi;
+import org.apache.geronimo.j2ee.jndi.JndiKey;
+import org.apache.geronimo.j2ee.jndi.JndiScope;
 import org.apache.geronimo.j2ee.management.impl.J2EEApplicationImpl;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
@@ -139,6 +142,7 @@
     private final Naming naming;
     private final Collection<? extends ArtifactResolver> artifactResolvers;
     private final BundleContext bundleContext;
+    private final AbstractNameQuery globalContextAbstractName;
 
     public static ThreadLocal<Boolean> createPlanMode = new ThreadLocal<Boolean>() {
         @Override
@@ -154,50 +158,11 @@
         }
     };
 
-//    static {
-//        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(EARConfigBuilder.class, NameFactory.CONFIG_BUILDER);
-//        infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
-//        infoBuilder.addAttribute("transactionManagerAbstractName", AbstractNameQuery.class, true);
-//        infoBuilder.addAttribute("connectionTrackerAbstractName", AbstractNameQuery.class, true);
-//        infoBuilder.addAttribute("corbaGBeanAbstractName", AbstractNameQuery.class, true);
-//        infoBuilder.addAttribute("serverName", AbstractNameQuery.class, true);
-//
-//        infoBuilder.addReference("Repositories", Repository.class, "Repository");
-//        infoBuilder.addReference("EJBConfigBuilder", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("WebConfigBuilder", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("ConnectorConfigBuilder", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("ActivationSpecInfoLocator", ActivationSpecInfoLocator.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("AppClientConfigBuilder", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("ServiceBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("PersistenceUnitBuilders", ModuleBuilderExtension.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("ArtifactResolvers", ArtifactResolver.class, "ArtifactResolver");
-//
-//        infoBuilder.addAttribute("kernel", Kernel.class, false);
-//
-//        infoBuilder.setConstructor(new String[]{
-//                "defaultEnvironment",
-//                "transactionManagerAbstractName",
-//                "connectionTrackerAbstractName",
-//                "corbaGBeanAbstractName",
-//                "serverName",
-//                "Repositories",
-//                "EJBConfigBuilder",
-//                "WebConfigBuilder",
-//                "ConnectorConfigBuilder",
-//                "ActivationSpecInfoLocator",
-//                "AppClientConfigBuilder",
-//                "ServiceBuilders",
-//                "PersistenceUnitBuilders",
-//                "ArtifactResolvers",
-//                "kernel"
-//        });
-//
-//    }
-
     public EARConfigBuilder(@ParamAttribute(name = "defaultEnvironment") Environment defaultEnvironment,
                             @ParamAttribute(name = "transactionManagerAbstractName") AbstractNameQuery transactionManagerAbstractName,
                             @ParamAttribute(name = "connectionTrackerAbstractName") AbstractNameQuery connectionTrackerAbstractName,
                             @ParamAttribute(name = "corbaGBeanAbstractName") AbstractNameQuery corbaGBeanAbstractName,
+                            @ParamAttribute(name = "globalContextAbstractName") AbstractNameQuery globalContextAbstractName,
                             @ParamAttribute(name = "serverName") AbstractNameQuery serverName,
                             @ParamReference(name = "Repositories", namingType = "Repository")Collection<? extends Repository> repositories,
                             @ParamReference(name = "EJBConfigBuilder", namingType = NameFactory.MODULE_BUILDER)Collection<ModuleBuilder> ejbConfigBuilder,
@@ -214,6 +179,7 @@
                 transactionManagerAbstractName,
                 connectionTrackerAbstractName,
                 corbaGBeanAbstractName,
+                globalContextAbstractName,
                 serverName,
                 ConfigurationUtil.getConfigurationManager(kernel),
                 repositories,
@@ -233,6 +199,7 @@
                             AbstractNameQuery connectionTrackerAbstractName,
                             AbstractNameQuery corbaGBeanAbstractName,
                             AbstractNameQuery serverName,
+                            AbstractNameQuery globalContextAbstractName,
                             Collection<? extends Repository> repositories,
                             ModuleBuilder ejbConfigBuilder,
                             ModuleBuilder webConfigBuilder,
@@ -247,6 +214,7 @@
                 transactionManagerAbstractName,
                 connectionTrackerAbstractName,
                 corbaGBeanAbstractName,
+                globalContextAbstractName,
                 serverName,
                 null,
                 repositories,
@@ -266,6 +234,7 @@
                              AbstractNameQuery transactionManagerAbstractName,
                              AbstractNameQuery connectionTrackerAbstractName,
                              AbstractNameQuery corbaGBeanAbstractName,
+                             AbstractNameQuery globalContextAbstractName,
                              AbstractNameQuery serverName,
                              ConfigurationManager configurationManager,
                              Collection<? extends Repository> repositories,
@@ -294,6 +263,7 @@
         this.transactionManagerObjectName = transactionManagerAbstractName;
         this.connectionTrackerObjectName = connectionTrackerAbstractName;
         this.corbaGBeanObjectName = corbaGBeanAbstractName;
+        this.globalContextAbstractName = globalContextAbstractName;
         this.serverName = serverName;
         this.naming = naming;
         this.artifactResolvers = artifactResolvers;
@@ -660,7 +630,7 @@
                 }
 
                 // Create the J2EEApplication managed object
-                GBeanData gbeanData = new GBeanData(earContext.getModuleName(), J2EEApplicationImpl.GBEAN_INFO);
+                GBeanData gbeanData = new GBeanData(earContext.getModuleName(), J2EEApplicationImpl.class);
                 try {
                     String originalSpecDD = applicationInfo.getOriginalSpecDD();
                     if (originalSpecDD == null) {
@@ -692,6 +662,8 @@
                 earContext.addGBean(gbeanData);
             }
 
+            AbstractName appJndiName = naming.createChildName(earContext.getModuleName(), "ApplicationJndi", "ApplicationJndi");
+            earContext.getGeneralData().put(EARContext.APPLICATION_JNDI_NAME_KEY, appJndiName);
             // each module can now add it's GBeans
             for (Module module : applicationInfo.getModules()) {
                 if (createPlanMode.get()) {
@@ -710,6 +682,12 @@
                 EARConfigBuilder.appInfo.set(applicationInfo);
                 throw new DeploymentException();
             }
+            Map<JndiKey, Map<String, Object>> contexts = NamingBuilder.JNDI_KEY.get(earContext.getGeneralData());
+            GBeanData appContexts = new GBeanData(appJndiName, ApplicationJndi.class);
+            appContexts.setAttribute("globalContextSegment", contexts.get(JndiScope.global));
+            appContexts.setAttribute("applicationContextMap", contexts.get(JndiScope.application));
+            appContexts.setReferencePattern("GlobalContext", globalContextAbstractName);
+            earContext.addGBean(appContexts);
 
             // it's the caller's responsibility to close the context...
             return earContext;

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java Fri Jan 22 00:10:53 2010
@@ -34,6 +34,7 @@
  * @version $Rev:386276 $ $Date$
  */
 public class EARContext extends DeploymentContext {
+    public static final String APPLICATION_JNDI_NAME_KEY = "AppplicationJndiName";
 
     private final AbstractNameQuery serverName;
     private final AbstractNameQuery transactionManagerObjectName;

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilder.java Fri Jan 22 00:10:53 2010
@@ -24,6 +24,7 @@
 import org.apache.geronimo.deployment.AbstractNamespaceBuilder;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.j2ee.annotation.Holder;
+import org.apache.geronimo.j2ee.jndi.JndiKey;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.xmlbeans.XmlObject;
 
@@ -37,12 +38,12 @@
     XmlObject[] NO_REFS = new XmlObject[] {};
     String ENV = "env/";
 
-    Key<Map<String, Object>> JNDI_KEY = new Key<Map<String, Object>>() {
+    Key<Map<JndiKey, Map<String, Object>>> JNDI_KEY = new Key<Map<JndiKey, Map<String, Object>>>() {
 
-        public Map<String, Object> get(Map context) {
-            Map<String, Object> result = (Map<String, Object>) context.get(this);
+        public Map<JndiKey, Map<String, Object>> get(Map context) {
+            Map<JndiKey, Map<String, Object>> result = (Map<JndiKey, Map<String, Object>>) context.get(this);
             if (result == null) {
-                result = new HashMap<String, Object>();
+                result = new HashMap<JndiKey, Map<String, Object>>();
                 context.put(this, result);
             }
             return result;

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java Fri Jan 22 00:10:53 2010
@@ -96,6 +96,8 @@
 
     protected static final AbstractName nonTransactionalTimerObjectName = naming.createChildName(rootConfig, "NonTransactionalThreaPooledTimer", "ThreadPooledTimer");
 
+    protected static final AbstractName globalContextAbstractName = naming.createChildName(rootConfig, "GlobalContext", "GlobalContext");
+
     protected static final AbstractName serverName = naming.createChildName(rootConfig, "J2EEServer", "Server");
 
     protected static final AbstractName earName = naming.createRootName(new Artifact("org.apache.geronimo.test.test-ear", "ear", "", "ear"), "test", NameFactory.J2EE_APPLICATION);
@@ -119,6 +121,8 @@
 
     protected final AbstractNameQuery connectionTrackerAbstractNameQuery = new AbstractNameQuery(connectionTrackerObjectName, null);
 
+    protected final AbstractNameQuery globalContextAbstractNameQuery = new AbstractNameQuery(globalContextAbstractName, null);
+
     protected final AbstractNameQuery corbaGBeanAbstractNameQuery = new AbstractNameQuery(serverName, null);
 
     private ListableRepository repository;
@@ -145,6 +149,7 @@
                     connectionTrackerAbstractNameQuery,
                     corbaGBeanAbstractNameQuery,
                     null,
+                    globalContextAbstractNameQuery,
                     Collections.singleton(repository),
                     ejbConfigBuilder,
                     webConfigBuilder,
@@ -176,6 +181,7 @@
                 connectionTrackerAbstractNameQuery,
                 corbaGBeanAbstractNameQuery,
                 null,
+                globalContextAbstractNameQuery,
                 null,
                 ejbConfigBuilder,
                 webConfigBuilder,
@@ -211,6 +217,7 @@
                 connectionTrackerAbstractNameQuery,
                 corbaGBeanAbstractNameQuery,
                 null,
+                globalContextAbstractNameQuery,
                 null,
                 ejbConfigBuilder,
                 webConfigBuilder,
@@ -246,6 +253,7 @@
                 connectionTrackerAbstractNameQuery,
                 corbaGBeanAbstractNameQuery,
                 null,
+                globalContextAbstractNameQuery,
                 null,
                 ejbConfigBuilder,
                 webConfigBuilder,
@@ -281,6 +289,7 @@
                 connectionTrackerAbstractNameQuery,
                 corbaGBeanAbstractNameQuery,
                 null,
+                globalContextAbstractNameQuery,
                 null,
                 ejbConfigBuilder,
                 webConfigBuilder,
@@ -316,6 +325,7 @@
                 connectionTrackerAbstractNameQuery,
                 corbaGBeanAbstractNameQuery,
                 null,
+                globalContextAbstractNameQuery,
                 null,
                 null,
                 webConfigBuilder,
@@ -352,6 +362,7 @@
                 connectionTrackerAbstractNameQuery,
                 corbaGBeanAbstractNameQuery,
                 null,
+                globalContextAbstractNameQuery,
                 null,
                 ejbConfigBuilder,
                 null,
@@ -387,6 +398,7 @@
                 connectionTrackerAbstractNameQuery,
                 corbaGBeanAbstractNameQuery,
                 null,
+                globalContextAbstractNameQuery,
                 null,
                 ejbConfigBuilder,
                 webConfigBuilder,

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/pom.xml?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/pom.xml (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/pom.xml Fri Jan 22 00:10:53 2010
@@ -46,6 +46,12 @@
             <artifactId>geronimo-management</artifactId>
             <version>${version}</version>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.framework</groupId>
+            <artifactId>geronimo-naming</artifactId>
+            <version>${version}</version>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.framework</groupId>
@@ -65,7 +71,11 @@
                     <instructions>
                         <!--packages containing "impl" or "internal" are excluded by default -->
                         <Export-Package>
-                            org.apache.geronimo.j2ee,org.apache.geronimo.j2ee.annotation,org.apache.geronimo.j2ee.j2eeobjectnames,org.apache.geronimo.j2ee.management.impl
+                            org.apache.geronimo.j2ee,
+                            org.apache.geronimo.j2ee.annotation,
+                            org.apache.geronimo.j2ee.j2eeobjectnames,
+                            org.apache.geronimo.j2ee.jndi,
+                            org.apache.geronimo.j2ee.management.impl
                         </Export-Package>
                         <!--<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>-->
                     </instructions>

Added: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java?rev=901935&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java Fri Jan 22 00:10:53 2010
@@ -0,0 +1,84 @@
+/*
+ * 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.j2ee.jndi;
+
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.gjndi.FederatedContext;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@GBean
+public class ApplicationJndi implements GBeanLifecycle {
+
+    private final Context applicationContext;
+    private final Context globalAdditions;
+    private final FederatedContext globalContext;
+
+    public ApplicationJndi(@ParamAttribute(name = "globalContextSegment") Map<String, Object> globalContextSegment,
+                           @ParamAttribute(name = "applicationContextMap") Map<String, Object> applicationContext,
+                           @ParamReference(name = "GlobalContext", namingType = "Context") FederatedContext globalContext,
+                           @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
+                           @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader
+                           ) throws NamingException {
+        this.globalAdditions = EnterpriseNamingContext.livenReferences(globalContextSegment, null, kernel, classLoader, JndiScope.global.name() + "/");
+        this.globalContext = globalContext;
+        this.globalContext.federateContext(this.globalAdditions);
+        this.applicationContext = EnterpriseNamingContext.livenReferences(applicationContext, null, kernel, classLoader, JndiScope.application.name() + "/");
+    }
+
+    public Context getApplicationContext() {
+        return applicationContext;
+    }
+
+    public FederatedContext getGlobalContext() {
+        return globalContext;
+    }
+
+    @Override
+    public void doStart() throws Exception {
+    }
+
+    @Override
+    public void doStop() throws Exception {
+        globalContext.unfederateContext(globalAdditions);
+    }
+
+    @Override
+    public void doFail() {
+        try {
+            doStop();
+        } catch (Exception e) {
+            //ignore
+        }
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/ApplicationJndi.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Added: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiKey.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiKey.java?rev=901935&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiKey.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiKey.java Fri Jan 22 00:10:53 2010
@@ -0,0 +1,28 @@
+/*
+ * 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.j2ee.jndi;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface JndiKey {
+    String toString();
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiKey.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Added: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiScope.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiScope.java?rev=901935&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiScope.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiScope.java Fri Jan 22 00:10:53 2010
@@ -0,0 +1,28 @@
+/*
+ * 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.j2ee.jndi;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public enum JndiScope implements JndiKey {
+    global, application, module, comp
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiScope.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/jndi/JndiScope.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/management/impl/J2EEApplicationImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/management/impl/J2EEApplicationImpl.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/management/impl/J2EEApplicationImpl.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/management/impl/J2EEApplicationImpl.java Fri Jan 22 00:10:53 2010
@@ -16,12 +16,7 @@
  */
 package org.apache.geronimo.j2ee.management.impl;
 
-import java.util.Hashtable;
-import java.util.Collection;
-import java.util.ArrayList;
-import javax.management.ObjectName;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.annotation.*;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.ObjectNameUtil;
 import org.apache.geronimo.management.AppClientModule;
@@ -33,27 +28,34 @@
 import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
 import org.apache.geronimo.management.geronimo.WebModule;
 
+import javax.management.ObjectName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+
 /**
  * @version $Rev$ $Date$
  */
+
+@GBean(j2eeType = NameFactory.J2EE_APPLICATION)
 public class J2EEApplicationImpl implements J2EEApplication {
     private final String objectName;
     private final String deploymentDescriptor;
     private final J2EEServer server;
-    private final Collection resources;
-    private final Collection appClientModules;
-    private final Collection ejbModules;
-    private final Collection resourceAdapterModules;
-    private final Collection webModules;
-
-    public J2EEApplicationImpl(String objectName,
-            String deploymentDescriptor,
-            J2EEServer server,
-            Collection resources,
-            Collection appClientModules,
-            Collection ejbModules,
-            Collection resourceAdapterModules,
-            Collection webModules) {
+    private final Collection<J2EEResource> resources;
+    private final Collection<AppClientModule> appClientModules;
+    private final Collection<EJBModule> ejbModules;
+    private final Collection<ResourceAdapterModule> resourceAdapterModules;
+    private final Collection<WebModule> webModules;
+
+    public J2EEApplicationImpl(@ParamSpecial(type = SpecialAttributeType.objectName)String objectName,
+            @ParamAttribute(name="deploymentDescriptor")String deploymentDescriptor,
+            @ParamReference(name="Server", namingType = NameFactory.J2EE_SERVER)J2EEServer server,
+            @ParamReference(name="Resources", namingType = NameFactory.J2EE_RESOURCE)Collection<J2EEResource> resources,
+            @ParamReference(name="AppClientModules", namingType = NameFactory.APP_CLIENT_MODULE)Collection<AppClientModule> appClientModules,
+            @ParamReference(name="EJBModules", namingType = NameFactory.EJB_MODULE)Collection<EJBModule> ejbModules,
+            @ParamReference(name="ResourceAdapterModules", namingType = NameFactory.RESOURCE_ADAPTER_MODULE)Collection<ResourceAdapterModule> resourceAdapterModules,
+            @ParamReference(name="WebModules", namingType = NameFactory.WEB_MODULE)Collection<WebModule> webModules) {
 
         this.objectName = objectName;
         ObjectName myObjectName = ObjectNameUtil.getObjectName(this.objectName);
@@ -163,33 +165,4 @@
         return server.getObjectName();
     }
 
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(J2EEApplicationImpl.class, NameFactory.J2EE_APPLICATION);
-        infoFactory.addAttribute("deploymentDescriptor", String.class, true);
-        infoFactory.addReference("Server", J2EEServer.class);
-        infoFactory.addReference("Resources", J2EEResource.class);
-        infoFactory.addReference("AppClientModules", AppClientModule.class);
-        infoFactory.addReference("EJBModules", EJBModule.class);
-        infoFactory.addReference("ResourceAdapterModules", ResourceAdapterModule.class);
-        infoFactory.addReference("WebModules", WebModule.class);
-
-        infoFactory.setConstructor(new String[]{
-                "objectName",
-                "deploymentDescriptor",
-                "Server",
-                "Resources",
-                "AppClientModules",
-                "EJBModules",
-                "ResourceAdapterModules",
-                "WebModules",
-        });
-
-        GBEAN_INFO = infoFactory.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java Fri Jan 22 00:10:53 2010
@@ -37,6 +37,8 @@
 import org.apache.geronimo.j2ee.annotation.Injection;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.geronimo.j2ee.jndi.JndiKey;
+import org.apache.geronimo.j2ee.jndi.JndiScope;
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Dependency;
@@ -126,13 +128,43 @@
     public int getPriority() {
         return NORMAL_PRIORITY;
     }
+
+    protected void put(String key, Object value, Map<JndiKey, Map<String, Object>> contexts) {
+        JndiKey jndiKey;
+        if (key.startsWith("java:")) {
+            int pos = key.indexOf("/", 5);
+            String type = key.substring(5, pos);
+            jndiKey = JndiScope.valueOf(type);
+            key = key.substring(5);
+        } else {
+            key = "comp/env/" + key;
+            jndiKey = JndiScope.comp;
+        }
+        Map<String, Object> scope = contexts.get(jndiKey);
+        if (scope == null) {
+            scope = new HashMap<String, Object>();
+            contexts.put(jndiKey, scope);
+        }
+        scope.put(key, value);
+    }
     
-    protected Object lookupJndiContextMap(Map sharedContext, String name) {
-        Map<String, Object> jndiContext = getJndiContextMap(sharedContext);
-        return jndiContext.get(name);
+    protected Object lookupJndiContextMap(Map sharedContext, String key) {
+        JndiKey jndiKey;
+        if (key.startsWith("java:")) {
+            int pos = key.indexOf("/", 5);
+            String type = key.substring(5, pos);
+            jndiKey = JndiScope.valueOf(type);
+            key = key.substring(5);
+        } else {
+            key = "comp/env/" + key;
+            jndiKey = JndiScope.comp;
+        }
+        Map<String, Object> scope = getJndiContextMap(sharedContext).get(jndiKey);
+        if (scope == null) return null;
+        return scope.get(key);
     }
     
-    protected Map<String, Object> getJndiContextMap(Map sharedContext) {
+    protected Map<JndiKey, Map<String, Object>> getJndiContextMap(Map sharedContext) {
         return NamingBuilder.JNDI_KEY.get(sharedContext);
     }
 

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java Fri Jan 22 00:10:53 2010
@@ -137,7 +137,7 @@
                 // see Java EE 5 spec, section EE.5.4.1.3
                 if (value != null) {
                     addInjections(name, envEntry.getInjectionTargetArray(), componentContext);
-                    getJndiContextMap(componentContext).put(ENV + name, value);
+                    put(name, value, getJndiContextMap(componentContext));
                 }
             } catch (NumberFormatException e) {
                 throw new DeploymentException("Invalid env-entry value for name: " + name, e);

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/GBeanRefBuilder.java Fri Jan 22 00:10:53 2010
@@ -89,7 +89,7 @@
 
             String refName = gbeanRef.getRefName();
 
-            NamingBuilder.JNDI_KEY.get(componentContext).put(ENV + refName, new GBeanReference(module.getConfigId(), queries, gBeanType));
+            put(refName, new GBeanReference(module.getConfigId(), queries, gBeanType), NamingBuilder.JNDI_KEY.get(componentContext));
 
         }
     }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-naming-builder/src/test/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilderTest.java Fri Jan 22 00:10:53 2010
@@ -29,6 +29,7 @@
 import javax.naming.NamingException;
 
 import junit.framework.TestCase;
+import org.apache.geronimo.j2ee.jndi.JndiScope;
 import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.xmlbeans.XmlObject;
@@ -39,7 +40,7 @@
  */
 public class EnvironmentEntryBuilderTest extends TestCase {
     private Map componentContext = new HashMap();
-    private NamingBuilder environmentEntryBuilder = new EnvironmentEntryBuilder(new String[] {AbstractNamingBuilder.JEE_NAMESPACE});
+    private NamingBuilder environmentEntryBuilder = new EnvironmentEntryBuilder(new String[]{AbstractNamingBuilder.JEE_NAMESPACE});
 
     private static final String TEST = "<tmp xmlns=\"http://java.sun.com/xml/ns/javaee\">" +
             "<env-entry>" +
@@ -164,23 +165,23 @@
             cursor.dispose();
         }
         environmentEntryBuilder.buildNaming(doc, null, null, componentContext);
-        Context context = EnterpriseNamingContext.createEnterpriseNamingContext(NamingBuilder.JNDI_KEY.get(componentContext));
+        Context context = EnterpriseNamingContext.livenReferences(NamingBuilder.JNDI_KEY.get(componentContext).get(JndiScope.comp), null, null, null, "comp/");
         Set actual = new HashSet();
-        for (NamingEnumeration e = context.listBindings("env"); e.hasMore();) {
+        for (NamingEnumeration e = context.listBindings("comp/env"); e.hasMore();) {
             NameClassPair pair = (NameClassPair) e.next();
             actual.add(pair.getName());
         }
         Set expected = new HashSet(Arrays.asList(new String[]{"string", "char", "byte", "short", "int", "long", "float", "double", "boolean"}));
         assertEquals(expected, actual);
-        assertEquals(stringVal, context.lookup("env/string"));
-        assertEquals(charVal, context.lookup("env/char"));
-        assertEquals(byteVal, context.lookup("env/byte"));
-        assertEquals(shortVal, context.lookup("env/short"));
-        assertEquals(intVal, context.lookup("env/int"));
-        assertEquals(longVal, context.lookup("env/long"));
-        assertEquals(floatVal, context.lookup("env/float"));
-        assertEquals(doubleVal, context.lookup("env/double"));
-        assertEquals(booleanVal, context.lookup("env/boolean"));
+        assertEquals(stringVal, context.lookup("comp/env/string"));
+        assertEquals(charVal, context.lookup("comp/env/char"));
+        assertEquals(byteVal, context.lookup("comp/env/byte"));
+        assertEquals(shortVal, context.lookup("comp/env/short"));
+        assertEquals(intVal, context.lookup("comp/env/int"));
+        assertEquals(longVal, context.lookup("comp/env/long"));
+        assertEquals(floatVal, context.lookup("comp/env/float"));
+        assertEquals(doubleVal, context.lookup("comp/env/double"));
+        assertEquals(booleanVal, context.lookup("comp/env/boolean"));
     }
 
     public void testEnvEntriesOverride() throws Exception {
@@ -212,34 +213,29 @@
             cursor.dispose();
         }
         environmentEntryBuilder.buildNaming(doc, plan, null, componentContext);
-        Context context = EnterpriseNamingContext.createEnterpriseNamingContext(NamingBuilder.JNDI_KEY.get(componentContext));
+        Context context = EnterpriseNamingContext.livenReferences(NamingBuilder.JNDI_KEY.get(componentContext).get(JndiScope.comp), null, null, null, "comp/");
         Set actual = new HashSet();
-        for (NamingEnumeration e = context.listBindings("env"); e.hasMore();) {
+        for (NamingEnumeration e = context.listBindings("comp/env"); e.hasMore();) {
             NameClassPair pair = (NameClassPair) e.next();
             actual.add(pair.getName());
         }
         Set expected = new HashSet(Arrays.asList(new String[]{"string", "char", "byte", "short", "int", "long", "float", "double", "boolean"}));
         assertEquals(expected, actual);
-        assertEquals(stringVal, context.lookup("env/string"));
-        assertEquals(charVal, context.lookup("env/char"));
-        assertEquals(byteVal, context.lookup("env/byte"));
-        assertEquals(shortVal, context.lookup("env/short"));
-        assertEquals(intVal, context.lookup("env/int"));
-        assertEquals(longVal, context.lookup("env/long"));
-        assertEquals(floatVal, context.lookup("env/float"));
-        assertEquals(doubleVal, context.lookup("env/double"));
-        assertEquals(booleanVal, context.lookup("env/boolean"));
+        assertEquals(stringVal, context.lookup("comp/env/string"));
+        assertEquals(charVal, context.lookup("comp/env/char"));
+        assertEquals(byteVal, context.lookup("comp/env/byte"));
+        assertEquals(shortVal, context.lookup("comp/env/short"));
+        assertEquals(intVal, context.lookup("comp/env/int"));
+        assertEquals(longVal, context.lookup("comp/env/long"));
+        assertEquals(floatVal, context.lookup("comp/env/float"));
+        assertEquals(doubleVal, context.lookup("comp/env/double"));
+        assertEquals(booleanVal, context.lookup("comp/env/boolean"));
     }
 
-    public void xtestEmptyEnvironment() throws NamingException {
-        Context context = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext);
-        try {
-            Context env = (Context) context.lookup("env");
-            assertNotNull(env);
-        } catch (NamingException e) {
-            e.printStackTrace();
-            fail();
-        }
+    public void testEmptyEnvironment() throws NamingException {
+        Context context = EnterpriseNamingContext.livenReferences(NamingBuilder.JNDI_KEY.get(componentContext).get(JndiScope.comp), null, null, null, "comp/");
+        Context env = (Context) context.lookup("comp/env");
+        assertNotNull(env);
     }
 
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java Fri Jan 22 00:10:53 2010
@@ -17,33 +17,6 @@
 
 package org.apache.geronimo.web25.deployment;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-
-import javax.security.auth.message.module.ServerAuthModule;
-import javax.xml.bind.JAXBException;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.Location;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.components.jaspi.model.AuthModuleType;
 import org.apache.geronimo.components.jaspi.model.ConfigProviderType;
@@ -70,6 +43,8 @@
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.deployment.annotation.SecurityAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.jndi.JndiKey;
+import org.apache.geronimo.j2ee.jndi.JndiScope;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.Naming;
@@ -111,6 +86,32 @@
 import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
+import javax.security.auth.message.module.ServerAuthModule;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+
 /**
  * @version $Rev$ $Date$
  */
@@ -707,6 +708,10 @@
         Map<NamingBuilder.Key, Object> buildingContext = new HashMap<NamingBuilder.Key, Object>();
         buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, moduleContext.getModuleName());
 
+        //get partial jndi context from earContext.
+        Map<JndiKey, Map<String, Object>> jndiContext = new HashMap<JndiKey, Map<String, Object>>(NamingBuilder.JNDI_KEY.get(earContext.getGeneralData()));
+        buildingContext.put(NamingBuilder.JNDI_KEY, jndiContext);
+
         if (!webApp.getMetadataComplete()) {
             // Create a classfinder and populate it for the naming builder(s). The absence of a
             // classFinder in the module will convey whether metadata-complete is set (or not)
@@ -718,11 +723,19 @@
         //This means that you cannot use the default environment of the web builder to add configs that will be searched.
         getNamingBuilders().buildNaming(webApp, vendorPlan, webModule, buildingContext);
 
-        Map compContext = NamingBuilder.JNDI_KEY.get(buildingContext);
+        //Combine contexts.  Note this may not work right for jaxws which has a comp/env/WebServiceContext binding
+        Map<String, Object> compContext = new HashMap<String, Object>();
+        if (jndiContext.get(JndiScope.comp) != null) {
+            compContext.putAll(jndiContext.get(JndiScope.comp));
+        }
+        if (jndiContext.get(JndiScope.module) != null) {
+            compContext.putAll(jndiContext.get(JndiScope.module));
+        }
+        
         Holder holder = NamingBuilder.INJECTION_KEY.get(buildingContext);
 
         webModule.getSharedContext().put(WebModule.WEB_APP_DATA, webModuleData);
-        webModule.getSharedContext().put(NamingBuilder.JNDI_KEY, compContext);
+        webModule.getSharedContext().put(NamingBuilder.JNDI_KEY, jndiContext);
         webModule.getSharedContext().put(NamingBuilder.INJECTION_KEY, holder);
         if (moduleContext.getServerName() != null) {
             webModuleData.setReferencePattern("J2EEServer", moduleContext.getServerName());
@@ -741,6 +754,7 @@
         }
 
         webModuleData.setAttribute("componentContext", compContext);
+        webModuleData.setReferencePattern("ApplicationJndi", (AbstractName)earContext.getGeneralData().get(EARContext.APPLICATION_JNDI_NAME_KEY));
         webModuleData.setReferencePattern("TransactionManager", moduleContext.getTransactionManagerName());
         webModuleData.setReferencePattern("TrackedConnectionAssociator", moduleContext.getConnectionTrackerName());
         webModuleData.setAttribute("modulePath", webModule.isStandAlone() || webModule.getEarContext() != webModule.getRootEarContext()? null: webModule.getTargetPath());

Modified: geronimo/server/trunk/plugins/j2ee/j2ee-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/j2ee-deployer/src/main/plan/plan.xml?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/j2ee-deployer/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/j2ee/j2ee-deployer/src/main/plan/plan.xml Fri Jan 22 00:10:53 2010
@@ -23,6 +23,7 @@
     <gbean name="EARBuilder" class="org.apache.geronimo.j2ee.deployment.EARConfigBuilder">
         <attribute name="transactionManagerAbstractName">?name=TransactionManager</attribute>
         <attribute name="connectionTrackerAbstractName">?name=ConnectionTracker</attribute>
+        <attribute name="globalContextAbstractName">?name=JavaGlobalContext</attribute>
         <attribute name="corbaGBeanAbstractName">?name=Server</attribute>
         <attribute name="serverName">?j2eeType=J2EEServer#org.apache.geronimo.management.geronimo.J2EEServer</attribute>
         <reference name="Repositories">

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceRefBuilder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceRefBuilder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceRefBuilder.java Fri Jan 22 00:10:53 2010
@@ -166,7 +166,7 @@
         Object ref = createService(serviceRef, gerServiceRef, module, bundle,
                                    serviceInterfaceClass, serviceQName,
                                    wsdlURI, serviceReferenceType, portComponentRefMap);
-        getJndiContextMap(componentContext).put(ENV + name, ref);
+        put(name, ref, getJndiContextMap(componentContext));
     }
 
     public abstract Object createService(ServiceRefType serviceRef, GerServiceRefType gerServiceRef,

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java Fri Jan 22 00:10:53 2010
@@ -54,7 +54,7 @@
         boolean useSimpleFinder =
             Boolean.getBoolean("org.apache.geronimo.jaxws.builder.useSimpleFinder");
 
-        WebServiceFinder webServiceFinder = null;
+        WebServiceFinder webServiceFinder;
 
         if (useSimpleFinder) {
             webServiceFinder = new SimpleWARWebServiceFinder();
@@ -87,13 +87,13 @@
         if (isEJB) {
             File jarFile = new File(moduleFile.getName());
             try {
-                urlList.add(jarFile.toURL());
+                urlList.add(jarFile.toURI().toURL());
             } catch (MalformedURLException e) {
                 // this should not happen
                 throw new DeploymentException(e);
             }
         } else {
-            File baseDir = null;
+            File baseDir;
 
             if (moduleFile instanceof UnpackedJarFile) {
                 // war directory is being deployed (--inPlace)
@@ -135,7 +135,7 @@
                     // ensure it is first
                     File classesDir = new File(baseDir, "WEB-INF/classes/");
                     try {
-                        urlList.add(0, classesDir.toURL());
+                        urlList.add(0, classesDir.toURI().toURL());
                     } catch (MalformedURLException e) {
                         // this should not happen, ignore
                     }
@@ -143,7 +143,7 @@
                         && name.endsWith(".jar")) {
                     File jarFile = new File(baseDir, name);
                     try {
-                        urlList.add(jarFile.toURL());
+                        urlList.add(jarFile.toURI().toURL());
                     } catch (MalformedURLException e) {
                         // this should not happen, ignore
                     }
@@ -151,8 +151,8 @@
             }
         }
 
-        URL[] urls = urlList.toArray(new URL[] {});
-        TemporaryClassLoader tempClassLoader = null;
+        URL[] urls = urlList.toArray(new URL[urlList.size()]);
+        TemporaryClassLoader tempClassLoader;
         try {
             tempClassLoader = new TemporaryClassLoader(urls, parentClassLoader);
             List<Class> classes = new ArrayList<Class>();

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java Fri Jan 22 00:10:53 2010
@@ -18,14 +18,7 @@
 package org.apache.geronimo.jetty8;
 
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.EventListener;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
@@ -44,6 +37,7 @@
 import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.j2ee.annotation.LifecycleMethod;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.jndi.ApplicationJndi;
 import org.apache.geronimo.j2ee.management.impl.InvalidObjectNameException;
 import org.apache.geronimo.jetty8.handler.GeronimoWebAppContext;
 import org.apache.geronimo.jetty8.handler.IntegrationContext;
@@ -105,7 +99,7 @@
     public WebAppContextWrapper(@ParamSpecial(type = SpecialAttributeType.objectName) String objectName,
                                 @ParamAttribute(name = "contextPath") String contextPath,
                                 @ParamAttribute(name = "deploymentDescriptor") String originalSpecDD,
-                                @ParamAttribute(name = "modulePath")String modulePath,
+                                @ParamAttribute(name = "modulePath") String modulePath,
                                 @ParamAttribute(name = "componentContext") Map<String, Object> componentContext,
                                 @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader,
                                 @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle,
@@ -142,6 +136,7 @@
 
                                 @ParamReference(name = "J2EEServer") J2EEServer server,
                                 @ParamReference(name = "J2EEApplication") J2EEApplication application,
+                                @ParamReference(name = "ApplicationJndi") ApplicationJndi applicationJndi,
                                 @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel) throws Exception {
 
         assert componentContext != null;
@@ -185,7 +180,18 @@
 
         //wrap the web app context with the jndi handler
         GeronimoUserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);
-        this.componentContext = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext, userTransaction, kernel, classLoader);
+        Set<Context> contexts = new LinkedHashSet<Context>(3);
+        Context localContext = EnterpriseNamingContext.livenReferences(componentContext, userTransaction, kernel, classLoader, "comp/");
+        contexts.add(localContext);
+        if (applicationJndi != null) {
+            if (applicationJndi.getApplicationContext() != null) {
+                contexts.add(applicationJndi.getApplicationContext());
+            }
+            if (applicationJndi.getGlobalContext() != null) {
+                contexts.add(applicationJndi.getGlobalContext());
+            }
+        }
+        this.componentContext = EnterpriseNamingContext.createEnterpriseNamingContext(contexts);
         integrationContext = new IntegrationContext(this.componentContext, unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator, userTransaction, bundle);
         webAppContext = new GeronimoWebAppContext(securityHandler, sessionHandler, servletHandler, null, integrationContext, classLoader, modulePath);
         webAppContext.setContextPath(contextPath);

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java Fri Jan 22 00:10:53 2010
@@ -173,7 +173,7 @@
                 null,
                 null,
                 null,
-                null);
+                null, null);
         app.doStart();
         return app;
     }

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java Fri Jan 22 00:10:53 2010
@@ -38,6 +38,8 @@
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedEjbJar;
+import org.apache.geronimo.j2ee.jndi.JndiKey;
+import org.apache.geronimo.j2ee.jndi.JndiScope;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.naming.deployment.AbstractNamingBuilder;
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
@@ -171,10 +173,9 @@
         }
     }
 
-
     public void addEjbModuleDependency(AbstractName ejbModuleName) {
         for (GBeanData gbean : gbeans.values()) {
-            gbean.addDependency(ejbModuleName);
+            gbean.setReferencePattern("EjbModule", ejbModuleName);
         }
     }
 
@@ -359,25 +360,26 @@
             ejbModule.setClassFinder(createEjbJarClassFinder(ejbModule));
         }
 
+        Map<JndiKey, Map<String, Object>> moduleJndiContext = NamingBuilder.JNDI_KEY.get(ejbModule.getSharedContext());
         EnterpriseBeansType enterpriseBeans = ejbJarType.getEnterpriseBeans();
         if (enterpriseBeans != null) {
             for (SessionBeanType xmlbeansEjb : enterpriseBeans.getSessionArray()) {
                 String ejbName = xmlbeansEjb.getEjbName().getStringValue().trim();
                 GBeanData gbean = getEjbGBean(ejbName);
                 ResourceRefType[] resourceRefs = xmlbeansEjb.getResourceRefArray();
-                addEnc(gbean, xmlbeansEjb, resourceRefs);
+                addEnc(gbean, xmlbeansEjb, resourceRefs, moduleJndiContext);
             }
             for (MessageDrivenBeanType xmlbeansEjb : enterpriseBeans.getMessageDrivenArray()) {
                 String ejbName = xmlbeansEjb.getEjbName().getStringValue().trim();
                 GBeanData gbean = getEjbGBean(ejbName);
                 ResourceRefType[] resourceRefs = xmlbeansEjb.getResourceRefArray();
-                addEnc(gbean, xmlbeansEjb, resourceRefs);
+                addEnc(gbean, xmlbeansEjb, resourceRefs, moduleJndiContext);
             }
             for (EntityBeanType xmlbeansEjb : enterpriseBeans.getEntityArray()) {
                 String ejbName = xmlbeansEjb.getEjbName().getStringValue().trim();
                 GBeanData gbean = getEjbGBean(ejbName);
                 ResourceRefType[] resourceRefs = xmlbeansEjb.getResourceRefArray();
-                addEnc(gbean, xmlbeansEjb, resourceRefs);
+                addEnc(gbean, xmlbeansEjb, resourceRefs, moduleJndiContext);
             }
 
         }
@@ -388,7 +390,7 @@
         }
     }
 
-    private void addEnc(GBeanData gbean, XmlObject xmlbeansEjb, ResourceRefType[] resourceRefs) throws DeploymentException {
+    private void addEnc(GBeanData gbean, XmlObject xmlbeansEjb, ResourceRefType[] resourceRefs, Map<JndiKey, Map<String, Object>> moduleJndiContext) throws DeploymentException {
         OpenejbGeronimoEjbJarType geronimoOpenejb = ejbModule.getVendorDD();
 
         //
@@ -397,6 +399,8 @@
 
         // Geronimo uses a map to pass data to the naming build and for the results data
         Map<Object, Object> buildingContext = new HashMap<Object, Object>();
+        Map<JndiKey, Map<String, Object>> jndiContext = new HashMap<JndiKey, Map<String, Object>>();
+        buildingContext.put(NamingBuilder.JNDI_KEY, jndiContext);
         buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, gbean.getAbstractName());
         ((AnnotatedEjbJar) ejbModule.getAnnotatedApp()).setBean(xmlbeansEjb);
 
@@ -404,7 +408,7 @@
                 geronimoOpenejb,
                 ejbModule, buildingContext);
 
-        Map compContext = NamingBuilder.JNDI_KEY.get(buildingContext);
+        Map<String, Object> compContext = jndiContext.get(JndiScope.comp);
         gbean.setAttribute("componentContextMap", compContext);
 
         //

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java Fri Jan 22 00:10:53 2010
@@ -54,6 +54,8 @@
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedEjbJar;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.jndi.JndiKey;
+import org.apache.geronimo.j2ee.jndi.JndiScope;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.classloader.TemporaryClassLoader;
@@ -743,7 +745,11 @@
         EjbDeploymentBuilder ejbDeploymentBuilder = ejbModule.getEjbBuilder();
 
         // add enc
+        Map<JndiKey, Map<String, Object>> jndiContext = NamingBuilder.JNDI_KEY.get(earContext.getGeneralData());
+        ejbModule.getSharedContext().put(NamingBuilder.JNDI_KEY, jndiContext);
         ejbDeploymentBuilder.buildEnc();
+        Map<String, Object> moduleContext = jndiContext.remove(JndiScope.module);
+
 
         Set<GBeanData> gBeanDatas = earContext.getConfiguration().findGBeanDatas(Collections.singleton(new AbstractNameQuery(PersistenceUnitGBean.class.getName())));
         LinkResolver<String> linkResolver = new UniqueDefaultLinkResolver<String>();
@@ -767,7 +773,7 @@
             }
         }
         // Add JSR77 EJBModule GBean
-        GBeanData ejbModuleGBeanData = new GBeanData(ejbModule.getModuleName(), EjbModuleImplGBean.GBEAN_INFO);
+        GBeanData ejbModuleGBeanData = new GBeanData(ejbModule.getModuleName(), EjbModuleImplGBean.class);
         try {
             ejbModuleGBeanData.setReferencePattern("J2EEServer", earContext.getServerName());
             if (!ejbModule.isStandAlone()) {
@@ -784,6 +790,9 @@
             ejbModuleGBeanData.setReferencePattern("OpenEjbSystem", new AbstractNameQuery(null, Collections.EMPTY_MAP, OpenEjbSystem.class.getName()));
             ejbModuleGBeanData.setAttribute("ejbJarInfo", ejbModule.getEjbJarInfo());
             ejbModuleGBeanData.setAttribute("modulePath", ejbModule.getTargetPath());
+            ejbModuleGBeanData.setAttribute("moduleContext", moduleContext);
+            AbstractName applicationJndiName = (AbstractName)earContext.getGeneralData().get(EARContext.APPLICATION_JNDI_NAME_KEY); 
+            ejbModuleGBeanData.setReferencePattern("ApplicationJndi", applicationJndiName);
             earContext.addGBean(ejbModuleGBeanData);
         } catch (Exception e) {
             throw new DeploymentException("Unable to initialize EJBModule GBean " + ejbModuleGBeanData.getAbstractName(), e);

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java Fri Jan 22 00:10:53 2010
@@ -166,16 +166,15 @@
             Object value = entry.getValue();
 
             // work with names prefixed with java:comp/
-            if (name.startsWith("java:comp/")) {
-                name = name.substring("java:comp/".length());
-            }
-
-            // if this is a ref it will be prefixed with env/
-            if (name.startsWith("env/")) {
+            if (name.startsWith("env/") ||
+                    name.startsWith("java:global/") ||
+                    name.startsWith("java:application/") ||
+                    name.startsWith("java:module/") ||
+                    name.startsWith("java:comp/")) {
                 if (uri != null) {
                     value = createClientRef(value);
                 }
-                getJndiContextMap(componentContext).put(name, value);
+                put(name, value, getJndiContextMap(componentContext));
             }
         }
     }
@@ -222,7 +221,7 @@
             EjbRef ref = new EjbRef();
             // ejb-ref-name
             ref.setEjbRefName(refName);
-            
+
             jndiConsumer.getEjbRef().add(ref);
 
             // ejb-ref-type
@@ -296,7 +295,7 @@
             EjbLocalRef ref = new EjbLocalRef();
             // ejb-ref-name
             ref.setEjbRefName(refName);
-            
+
             jndiConsumer.getEjbLocalRef().add(ref);
 
             // ejb-ref-type
@@ -387,6 +386,7 @@
 
     // XMLBean uses lame arrays that can be null, so we need an asList that handles nulls
     // Beware Arrays.asList(), it returns an ArrayList lookalike, that is not fully mutable...
+
     public static <E> List<E> asList(E[] array) {
         if (array == null) {
             return new ArrayList<E>();

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/deployment/ClusteredStatefulDeployment.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/deployment/ClusteredStatefulDeployment.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/deployment/ClusteredStatefulDeployment.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/deployment/ClusteredStatefulDeployment.java Fri Jan 22 00:10:53 2010
@@ -22,19 +22,14 @@
 import java.util.Map;
 import java.util.Set;
 
-import javax.naming.Context;
-import javax.security.auth.login.LoginException;
-
 import org.apache.geronimo.clustering.SessionManager;
 import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
-import org.apache.geronimo.openejb.EjbDeployment;
 import org.apache.geronimo.openejb.EjbDeploymentGBean;
+import org.apache.geronimo.openejb.EjbModuleImpl;
 import org.apache.geronimo.openejb.OpenEjbSystem;
 import org.apache.geronimo.openejb.cluster.infra.SessionManagerTracker;
 import org.apache.geronimo.security.jacc.RunAsSource;
@@ -42,121 +37,67 @@
 import org.apache.openejb.Container;
 
 /**
- *
  * @version $Rev:$ $Date:$
  */
-public class ClusteredStatefulDeployment extends EjbDeployment implements GBeanLifecycle {
+public class ClusteredStatefulDeployment extends EjbDeploymentGBean {
 
     private final SessionManager sessionManager;
 
-    public ClusteredStatefulDeployment() throws LoginException {
-        sessionManager = null;
-    }
+//    public ClusteredStatefulDeployment() throws LoginException {
+//        sessionManager = null;
+//    }
 
     public ClusteredStatefulDeployment(String objectName,
-        String deploymentId,
-        String ejbName,
-        String homeInterfaceName,
-        String remoteInterfaceName,
-        String localHomeInterfaceName,
-        String localInterfaceName,
-        String serviceEndpointInterfaceName,
-        String beanClassName,
-        ClassLoader classLoader,
-        boolean securityEnabled,
-        String defaultRole,
-        String runAsRole,
-        RunAsSource runAsSource,
-        Map componentContext,
-        Set unshareableResources,
-        Set applicationManagedSecurityResources,
-        TrackedConnectionAssociator trackedConnectionAssociator,
-        GeronimoTransactionManager transactionManager,
-        OpenEjbSystem openEjbSystem,
-        SessionManager sessionManager,
-        Kernel kernel) throws Exception {
-        this(objectName,
-            deploymentId,
-            ejbName,
-            homeInterfaceName,
-            remoteInterfaceName,
-            localHomeInterfaceName,
-            localInterfaceName,
-            serviceEndpointInterfaceName,
-            beanClassName,
-            classLoader,
-            securityEnabled,
-            defaultRole,
-            runAsRole,
-            runAsSource,
-            EnterpriseNamingContext.createEnterpriseNamingContext(componentContext,
-                transactionManager,
-                kernel,
-                classLoader),
-            unshareableResources,
-            applicationManagedSecurityResources,
-            trackedConnectionAssociator,
-            openEjbSystem,
-            sessionManager);
-    }
-    
-    public ClusteredStatefulDeployment(String objectName,
-        String deploymentId,
-        String ejbName,
-        String homeInterfaceName,
-        String remoteInterfaceName,
-        String localHomeInterfaceName,
-        String localInterfaceName,
-        String serviceEndpointInterfaceName,
-        String beanClassName,
-        ClassLoader classLoader,
-        boolean securityEnabled,
-        String defaultRole,
-        String runAsRole,
-        RunAsSource runAsSource,
-        Context componentContext,
-        Set unshareableResources,
-        Set applicationManagedSecurityResources,
-        TrackedConnectionAssociator trackedConnectionAssociator,
-        OpenEjbSystem openEjbSystem,
-        SessionManager sessionManager) throws LoginException {
+                                       String deploymentId,
+                                       String ejbName,
+                                       String homeInterfaceName,
+                                       String remoteInterfaceName,
+                                       String localHomeInterfaceName,
+                                       String localInterfaceName,
+                                       String serviceEndpointInterfaceName,
+                                       String beanClassName,
+                                       ClassLoader classLoader,
+                                       boolean securityEnabled,
+                                       String defaultRole,
+                                       String runAsRole,
+                                       RunAsSource runAsSource,
+                                       Map<String, Object> componentContext,
+                                       Set<String> unshareableResources,
+                                       Set<String> applicationManagedSecurityResources,
+                                       TrackedConnectionAssociator trackedConnectionAssociator,
+                                       GeronimoTransactionManager transactionManager,
+                                       OpenEjbSystem openEjbSystem,
+                                       SessionManager sessionManager,
+                                       EjbModuleImpl ejbModule,
+                                       Kernel kernel) throws Exception {
         super(objectName,
-            deploymentId,
-            ejbName,
-            homeInterfaceName,
-            remoteInterfaceName,
-            localHomeInterfaceName,
-            localInterfaceName,
-            serviceEndpointInterfaceName,
-            beanClassName,
-            classLoader,
-            securityEnabled,
-            defaultRole,
-            runAsRole,
-            runAsSource,
-            componentContext,
-            unshareableResources,
-            applicationManagedSecurityResources,
-            trackedConnectionAssociator,
-            openEjbSystem);
+                deploymentId,
+                ejbName,
+                homeInterfaceName,
+                remoteInterfaceName,
+                localHomeInterfaceName,
+                localInterfaceName,
+                serviceEndpointInterfaceName,
+                beanClassName,
+                classLoader,
+                securityEnabled,
+                defaultRole,
+                runAsRole,
+                runAsSource,
+                componentContext,
+                unshareableResources,
+                applicationManagedSecurityResources,
+                trackedConnectionAssociator,
+                transactionManager,
+                openEjbSystem,
+                ejbModule,
+                kernel);
         if (null == sessionManager) {
             throw new IllegalArgumentException("sessionManager is required");
         }
         this.sessionManager = sessionManager;
     }
 
-    public void doStart() throws Exception {
-        start();
-    }
-
-    public void doStop() throws Exception {
-        stop();
-    }
-
-    public void doFail() {
-        stop();
-    }
-
     protected void start() throws Exception {
         super.start();
 
@@ -190,42 +131,42 @@
 
     static {
         GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(ClusteredStatefulDeployment.class,
-            ClusteredStatefulDeployment.class,
-            EjbDeploymentGBean.GBEAN_INFO,
-            NameFactory.STATEFUL_SESSION_BEAN);
-        
+                ClusteredStatefulDeployment.class,
+                EjbDeploymentGBean.GBEAN_INFO,
+                NameFactory.STATEFUL_SESSION_BEAN);
+
         builder.addReference(GBEAN_REF_SESSION_MANAGER, SessionManager.class, GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
-        
-        builder.setConstructor(new String[] { "objectName",
-            "deploymentId",
-            "ejbName",
-
-            "homeInterfaceName",
-            "remoteInterfaceName",
-            "localHomeInterfaceName",
-            "localInterfaceName",
-            "serviceEndpointInterfaceName",
-            "beanClassName",
-            "classLoader",
-
-            "securityEnabled",
-            "defaultRole",
-            "runAsRole",
-            "RunAsSource",
-
-            "componentContextMap",
-
-            "unshareableResources",
-            "applicationManagedSecurityResources",
-            "TrackedConnectionAssociator",
-            "TransactionManager",
 
-            "OpenEjbSystem",
-            GBEAN_REF_SESSION_MANAGER,
+        builder.setConstructor(new String[]{"objectName",
+                "deploymentId",
+                "ejbName",
+
+                "homeInterfaceName",
+                "remoteInterfaceName",
+                "localHomeInterfaceName",
+                "localInterfaceName",
+                "serviceEndpointInterfaceName",
+                "beanClassName",
+                "classLoader",
+
+                "securityEnabled",
+                "defaultRole",
+                "runAsRole",
+                "RunAsSource",
+
+                "componentContextMap",
+
+                "unshareableResources",
+                "applicationManagedSecurityResources",
+                "TrackedConnectionAssociator",
+                "TransactionManager",
+
+                "OpenEjbSystem",
+                GBEAN_REF_SESSION_MANAGER,
 
-            "kernel"
+                "kernel"
         });
-        
+
         GBEAN_INFO = builder.getBeanInfo();
     }
 

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=901935&r1=901934&r2=901935&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 Fri Jan 22 00:10:53 2010
@@ -57,8 +57,8 @@
     private final Context componentContext;
 
     // connector stuff
-    private final Set unshareableResources;
-    private final Set applicationManagedSecurityResources;
+    private final Set<String> unshareableResources;
+    private final Set<String> applicationManagedSecurityResources;
     private final TrackedConnectionAssociator trackedConnectionAssociator;
 
     protected final OpenEjbSystem openEjbSystem;
@@ -87,8 +87,8 @@
             String runAsRole,
             RunAsSource runAsSource,
             Context componentContext,
-            Set unshareableResources,
-            Set applicationManagedSecurityResources,
+            Set<String> unshareableResources,
+            Set<String> applicationManagedSecurityResources,
             TrackedConnectionAssociator trackedConnectionAssociator,
             OpenEjbSystem openEjbSystem) throws LoginException {
         this.objectName = objectName;
@@ -170,11 +170,11 @@
         return javaCompSubContext;
     }
 
-    public Set getUnshareableResources() {
+    public Set<String> getUnshareableResources() {
         return unshareableResources;
     }
 
-    public Set getApplicationManagedSecurityResources() {
+    public Set<String> getApplicationManagedSecurityResources() {
         return applicationManagedSecurityResources;
     }
 

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeploymentGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeploymentGBean.java?rev=901935&r1=901934&r2=901935&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeploymentGBean.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeploymentGBean.java Fri Jan 22 00:10:53 2010
@@ -17,42 +17,45 @@
  */
 package org.apache.geronimo.openejb;
 
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 
+import javax.naming.Context;
+import javax.naming.NamingException;
+import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
-import org.apache.geronimo.security.jacc.RunAsSource;
 import org.apache.geronimo.security.SecurityNames;
+import org.apache.geronimo.security.jacc.RunAsSource;
 import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
-import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
-import org.apache.geronimo.kernel.Kernel;
 
 public class EjbDeploymentGBean extends EjbDeployment implements GBeanLifecycle {
     public EjbDeploymentGBean(String objectName,
-            String deploymentId,
-            String ejbName,
-            String homeInterfaceName,
-            String remoteInterfaceName,
-            String localHomeInterfaceName,
-            String localInterfaceName,
-            String serviceEndpointInterfaceName,
-            String beanClassName,
-            ClassLoader classLoader,
-            boolean securityEnabled,
-            String defaultRole,
-            String runAsRole,
-            RunAsSource runAsSource,
-            Map componentContext,
-            Set unshareableResources,
-            Set applicationManagedSecurityResources,
-            TrackedConnectionAssociator trackedConnectionAssociator,
-            GeronimoTransactionManager transactionManager,
-            OpenEjbSystem openEjbSystem,
-            Kernel kernel) throws Exception {
+                              String deploymentId,
+                              String ejbName,
+                              String homeInterfaceName,
+                              String remoteInterfaceName,
+                              String localHomeInterfaceName,
+                              String localInterfaceName,
+                              String serviceEndpointInterfaceName,
+                              String beanClassName,
+                              ClassLoader classLoader,
+                              boolean securityEnabled,
+                              String defaultRole,
+                              String runAsRole,
+                              RunAsSource runAsSource,
+                              Map<String, Object> componentContext,
+                              Set<String> unshareableResources,
+                              Set<String> applicationManagedSecurityResources,
+                              TrackedConnectionAssociator trackedConnectionAssociator,
+                              GeronimoTransactionManager transactionManager,
+                              OpenEjbSystem openEjbSystem,
+                              EjbModuleImpl ejbModule, Kernel kernel) throws Exception {
         super(objectName,
                 deploymentId,
                 ejbName,
@@ -67,13 +70,23 @@
                 defaultRole,
                 runAsRole,
                 runAsSource,
-                EnterpriseNamingContext.createEnterpriseNamingContext(componentContext, transactionManager, kernel, classLoader),
+                buildJndiContext(componentContext, ejbModule, transactionManager, kernel, classLoader),
                 unshareableResources,
                 applicationManagedSecurityResources,
                 trackedConnectionAssociator,
                 openEjbSystem);
     }
 
+    private static Context buildJndiContext(Map<String, Object> componentContext, EjbModuleImpl ejbModule, GeronimoTransactionManager transactionManager, Kernel kernel, ClassLoader classLoader) throws NamingException {
+        Context compContext = EnterpriseNamingContext.livenReferences(componentContext, transactionManager, kernel, classLoader, "comp/");
+        Set<Context> contexts = new LinkedHashSet<Context>(4);
+        contexts.add(compContext);
+        contexts.add(ejbModule.getModuleContext());
+        contexts.add(ejbModule.getApplicationJndi().getApplicationContext());
+        contexts.add(ejbModule.getApplicationJndi().getGlobalContext());
+        return EnterpriseNamingContext.createEnterpriseNamingContext(contexts);
+    }
+
     public void doStart() throws Exception {
         start();
     }
@@ -117,6 +130,7 @@
         infoFactory.addReference("TransactionManager", GeronimoTransactionManager.class);
 
         infoFactory.addReference("OpenEjbSystem", OpenEjbSystem.class);
+        infoFactory.addReference("EjbModule", EjbModuleImpl.class);
 
         infoFactory.addAttribute("kernel", Kernel.class, false);
 
@@ -146,6 +160,7 @@
                 "TransactionManager",
 
                 "OpenEjbSystem",
+                "EjbModule",
 
                 "kernel",
         });



Mime
View raw message