geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r126558 - in geronimo/trunk/modules: client-builder/src/java/org/apache/geronimo/client/builder client/src/java/org/apache/geronimo/client jetty-builder/src/java/org/apache/geronimo/jetty/deployment jetty/src/java/org/apache/geronimo/jetty jetty/src/java/org/apache/geronimo/jetty/interceptor naming-builder/src/java/org/apache/geronimo/naming/deployment naming/src/java/org/apache/geronimo/naming/java naming/src/test/org/apache/geronimo/naming/java
Date Wed, 26 Jan 2005 23:13:14 GMT
Author: dain
Date: Wed Jan 26 15:13:09 2005
New Revision: 126558

URL: http://svn.apache.org/viewcvs?view=rev&rev=126558
Log:
Changed deployment to pass around a Map instead of a jndi Context for the enc.  This allows
all parts of deployment and the ultimate container to modify the enc.

Added:
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/SimpleReadOnlyContext.java
Modified:
   geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
   geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/StaticJndiContextPlugin.java
   geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java
   geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextInterceptor.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/javaURLContextFactory.java
   geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java

Modified: geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?view=diff&rev=126558&p1=geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java&r1=126557&p2=geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
(original)
+++ geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
Wed Jan 26 15:13:09 2005
@@ -27,6 +27,7 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.StringTokenizer;
+import java.util.Map;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
@@ -62,7 +63,6 @@
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
-import org.apache.geronimo.naming.java.ReadOnlyContext;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientDocument;
 import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientType;
@@ -301,7 +301,7 @@
         }
 
         // create a gbean for the app client module and add it to the ear
-        ReadOnlyContext componentContext;
+        Map componentContext;
         GBeanData appClientModuleGBeanData = new GBeanData(appClientModuleName, J2EEAppClientModuleImpl.GBEAN_INFO);
         try {
             appClientModuleGBeanData.setReferencePatterns("J2EEServer", Collections.singleton(earContext.getServerObjectName()));
@@ -440,7 +440,6 @@
                 ObjectName jndiContextName = ObjectName.getInstance("geronimo.client:type=StaticJndiContext");
                 GBeanData jndiContextGBeanData = new GBeanData(jndiContextName, StaticJndiContextPlugin.GBEAN_INFO);
                 try {
-
                     componentContext = buildComponentContext(appClientDeploymentContext,
appClientModule, appClient, geronimoAppClient, earClassLoader);
                     jndiContextGBeanData.setAttribute("context", componentContext);
                 } catch (Exception e) {
@@ -554,7 +553,7 @@
         }
     }
 
-    private ReadOnlyContext buildComponentContext(EARContext earContext, AppClientModule
appClientModule, ApplicationClientType appClient, GerApplicationClientType geronimoAppClient,
ClassLoader cl) throws DeploymentException {
+    private Map buildComponentContext(EARContext earContext, AppClientModule appClientModule,
ApplicationClientType appClient, GerApplicationClientType geronimoAppClient, ClassLoader cl)
throws DeploymentException {
 
         return ENCConfigBuilder.buildComponentContext(earContext,
                 appClientModule,

Modified: geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/StaticJndiContextPlugin.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/StaticJndiContextPlugin.java?view=diff&rev=126558&p1=geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/StaticJndiContextPlugin.java&r1=126557&p2=geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/StaticJndiContextPlugin.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/StaticJndiContextPlugin.java
(original)
+++ geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/StaticJndiContextPlugin.java
Wed Jan 26 15:13:09 2005
@@ -16,11 +16,17 @@
  */
 package org.apache.geronimo.client;
 
+import java.util.Iterator;
+import java.util.Map;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
+import javax.naming.Context;
+import javax.naming.NamingException;
 
-import org.apache.geronimo.naming.java.ReadOnlyContext;
 import org.apache.geronimo.naming.java.RootContext;
+import org.apache.geronimo.naming.java.SimpleReadOnlyContext;
+import org.apache.geronimo.naming.reference.KernelAwareReference;
+import org.apache.geronimo.naming.reference.ClassLoaderAwareReference;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.kernel.Kernel;
@@ -29,15 +35,23 @@
  * @version $Rev$ $Date$
  */
 public class StaticJndiContextPlugin implements AppClientPlugin {
-    private final ReadOnlyContext context;
+    private final Context context;
 
-    public StaticJndiContextPlugin(ReadOnlyContext context) {
-        this.context = context;
+    public StaticJndiContextPlugin(Map context, Kernel kernel, ClassLoader classLoader) throws
NamingException {
+        // create ReadOnlyContext
+        for (Iterator iterator = context.values().iterator(); iterator.hasNext();) {
+            Object value = iterator.next();
+            if (value instanceof KernelAwareReference) {
+                ((KernelAwareReference) value).setKernel(kernel);
+            }
+            if (value instanceof ClassLoaderAwareReference) {
+                ((ClassLoaderAwareReference) value).setClassLoader(classLoader);
+            }
+        }
+        this.context = new SimpleReadOnlyContext(context);
     }
 
     public void startClient(ObjectName appClientModuleName, Kernel kernel, ClassLoader classLoader)
throws Exception {
-        context.setKernel(kernel);
-        context.setClassLoader(classLoader);
         RootContext.setComponentContext(context);
         System.setProperty("java.naming.factory.initial", "com.sun.jndi.rmi.registry.RegistryContextFactory");
         System.setProperty("java.naming.factory.url.pkgs", "org.apache.geronimo.naming");
@@ -54,10 +68,12 @@
     static {
         GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(StaticJndiContextPlugin.class);
 
-        infoFactory.addAttribute("context", ReadOnlyContext.class, true);
+        infoFactory.addAttribute("context", Map.class, true);
+        infoFactory.addAttribute("kernel", Kernel.class, false);
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
         infoFactory.addInterface(AppClientPlugin.class);
 
-        infoFactory.setConstructor(new String[]{"context"});
+        infoFactory.setConstructor(new String[]{"context", "kernel", "classLoader"});
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Modified: geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?view=diff&rev=126558&p1=geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java&r1=126557&p2=geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Wed Jan 26 15:13:09 2005
@@ -70,7 +70,6 @@
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
-import org.apache.geronimo.naming.java.ReadOnlyContext;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.security.deploy.Security;
 import org.apache.geronimo.security.deployment.SecurityBuilder;
@@ -349,7 +348,7 @@
 
         UserTransaction userTransaction = new OnlineUserTransaction();
         //this may add to the web classpath with enhanced classes.
-        ReadOnlyContext compContext = buildComponentContext(earContext, webModule, webApp,
jettyWebApp, userTransaction, webClassLoader);
+        Map compContext = buildComponentContext(earContext, webModule, webApp, jettyWebApp,
userTransaction, webClassLoader);
 
         GBeanData webModuleData = new GBeanData(webModuleName, JettyWebAppContext.GBEAN_INFO);
         try {
@@ -427,8 +426,7 @@
             } else {
                 welcomeFiles = new ArrayList(defaultWelcomeFiles);
             }
-
-            webModuleData.setAttribute("welcomeFiles", (String[]) welcomeFiles.toArray(new
String[welcomeFiles.size()]));
+            webModuleData.setAttribute("welcomeFiles", welcomeFiles.toArray(new String[welcomeFiles.size()]));
 
             LocaleEncodingMappingListType[] localeEncodingMappingListArray = webApp.getLocaleEncodingMappingListArray();
             Map localeEncodingMappingMap = new HashMap();
@@ -989,8 +987,7 @@
         }
     }
 
-    private ReadOnlyContext buildComponentContext(EARContext earContext, Module webModule,
WebAppType webApp, JettyWebAppType jettyWebApp, UserTransaction userTransaction, ClassLoader
cl) throws DeploymentException {
-
+    private Map buildComponentContext(EARContext earContext, Module webModule, WebAppType
webApp, JettyWebAppType jettyWebApp, UserTransaction userTransaction, ClassLoader cl) throws
DeploymentException {
         URI targetPathUri = null;
         try {
             targetPathUri = new URI(webModule.getTargetPath() + "/");

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java?view=diff&rev=126558&p1=geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java&r1=126557&p2=geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
Wed Jan 26 15:13:09 2005
@@ -27,6 +27,8 @@
 import java.security.PermissionCollection;
 import java.io.IOException;
 
+import javax.naming.Context;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.mortbay.http.Authenticator;
@@ -51,12 +53,14 @@
 import org.apache.geronimo.jetty.interceptor.TransactionContextBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.WebApplicationContextBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.SecurityContextBeforeAfter;
-import org.apache.geronimo.naming.java.ReadOnlyContext;
 import org.apache.geronimo.transaction.OnlineUserTransaction;
 import org.apache.geronimo.transaction.TrackedConnectionAssociator;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
 import org.apache.geronimo.security.deploy.Security;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.naming.reference.KernelAwareReference;
+import org.apache.geronimo.naming.reference.ClassLoaderAwareReference;
+import org.apache.geronimo.naming.java.SimpleReadOnlyContext;
 
 /**
  * Wrapper for a WebApplicationContext that sets up its J2EE environment.
@@ -94,7 +98,7 @@
     }
 
     public JettyWebAppContext(URI uri,
-                                  ReadOnlyContext componentContext,
+                                  Map componentContext,
                                   OnlineUserTransaction userTransaction,
                                   ClassLoader classLoader,
                                   URI[] webClassPath,
@@ -175,15 +179,25 @@
         setTagLibMap(tagLibMap);
         setSessionTimeoutSeconds(sessionTimeoutSeconds);
 
+        // create ReadOnlyContext
+        Context enc = null;
         if (componentContext != null) {
-            componentContext.setKernel(kernel);
-            componentContext.setClassLoader(this.webClassLoader);
+            for (Iterator iterator = componentContext.values().iterator(); iterator.hasNext();)
{
+                Object value = iterator.next();
+                if (value instanceof KernelAwareReference) {
+                    ((KernelAwareReference) value).setKernel(kernel);
+                }
+                if (value instanceof ClassLoaderAwareReference) {
+                    ((ClassLoaderAwareReference) value).setClassLoader(this.webClassLoader);
+                }
+            }
+            enc = new SimpleReadOnlyContext(componentContext);
         }
 
         int index = 0;
         BeforeAfter interceptor = new InstanceContextBeforeAfter(null, index++, unshareableResources,
applicationManagedSecurityResources, trackedConnectionAssociator);
         interceptor = new TransactionContextBeforeAfter(interceptor, index++, index++, transactionContextManager);
-        interceptor = new ComponentContextBeforeAfter(interceptor, index++, componentContext);
+        interceptor = new ComponentContextBeforeAfter(interceptor, index++, enc);
         interceptor = new ThreadClassloaderBeforeAfter(interceptor, index++, index++, this.webClassLoader);
         interceptor = new WebApplicationContextBeforeAfter(interceptor, index++, this);
 //JACC
@@ -394,7 +408,7 @@
 
 
         infoBuilder.addAttribute("uri", URI.class, true);
-        infoBuilder.addAttribute("componentContext", ReadOnlyContext.class, true);
+        infoBuilder.addAttribute("componentContext", Map.class, true);
         infoBuilder.addAttribute("userTransaction", OnlineUserTransaction.class, true);
         infoBuilder.addAttribute("classLoader", ClassLoader.class, false);
         infoBuilder.addAttribute("webClassPath", URI[].class, true);

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java?view=diff&rev=126558&p1=geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java&r1=126557&p2=geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/ComponentContextBeforeAfter.java
Wed Jan 26 15:13:09 2005
@@ -16,7 +16,8 @@
  */
 package org.apache.geronimo.jetty.interceptor;
 
-import org.apache.geronimo.naming.java.ReadOnlyContext;
+import javax.naming.Context;
+
 import org.apache.geronimo.naming.java.RootContext;
 import org.mortbay.http.HttpRequest;
 import org.mortbay.http.HttpResponse;
@@ -28,17 +29,17 @@
 
     private final BeforeAfter next;
     private final int index;
-    private final ReadOnlyContext readOnlyContext;
+    private final Context componentContext;
 
-    public ComponentContextBeforeAfter(BeforeAfter next, int index, ReadOnlyContext readOnlyContext)
{
+    public ComponentContextBeforeAfter(BeforeAfter next, int index, Context componentContext)
{
         this.next = next;
         this.index = index;
-        this.readOnlyContext = readOnlyContext;
+        this.componentContext = componentContext;
     }
 
     public void before(Object[] context, HttpRequest httpRequest, HttpResponse httpResponse)
{
         context[index] = RootContext.getComponentContext();
-        RootContext.setComponentContext(readOnlyContext);
+        RootContext.setComponentContext(componentContext);
         if (next != null) {
             next.before(context, httpRequest, httpResponse);
         }
@@ -48,7 +49,7 @@
         if (next != null) {
             next.after(context, httpRequest, httpResponse);
         }
-        RootContext.setComponentContext((ReadOnlyContext) context[index]);
+        RootContext.setComponentContext((Context) context[index]);
     }
 
 }

Modified: geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java?view=diff&rev=126558&p1=geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java&r1=126557&p2=geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
(original)
+++ geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
Wed Jan 26 15:13:09 2005
@@ -44,7 +44,6 @@
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.naming.java.ComponentContextBuilder;
-import org.apache.geronimo.naming.java.ReadOnlyContext;
 import org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerEjbRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerGbeanLocatorType;
@@ -569,7 +568,7 @@
         builder.setApplicationManagedSecurityResources(applicationManagedSecurityResources);
     }
 
-    public static ReadOnlyContext buildComponentContext(EARContext earContext, Module module,
UserTransaction userTransaction, EnvEntryType[] envEntries, EjbRefType[] ejbRefs, GerEjbRefType[]
gerEjbRefs, EjbLocalRefType[] ejbLocalRefs, GerEjbLocalRefType[] gerEjbLocalRef, ResourceRefType[]
resourceRefs, GerResourceRefType[] gerResourceRef, ResourceEnvRefType[] resourceEnvRefs, GerResourceEnvRefType[]
gerResourceEnvRef, MessageDestinationRefType[] messageDestinationRefs, ServiceRefType[] serviceRefs,
ClassLoader cl) throws DeploymentException {
+    public static Map buildComponentContext(EARContext earContext, Module module, UserTransaction
userTransaction, EnvEntryType[] envEntries, EjbRefType[] ejbRefs, GerEjbRefType[] gerEjbRefs,
EjbLocalRefType[] ejbLocalRefs, GerEjbLocalRefType[] gerEjbLocalRef, ResourceRefType[] resourceRefs,
GerResourceRefType[] gerResourceRef, ResourceEnvRefType[] resourceEnvRefs, GerResourceEnvRefType[]
gerResourceEnvRef, MessageDestinationRefType[] messageDestinationRefs, ServiceRefType[] serviceRefs,
ClassLoader cl) throws DeploymentException {
         ComponentContextBuilder builder = new ComponentContextBuilder();
 
         if (userTransaction != null) {

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java?view=diff&rev=126558&p1=geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java&r1=126557&p2=geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java
(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextBuilder.java
Wed Jan 26 15:13:09 2005
@@ -17,6 +17,8 @@
 
 package org.apache.geronimo.naming.java;
 
+import java.util.Map;
+import java.util.HashMap;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.naming.NamingException;
@@ -33,41 +35,21 @@
  */
 public class ComponentContextBuilder {
     private static final String ENV = "env/";
-    private final ReadOnlyContext context;
+    private final Map context = new HashMap();
 
-    public ComponentContextBuilder() {
-        this.context = new ReadOnlyContext();
-        try {
-            context.internalBind("env", new ReadOnlyContext());
-        } catch (NamingException e) {
-            throw new AssertionError();
-        }
-    }
-
-    public ReadOnlyContext getContext() {
-        context.freeze();
+    public Map getContext() {
         return context;
     }
 
     public void addUserTransaction(UserTransaction userTransaction) throws NamingException
{
-        if (context.isFrozen()) {
-            throw new IllegalStateException("Context has been frozen");
-        }
-        context.internalBind("UserTransaction", userTransaction);
+        context.put("UserTransaction", userTransaction);
     }
 
     public void bind(String name, Object value) throws NamingException {
-        if (context.isFrozen()) {
-            throw new IllegalStateException("Context has been frozen");
-        }
-        context.internalBind(ENV + name, value);
+        context.put(ENV + name, value);
     }
 
     public void addEnvEntry(String name, String type, String text, ClassLoader classLoader)
throws NamingException, NumberFormatException {
-        if (context.isFrozen()) {
-            throw new IllegalStateException("Context has been frozen");
-        }
-
         Object value;
         if (text == null) {
             if ("org.apache.geronimo.kernel.Kernel".equals(type)) {
@@ -113,6 +95,6 @@
             value = new GBeanProxyReference(objectName, clazz);
 
         }
-        context.internalBind(ENV + name, value);
+        context.put(ENV + name, value);
     }
 }

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextInterceptor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextInterceptor.java?view=diff&rev=126558&p1=geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextInterceptor.java&r1=126557&p2=geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextInterceptor.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextInterceptor.java
(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ComponentContextInterceptor.java
Wed Jan 26 15:13:09 2005
@@ -17,6 +17,8 @@
 
 package org.apache.geronimo.naming.java;
 
+import javax.naming.Context;
+
 import org.apache.geronimo.core.service.Interceptor;
 import org.apache.geronimo.core.service.Invocation;
 import org.apache.geronimo.core.service.InvocationResult;
@@ -29,19 +31,19 @@
  */
 public class ComponentContextInterceptor implements Interceptor {
     private final Interceptor next;
-    private final ReadOnlyContext compContext;
+    private final Context compContext;
 
     /**
      * Constructor specifying the components JNDI Context (java:comp)
      * @param compContext the component's JNDI Context
      */
-    public ComponentContextInterceptor(Interceptor next, ReadOnlyContext compContext) {
+    public ComponentContextInterceptor(Interceptor next, Context compContext) {
         this.next = next;
         this.compContext = compContext;
     }
 
     public InvocationResult invoke(Invocation invocation) throws Throwable {
-        ReadOnlyContext oldContext = RootContext.getComponentContext();
+        Context oldContext = RootContext.getComponentContext();
         try {
             RootContext.setComponentContext(compContext);
             return next.invoke(invocation);

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java?view=diff&rev=126558&p1=geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java&r1=126557&p2=geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java
(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/ReadOnlyContext.java
Wed Jan 26 15:13:09 2005
@@ -37,6 +37,7 @@
 import javax.naming.NotContextException;
 import javax.naming.OperationNotSupportedException;
 import javax.naming.Reference;
+import javax.naming.InitialContext;
 import javax.naming.spi.NamingManager;
 
 import org.apache.geronimo.naming.reference.SimpleReference;
@@ -192,13 +193,8 @@
         }
         Object result = treeBindings.get(name);
         if (result == null) {
-            int pos = name.indexOf(':');
-            if (pos > 0) {
-                String scheme = name.substring(0, pos);
-                Context ctx = NamingManager.getURLContext(scheme, env);
-                if (ctx == null) {
-                    throw new NamingException("scheme " + scheme + " not recognized");
-                }
+            if (name.indexOf(':') > 0) {
+                Context ctx = new InitialContext();
                 return ctx.lookup(name);
             } else {
                 // Split out the first name of the path
@@ -238,9 +234,6 @@
             } catch (Exception e) {
                 throw (NamingException)new NamingException("could not look up : " + name).initCause(e);
             }
-        }
-        if (result instanceof ReadOnlyContext) {
-            result = new ReadOnlyContext((ReadOnlyContext) result, env);
         }
         return result;
     }

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java?view=diff&rev=126558&p1=geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java&r1=126557&p2=geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java
(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/RootContext.java
Wed Jan 26 15:13:09 2005
@@ -20,6 +20,7 @@
 import java.util.Hashtable;
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
+import javax.naming.Context;
 
 /**
  * The root context for the java: namespace.
@@ -31,10 +32,6 @@
 public class RootContext extends ReadOnlyContext {
     private static InheritableThreadLocal compContext = new InheritableThreadLocal();
 
-    public RootContext(Hashtable env) {
-        super(env);
-    }
-
     public Object lookup(String name) throws NamingException {
         if (name.startsWith("java:")) {
             name = name.substring(5);
@@ -42,12 +39,11 @@
                 return this;
             }
 
-            ReadOnlyContext compCtx = (ReadOnlyContext) compContext.get();
+            Context compCtx = (Context) compContext.get();
             if (compCtx == null) {
                 // the component context was not set for this thread
                 throw new NameNotFoundException(name);
             }
-            compCtx = new ReadOnlyContext(compCtx, getEnvironment());
 
             if ("comp".equals(name)) {
                 return compCtx;
@@ -69,7 +65,7 @@
      * for all lookups of "java:comp"
      * @param ctx the current components context
      */
-    public static void setComponentContext(ReadOnlyContext ctx) {
+    public static void setComponentContext(Context ctx) {
         compContext.set(ctx);
     }
 
@@ -77,7 +73,7 @@
      * Get the component context for the current thread.
      * @return the current components context
      */
-    public static ReadOnlyContext getComponentContext() {
-        return (ReadOnlyContext) compContext.get();
+    public static Context getComponentContext() {
+        return (Context) compContext.get();
     }
 }

Added: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/SimpleReadOnlyContext.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/SimpleReadOnlyContext.java?view=auto&rev=126558
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/SimpleReadOnlyContext.java
Wed Jan 26 15:13:09 2005
@@ -0,0 +1,44 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed 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.naming.java;
+
+import java.util.Map;
+import java.util.Iterator;
+import javax.naming.NamingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class SimpleReadOnlyContext extends ReadOnlyContext {
+    private SimpleReadOnlyContext() {
+    }
+
+    public SimpleReadOnlyContext(Map context) throws NamingException {
+        internalBind("env", new ReadOnlyContext());
+        for (Iterator iterator = context.entrySet().iterator(); iterator.hasNext();) {
+            Map.Entry entry = (Map.Entry) iterator.next();
+            String name = (String) entry.getKey();
+            Object value = entry.getValue();
+            internalBind(name, value);
+        }
+        freeze();
+    }
+
+    protected ReadOnlyContext newContext() {
+        return new SimpleReadOnlyContext();
+    }
+}

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/javaURLContextFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/javaURLContextFactory.java?view=diff&rev=126558&p1=geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/javaURLContextFactory.java&r1=126557&p2=geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/javaURLContextFactory.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/javaURLContextFactory.java
(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/java/javaURLContextFactory.java
Wed Jan 26 15:13:09 2005
@@ -42,7 +42,7 @@
      */
     public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment)
throws Exception {
         if (obj == null) {
-            return new RootContext(environment);
+            return new RootContext();
         } else {
             throw new OperationNotSupportedException();
         }

Modified: geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java?view=diff&rev=126558&p1=geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java&r1=126557&p2=geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java&r2=126558
==============================================================================
--- geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java
(original)
+++ geronimo/trunk/modules/naming/src/test/org/apache/geronimo/naming/java/ContextBuilderTest.java
Wed Jan 26 15:13:09 2005
@@ -41,27 +41,6 @@
 
     private List proxy;
 
-    public void testFreeze() {
-        ReadOnlyContext context = builder.getContext();
-        assertTrue(context.isFrozen());
-        try {
-            builder.addEnvEntry(null, null, null, null);
-            fail();
-        } catch (IllegalStateException e) {
-            // ok
-        } catch (NamingException e) {
-            fail();
-        }
-        try {
-            builder.addUserTransaction(null);
-            fail();
-        } catch (IllegalStateException e) {
-            // ok
-        } catch (NamingException e) {
-            fail();
-        }
-    }
-
     public void testEnvEntries() throws Exception {
         String stringVal = "Hello World";
         Character charVal = new Character('H');
@@ -82,7 +61,7 @@
         builder.addEnvEntry("double", Double.class.getName(), doubleVal.toString(), null);
         builder.addEnvEntry("boolean", Boolean.class.getName(), booleanVal.toString(), null);
 
-        ReadOnlyContext context = builder.getContext();
+        SimpleReadOnlyContext context = new SimpleReadOnlyContext(builder.getContext());
         Set actual = new HashSet();
         for (NamingEnumeration e = context.listBindings("env"); e.hasMore();) {
             NameClassPair pair = (NameClassPair) e.next();
@@ -105,7 +84,7 @@
         proxy = new ArrayList();
 //        builder.addResourceEnvRef("resourceenvref", List.class, localRef);
 
-        ReadOnlyContext roc = builder.getContext();
+        SimpleReadOnlyContext context = new SimpleReadOnlyContext(builder.getContext());
         Kernel kernel = new Kernel("test.kernel", "test.domain");
         kernel.boot();
         try {
@@ -115,15 +94,15 @@
             gbean.setAttribute("Content", proxy);
             kernel.loadGBean(proxyFactoryName, gbean);
             kernel.startGBean(proxyFactoryName);
-            Object o = roc.lookup("env/resourceenvref");
+            Object o = context.lookup("env/resourceenvref");
             assertEquals(proxy, o);
         } finally {
             kernel.shutdown();
         }
     }
 
-    public void testEmptyEnvironment() {
-        ReadOnlyContext context = builder.getContext();
+    public void testEmptyEnvironment() throws NamingException {
+        SimpleReadOnlyContext context = new SimpleReadOnlyContext(builder.getContext());
         try {
             ReadOnlyContext env = (ReadOnlyContext) context.lookup("env");
             assertNotNull(env);

Mime
View raw message