geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 53924 - in geronimo/trunk/modules: deployment/src/java/org/apache/geronimo/deployment/service jetty/src/java/org/apache/geronimo/jetty jetty/src/java/org/apache/geronimo/jetty/deployment jetty/src/test/org/apache/geronimo/jetty kernel/src/java/org/apache/geronimo/kernel/config
Date Thu, 07 Oct 2004 00:13:20 GMT
Author: dain
Date: Wed Oct  6 17:13:19 2004
New Revision: 53924

Modified:
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
   geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/ApplicationTest.java
   geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationParent.java
Log:
Added explicit handling of web application classloader which handles WEB-INF/classes and WEB-INF/lib/*.jar
This class loader is also used during deployment so env ref classes can come from the war
classes
Changed Configuration to set the configurationBaseUrl on each gbean in configuration that
has such an attibute


Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
Wed Oct  6 17:13:19 2004
@@ -28,7 +28,6 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.jar.JarFile;
-import java.util.jar.Manifest;
 import javax.management.MalformedObjectNameException;
 
 import org.apache.geronimo.deployment.ConfigurationBuilder;

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
==============================================================================
--- 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 Oct  6 17:13:19 2004
@@ -21,6 +21,7 @@
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.Set;
 import javax.resource.ResourceException;
 
@@ -30,7 +31,6 @@
 import org.apache.geronimo.gbean.GBeanInfoFactory;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.WaitingException;
-import org.apache.geronimo.kernel.config.ConfigurationParent;
 import org.apache.geronimo.naming.java.ReadOnlyContext;
 import org.apache.geronimo.naming.java.RootContext;
 import org.apache.geronimo.transaction.DefaultInstanceContext;
@@ -52,54 +52,75 @@
 public class JettyWebAppContext extends WebApplicationContext implements GBeanLifecycle {
     private static Log log = LogFactory.getLog(JettyWebAppContext.class);
 
-    private final ConfigurationParent config;
-    private final URI uri;
-    private final JettyContainer container;
     private final ReadOnlyContext componentContext;
-    private final TransactionContextManager transactionContextManager;
-    private final TrackedConnectionAssociator associator;
     private final UserTransactionImpl userTransaction;
     private final ClassLoader classLoader;
     private final Set unshareableResources;
     private final Set applicationManagedSecurityResources;
+    private final TransactionContextManager transactionContextManager;
+    private final TrackedConnectionAssociator trackedConnectionAssociator;
+    private final JettyContainer jettyContainer;
 
     private boolean contextPriorityClassLoader = false;
+    private final URI webAppRoot;
 
+    /**
+     * @deprecated never use this... this is only here because Jetty WebApplicationContext
is externalizable
+     */
     public JettyWebAppContext() {
-        this(null, null, null, null, null, null, null, null, null, null);
+        componentContext = null;
+        userTransaction = null;
+        classLoader = null;
+        unshareableResources = null;
+        applicationManagedSecurityResources = null;
+        transactionContextManager = null;
+        trackedConnectionAssociator = null;
+        jettyContainer = null;
+        webAppRoot = null;
     }
 
     public JettyWebAppContext(URI uri,
-            ReadOnlyContext compContext,
+            ReadOnlyContext componentContext,
             UserTransactionImpl userTransaction,
             ClassLoader classLoader,
+            URI[] webClassPath,
+            URL configurationBaseUrl,
             Set unshareableResources,
             Set applicationManagedSecurityResources,
             TransactionContextManager transactionContextManager,
-            TrackedConnectionAssociator associator,
-            ConfigurationParent config,
-            JettyContainer container) {
-        super();
+            TrackedConnectionAssociator trackedConnectionAssociator,
+            JettyContainer jettyContainer) throws MalformedURLException {
 
-        assert container != null;
-        assert compContext != null;
-        assert transactionContextManager != null;
-        assert associator != null;
+        assert uri != null;
+        assert componentContext != null;
         assert userTransaction != null;
         assert classLoader != null;
+        assert webClassPath != null;
+        assert configurationBaseUrl != null;
+        assert transactionContextManager != null;
+        assert trackedConnectionAssociator != null;
+        assert jettyContainer != null;
 
-        this.config = config;
-        this.uri = uri;
-        this.container = container;
-        this.componentContext = compContext;
+        this.componentContext = componentContext;
+        this.userTransaction = userTransaction;
         this.unshareableResources = unshareableResources;
         this.applicationManagedSecurityResources = applicationManagedSecurityResources;
         this.transactionContextManager = transactionContextManager;
-        this.associator = associator;
-        this.userTransaction = userTransaction;
-        this.classLoader = classLoader;
+        this.trackedConnectionAssociator = trackedConnectionAssociator;
+        this.jettyContainer = jettyContainer;
 
         setConfigurationClassNames(new String[]{"org.apache.geronimo.jetty.JettyXMLConfiguration"});
+
+        URI root = URI.create(configurationBaseUrl.toString());
+        webAppRoot = root.resolve(uri);
+
+        URL[] urls = new URL[webClassPath.length];
+        for (int i = 0; i < webClassPath.length; i++) {
+            URI classPathEntry = webClassPath[i];
+            classPathEntry = webAppRoot.resolve(classPathEntry);
+            urls[i] = classPathEntry.toURL();
+        }
+        this.classLoader = new URLClassLoader(urls, classLoader);
     }
 
     /**
@@ -127,12 +148,10 @@
      * determine if the context needs to create its own classloader.
      */
     protected void initClassLoader(boolean forceContextLoader) throws MalformedURLException,
IOException {
+        setClassLoader(classLoader);
+
+        // todo this has no effect since our classloader is not a Jetty context loader
         setClassLoaderJava2Compliant(!contextPriorityClassLoader);
-        if (!contextPriorityClassLoader) {
-            // TODO - once geronimo is correctly setting up the classpath, this should be
uncommented.
-            // At the moment, the g classloader does not appear to know about the WEB-INF
classes and lib.
-            // setClassLoader(Thread.currentThread().getContextClassLoader());
-        }
         super.initClassLoader(forceContextLoader);
 
         if (log.isDebugEnabled()) {
@@ -167,7 +186,7 @@
 
             try {
                 try {
-                    oldInstanceContext = associator.enter(new DefaultInstanceContext(unshareableResources,
applicationManagedSecurityResources));
+                    oldInstanceContext = trackedConnectionAssociator.enter(new DefaultInstanceContext(unshareableResources,
applicationManagedSecurityResources));
                 } catch (ResourceException e) {
                     throw new RuntimeException(e);
                 }
@@ -186,7 +205,7 @@
             }
         } finally {
             try {
-                associator.exit(oldInstanceContext);
+                trackedConnectionAssociator.exit(oldInstanceContext);
             } catch (ResourceException e) {
                 throw new RuntimeException(e);
             } finally {
@@ -204,14 +223,10 @@
             return;
         }
 
-        if (uri.isAbsolute()) {
-            setWAR(uri.toString());
-        } else {
-            setWAR(new URL(config.getBaseURL(), uri.toString()).toString());
-        }
+        setWAR(webAppRoot.toString());
 
-        userTransaction.setUp(transactionContextManager, associator);
-        container.addContext(this);
+        userTransaction.setUp(transactionContextManager, trackedConnectionAssociator);
+        jettyContainer.addContext(this);
 
         ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
         try {
@@ -233,7 +248,7 @@
                 try {
 
                     try {
-                        oldInstanceContext = associator.enter(new DefaultInstanceContext(unshareableResources,
applicationManagedSecurityResources));
+                        oldInstanceContext = trackedConnectionAssociator.enter(new DefaultInstanceContext(unshareableResources,
applicationManagedSecurityResources));
                     } catch (ResourceException e) {
                         throw new RuntimeException(e);
                     }
@@ -252,7 +267,7 @@
                 }
             } finally {
                 try {
-                    associator.exit(oldInstanceContext);
+                    trackedConnectionAssociator.exit(oldInstanceContext);
                 } catch (ResourceException e) {
                     throw new RuntimeException(e);
                 } finally {
@@ -294,7 +309,7 @@
                 try {
 
                     try {
-                        oldInstanceContext = associator.enter(new DefaultInstanceContext(unshareableResources,
applicationManagedSecurityResources));
+                        oldInstanceContext = trackedConnectionAssociator.enter(new DefaultInstanceContext(unshareableResources,
applicationManagedSecurityResources));
                     } catch (ResourceException e) {
                         throw new RuntimeException(e);
                     }
@@ -320,7 +335,7 @@
                 }
             } finally {
                 try {
-                    associator.exit(oldInstanceContext);
+                    trackedConnectionAssociator.exit(oldInstanceContext);
                 } catch (ResourceException e) {
                     throw new RuntimeException(e);
                 } finally {
@@ -329,7 +344,7 @@
                 }
                 //TODO should we reset the transactioncontext to null if we set it?
             }
-            container.removeContext(this);
+            jettyContainer.removeContext(this);
             if (userTransaction != null) {
                 userTransaction.setOnline(false);
             }
@@ -346,7 +361,7 @@
         } catch (InterruptedException e) {
         }
 
-        container.removeContext(this);
+        jettyContainer.removeContext(this);
         log.info("JettyWebAppContext failed");
     }
 
@@ -356,29 +371,32 @@
         GBeanInfoFactory infoFactory = new GBeanInfoFactory("Jetty WebApplication Context",
JettyWebAppContext.class);
 
         infoFactory.addAttribute("uri", URI.class, true);
-        infoFactory.addAttribute("contextPath", String.class, true);
-        infoFactory.addAttribute("contextPriorityClassLoader", Boolean.TYPE, true);
         infoFactory.addAttribute("componentContext", ReadOnlyContext.class, true);
-        infoFactory.addAttribute("unshareableResources", Set.class, true);
-        infoFactory.addAttribute("applicationManagedSecurityResources", Set.class, true);
         infoFactory.addAttribute("userTransaction", UserTransactionImpl.class, true);
         infoFactory.addAttribute("classLoader", ClassLoader.class, false);
+        infoFactory.addAttribute("webClassPath", URI[].class, true);
+        infoFactory.addAttribute("configurationBaseUrl", URL.class, true);
+        infoFactory.addAttribute("unshareableResources", Set.class, true);
+        infoFactory.addAttribute("applicationManagedSecurityResources", Set.class, true);
+
+        infoFactory.addAttribute("contextPath", String.class, true);
+        infoFactory.addAttribute("contextPriorityClassLoader", Boolean.TYPE, true);
 
-        infoFactory.addReference("Configuration", ConfigurationParent.class);
-        infoFactory.addReference("JettyContainer", JettyContainer.class);
         infoFactory.addReference("TransactionContextManager", TransactionContextManager.class);
         infoFactory.addReference("TrackedConnectionAssociator", TrackedConnectionAssociator.class);
+        infoFactory.addReference("JettyContainer", JettyContainer.class);
 
         infoFactory.setConstructor(new String[]{
             "uri",
             "componentContext",
             "userTransaction",
             "classLoader",
+            "webClassPath",
+            "configurationBaseUrl",
             "unshareableResources",
             "applicationManagedSecurityResources",
             "TransactionContextManager",
             "TrackedConnectionAssociator",
-            "Configuration",
             "JettyContainer",
         });
 
@@ -388,5 +406,4 @@
     public static GBeanInfo getGBeanInfo() {
         return GBEAN_INFO;
     }
-
 }

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppJACCContext.java
Wed Oct  6 17:13:19 2004
@@ -18,7 +18,9 @@
 package org.apache.geronimo.jetty;
 
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URI;
+import java.net.URL;
 import java.security.AccessControlContext;
 import java.security.AccessControlException;
 import java.security.Principal;
@@ -40,7 +42,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoFactory;
 import org.apache.geronimo.gbean.WaitingException;
-import org.apache.geronimo.kernel.config.ConfigurationParent;
 import org.apache.geronimo.naming.java.ReadOnlyContext;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.GeronimoSecurityException;
@@ -78,36 +79,48 @@
 
     private final String policyContextID;
     private final Security securityConfig;
+    private final JAASJettyPrincipal defaultPrincipal;
 
     private PolicyConfigurationFactory factory;
     private PolicyConfiguration policyConfiguration;
 
     private final Map roleDesignates = new HashMap();
-
-    private final JAASJettyPrincipal defaultPrincipal;
-
     private final PathMap constraintMap = new PathMap();
 
     private String formLoginPath;
 
     public JettyWebAppJACCContext() {
-        this(null, null, null, null, null, null, null, null, null, null, null, null);
+        policyContextID = null;
+        securityConfig = null;
+        defaultPrincipal = null;
     }
 
-    public JettyWebAppJACCContext(URI uri,
-            ReadOnlyContext compContext,
+    public JettyWebAppJACCContext(
+            URI uri,
+            ReadOnlyContext componentContext,
             UserTransactionImpl userTransaction,
             ClassLoader classLoader,
+            URI[] webClassPath,
+            URL configurationBaseUrl,
             Set unshareableResources,
             Set applicationManagedSecurityResources,
             String policyContextID,
             Security securityConfig,
             TransactionContextManager transactionContextManager,
-            TrackedConnectionAssociator associator,
-            ConfigurationParent config,
-            JettyContainer container) {
+            TrackedConnectionAssociator trackedConnectionAssociator,
+            JettyContainer jettyContainer) throws MalformedURLException {
 
-        super(uri, compContext, userTransaction, classLoader, unshareableResources, applicationManagedSecurityResources,
transactionContextManager, associator, config, container);
+        super(uri,
+                componentContext,
+                userTransaction,
+                classLoader,
+                webClassPath,
+                configurationBaseUrl,
+                unshareableResources,
+                applicationManagedSecurityResources,
+                transactionContextManager,
+                trackedConnectionAssociator,
+                jettyContainer);
 
         this.policyContextID = policyContextID;
         this.securityConfig = securityConfig;
@@ -139,8 +152,10 @@
      * Handler request.
      * Call each HttpHandler until request is handled.
      *
-     * @param pathInContext Path in context
-     * @param pathParams Path parameters such as encoded Session ID
+     * @param pathInContext path in context
+     * @param pathParams path parameters such as encoded Session ID
+     * @param httpRequest the request object
+     * @param httpResponse the response object
      */
     public void handle(String pathInContext,
             String pathParams,
@@ -479,21 +494,22 @@
     static {
         GBeanInfoFactory infoFactory = new GBeanInfoFactory("Jetty JACC WebApplication Context",
JettyWebAppJACCContext.class, JettyWebAppContext.GBEAN_INFO);
 
-        infoFactory.addAttribute("securityConfig", Security.class, true);
         infoFactory.addAttribute("policyContextID", String.class, true);
+        infoFactory.addAttribute("securityConfig", Security.class, true);
 
         infoFactory.setConstructor(new String[]{
             "uri",
             "componentContext",
             "userTransaction",
             "classLoader",
+            "webClassPath",
+            "configurationBaseUrl",
             "unshareableResources",
             "applicationManagedSecurityResources",
             "policyContextID",
             "securityConfig",
             "TransactionContextManager",
             "TrackedConnectionAssociator",
-            "Configuration",
             "JettyContainer",
         });
 

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Wed Oct  6 17:13:19 2004
@@ -19,15 +19,19 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.FileFilter;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.MalformedURLException;
+import java.net.URLClassLoader;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.LinkedList;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 import javax.management.AttributeNotFoundException;
@@ -243,25 +247,38 @@
         }
     }
 
-    public void initContext(EARContext earContext, Module webModule, ClassLoader cl) {
+    public void initContext(EARContext earContext, Module module, ClassLoader cl) {
         // web application do not add anything to the shared context
     }
 
     public String addGBeans(EARContext earContext, Module module, ClassLoader cl) throws
DeploymentException {
         WebModule webModule = (WebModule) module;
 
+        // construct the webClassLoader
+        URI[] webClassPath = getWebClassPath(earContext, webModule);
+        URI baseUri = earContext.getTargetFile(URI.create(webModule.getTargetPath() + "/")).toURI();
+        URL[] webClassPathURLs = new URL[webClassPath.length];
+        for (int i = 0; i < webClassPath.length; i++) {
+            URI path = baseUri.resolve(webClassPath[i]);
+            try {
+                webClassPathURLs[i] = path.toURL();
+            } catch (MalformedURLException e) {
+                throw new DeploymentException("Invalid web class path element: path=" + path
+ ", baseUri=" + baseUri);
+            }
+        }
+        ClassLoader webClassLoader = new URLClassLoader(webClassPathURLs, cl);
+
+
         WebAppType webApp = (WebAppType) webModule.getSpecDD();
         JettyWebAppType jettyWebApp = (JettyWebAppType) webModule.getVendorDD();
 
         if (jettyWebApp != null) {
             JettyGbeanType[] gbeans = jettyWebApp.getGbeanArray();
             for (int i = 0; i < gbeans.length; i++) {
-                GBeanHelper.addGbean(new JettyGBeanAdapter(gbeans[i]), cl, earContext);
+                GBeanHelper.addGbean(new JettyGBeanAdapter(gbeans[i]), webClassLoader, earContext);
             }
         }
 
-        URI configID = earContext.getConfigID();
-
         Properties nameProps = new Properties();
         nameProps.put("J2EEServer", earContext.getJ2EEServerName());
         nameProps.put("J2EEApplication", earContext.getJ2EEApplicationName());
@@ -275,22 +292,16 @@
         }
 
         UserTransaction userTransaction = new UserTransactionImpl();
-        ReadOnlyContext compContext = buildComponentContext(earContext, webModule, webApp,
jettyWebApp, userTransaction, cl);
+        ReadOnlyContext compContext = buildComponentContext(earContext, webModule, webApp,
jettyWebApp, userTransaction, webClassLoader);
 
         Security security = buildSecurityConfig(jettyWebApp);
 
         GBeanMBean gbean;
         try {
             if (security == null) {
-                gbean = new GBeanMBean(JettyWebAppContext.GBEAN_INFO, cl);
+                gbean = new GBeanMBean(JettyWebAppContext.GBEAN_INFO, webClassLoader);
             } else {
-                gbean = new GBeanMBean(JettyWebAppJACCContext.GBEAN_INFO, cl);
-            }
-
-            gbean.setAttribute("uri", URI.create(module.getTargetPath() + "/"));
-            gbean.setAttribute("contextPath", webModule.getContextRoot());
-            gbean.setAttribute("contextPriorityClassLoader", Boolean.valueOf(jettyWebApp.getContextPriorityClassloader()));
-            if (security != null) {
+                gbean = new GBeanMBean(JettyWebAppJACCContext.GBEAN_INFO, webClassLoader);
                 gbean.setAttribute("securityConfig", security);
 
                 String policyContextID;
@@ -301,18 +312,55 @@
                 }
                 gbean.setAttribute("policyContextID", policyContextID);
             }
+
+            gbean.setAttribute("uri", URI.create(module.getTargetPath() + "/"));
             gbean.setAttribute("componentContext", compContext);
             gbean.setAttribute("userTransaction", userTransaction);
+            gbean.setAttribute("webClassPath", webClassPath);
+            // unsharableResources, applicationManagedSecurityResources
             setResourceEnvironment(gbean, webApp.getResourceRefArray(), jettyWebApp.getResourceRefArray());
-            gbean.setReferencePattern("Configuration", new ObjectName("geronimo.config:name="
+ ObjectName.quote(configID.toString()))); // @todo this is used to resolve relative URIs,
we should fix this
-            gbean.setReferencePattern("JettyContainer", new ObjectName("*:type=WebContainer,container=Jetty"));
// @todo configurable
+
+            gbean.setAttribute("contextPath", webModule.getContextRoot());
+            gbean.setAttribute("contextPriorityClassLoader", Boolean.valueOf(jettyWebApp.getContextPriorityClassloader()));
+
             gbean.setReferencePattern("TransactionContextManager", earContext.getTransactionContextManagerObjectName());
             gbean.setReferencePattern("TrackedConnectionAssociator", earContext.getConnectionTrackerObjectName());
+            gbean.setReferencePattern("JettyContainer", new ObjectName("*:type=WebContainer,container=Jetty"));
// @todo configurable
         } catch (Exception e) {
             throw new DeploymentException("Unable to initialize webapp GBean", e);
         }
         earContext.addGBean(webModuleName, gbean);
         return null;
+    }
+
+    private static URI[] getWebClassPath(EARContext earContext, WebModule webModule) {
+        LinkedList webClassPath = new LinkedList();
+        File baseDir = earContext.getTargetFile(URI.create(webModule.getTargetPath() + "/"));
+        File webInfDir = new File(baseDir, "WEB-INF");
+
+        // check for a classes dir
+        File classesDir = new File(webInfDir, "classes");
+        if (classesDir.isDirectory()) {
+            webClassPath.add(URI.create("WEB-INF/classes/"));
+        }
+
+        // add all of the libs
+        File libDir = new File(webInfDir, "lib");
+        if (libDir.isDirectory()) {
+            File[] libs = libDir.listFiles(new FileFilter() {
+                public boolean accept(File file) {
+                    return file.isFile() && file.getName().endsWith(".jar");
+                }
+            });
+
+            if (libs != null) {
+                for (int i = 0; i < libs.length; i++) {
+                    File lib = libs[i];
+                    webClassPath.add(URI.create("WEB-INF/lib/" + lib.getName()));
+                }
+            }
+        }
+        return (URI[]) webClassPath.toArray(new URI[webClassPath.size()]);
     }
 
     private ReadOnlyContext buildComponentContext(EARContext earContext, WebModule webModule,
WebAppType webApp, JettyWebAppType jettyWebApp, UserTransaction userTransaction, ClassLoader
cl) throws DeploymentException {

Modified: geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/ApplicationTest.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/ApplicationTest.java	(original)
+++ geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/ApplicationTest.java	Wed
Oct  6 17:13:19 2004
@@ -60,17 +60,19 @@
     }
 
     public void testApplication() throws Exception {
-        URL url = Thread.currentThread().getContextClassLoader().getResource("deployables/war1/");
         GBeanMBean app = new GBeanMBean(JettyWebAppContext.GBEAN_INFO);
-        app.setAttribute("uri", URI.create(url.toString()));
-        app.setAttribute("contextPath", "/test");
+        app.setAttribute("uri", URI.create("war1/"));
         app.setAttribute("componentContext", null);
         UserTransactionImpl userTransaction = new UserTransactionImpl();
         app.setAttribute("userTransaction", userTransaction);
-        app.setReferencePatterns("Configuration", Collections.EMPTY_SET);
-        app.setReferencePatterns("JettyContainer", containerPatterns);
+        app.setAttribute("webClassPath", new URI[0]);
+        app.setAttribute("configurationBaseUrl", Thread.currentThread().getContextClassLoader().getResource("deployables/"));
         app.setReferencePattern("TransactionContextManager", tcmName);
         app.setReferencePattern("TrackedConnectionAssociator", tcaName);
+        app.setReferencePatterns("JettyContainer", containerPatterns);
+
+        app.setAttribute("contextPath", "/test");
+
         start(appName, app);
 
 

Modified: geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java	(original)
+++ geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java	Wed
Oct  6 17:13:19 2004
@@ -103,20 +103,22 @@
 
         securityConfig.getRoleMappings().add(role);
 
-        URL url = Thread.currentThread().getContextClassLoader().getResource("deployables/war3/");
         GBeanMBean app = new GBeanMBean(JettyWebAppJACCContext.GBEAN_INFO);
-        app.setAttribute("uri", URI.create(url.toString()));
-        app.setAttribute("contextPath", "/test");
+
+        app.setAttribute("uri", URI.create("war3/"));
         app.setAttribute("componentContext", null);
         UserTransactionImpl userTransaction = new UserTransactionImpl();
         app.setAttribute("userTransaction", userTransaction);
+        app.setAttribute("webClassPath", new URI[0]);
+        app.setAttribute("configurationBaseUrl", Thread.currentThread().getContextClassLoader().getResource("deployables/"));
         app.setAttribute("securityConfig", securityConfig);
         app.setAttribute("policyContextID", "TEST");
-        app.setReferencePatterns("Configuration", Collections.EMPTY_SET);
-        app.setReferencePatterns("JettyContainer", containerPatterns);
+
+        app.setAttribute("contextPath", "/test");
+
         app.setReferencePattern("TransactionContextManager", tcmName);
         app.setReferencePattern("TrackedConnectionAssociator", tcaName);
-        app.setReferencePattern("TrackedConnectionAssociator", tcaName);
+        app.setReferencePatterns("JettyContainer", containerPatterns);
         start(appName, app);
 
         HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
Wed Oct  6 17:13:19 2004
@@ -172,6 +172,12 @@
             // create and initialize GBeans
             gbeans = loadGBeans(gbeanState, classLoader);
 
+            // set configurationBaseUrl attribute on each gbean
+            for (Iterator i = gbeans.values().iterator(); i.hasNext();) {
+                GBeanMBean gbean = (GBeanMBean) i.next();
+                setGBeanBaseUrl(gbean, baseURL);
+            }
+
             // register all the GBeans
             for (Iterator i = gbeans.entrySet().iterator(); i.hasNext();) {
                 Map.Entry entry = (Map.Entry) i.next();
@@ -196,6 +202,18 @@
         }
 
         log.info("Started configuration " + id);
+    }
+
+    private static void setGBeanBaseUrl(GBeanMBean gbean, URL baseUrl) throws ReflectionException,
AttributeNotFoundException {
+        GBeanInfo gbeanInfo = gbean.getGBeanInfo();
+        Set attributes = gbeanInfo.getAttributes();
+        for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {
+            GAttributeInfo attribute = (GAttributeInfo) iterator.next();
+            if (attribute.getName().equals("configurationBaseUrl") && attribute.getType().equals("java.net.URL"))
{
+                gbean.setAttribute("configurationBaseUrl", baseUrl);
+                return;
+            }
+        }
     }
 
     public void doStop() {

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationParent.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationParent.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationParent.java
Wed Oct  6 17:13:19 2004
@@ -17,13 +17,11 @@
 
 package org.apache.geronimo.kernel.config;
 
-import java.net.URL;
+
 
 /**
  * @version $Rev$ $Date$
  */
 public interface ConfigurationParent {
     ClassLoader getClassLoader();
-
-    URL getBaseURL();
 }

Mime
View raw message