geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r558910 - in /geronimo/server/branches/2.0/modules: geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ geronimo-deployment/src/test/java/org/apache/geronimo/deployment/ geronimo-web-2.5-builder/src/main/java/org/apache/geroni...
Date Tue, 24 Jul 2007 01:41:36 GMT
Author: kevan
Date: Mon Jul 23 18:41:35 2007
New Revision: 558910

URL: http://svn.apache.org/viewvc?view=rev&rev=558910
Log:
GERONIMO-3307 Port of djencks change from trunk to branches/2.0. Clear up test case meaning
a bit, better error message, and use the right DeploymentContext for finding the war manifest
classpath

Modified:
    geronimo/server/branches/2.0/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
    geronimo/server/branches/2.0/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/DeploymentContextTest.java
    geronimo/server/branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java

Modified: geronimo/server/branches/2.0/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java?view=diff&rev=558910&r1=558909&r2=558910
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/server/branches/2.0/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
Mon Jul 23 18:41:35 2007
@@ -265,7 +265,11 @@
 
         public JarFile newJarFile(URI relativeURI) throws IOException {
             File targetFile = getTargetFile(relativeURI);
-            return new JarFile(targetFile);
+            try {
+                return new JarFile(targetFile);
+            } catch (IOException e) {
+                throw (IOException)new IOException("Could not create JarFile for file: "
+ targetFile).initCause(e);
+            }
         }
 
         public String getManifestClassPath(JarFile jarFile) throws IOException {

Modified: geronimo/server/branches/2.0/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/DeploymentContextTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/DeploymentContextTest.java?view=diff&rev=558910&r1=558909&r2=558910
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/DeploymentContextTest.java
(original)
+++ geronimo/server/branches/2.0/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/DeploymentContextTest.java
Mon Jul 23 18:41:35 2007
@@ -112,14 +112,24 @@
     //test the getCompleteManifestClassPath method
 
     private static class MockJarFile extends JarFile {
+        private final URI relativeURI;
         private final String manifestClasspath;
 
-
-        public MockJarFile(String manifestClasspath) throws IOException {
+        /**
+         * Constructor
+         * @param relativeURI "path" of "jar" within "ear"
+         * @param manifestClasspath manifest classpath of jar. Entries should be relative
to root of "ear"
+         * @throws IOException ain't gonna happen.
+         */
+        public MockJarFile(URI relativeURI, String manifestClasspath) throws IOException
{
             super(DeploymentUtil.DUMMY_JAR_FILE);
+            this.relativeURI = relativeURI;
             this.manifestClasspath = manifestClasspath;
         }
 
+        public URI getRelativeURI() {
+            return relativeURI;
+        }
 
         public String getManifestClasspath() {
             return manifestClasspath;
@@ -136,7 +146,7 @@
 
         public JarFile newJarFile(URI relativeURI) throws IOException {
             String manifestcp = data.get(relativeURI);
-            return new MockJarFile(manifestcp);
+            return new MockJarFile(relativeURI, manifestcp);
         }
 
         public String getManifestClassPath(JarFile jarFile) throws IOException {
@@ -145,9 +155,7 @@
     }
     
     public void testManifestClassPath1() throws Exception {
-        //remember, the constructor takes the manifest classpath, not the location
-        JarFile start = new MockJarFile("lib1.jar");
-        URI moduleBaseURI = URI.create("ejb.jar");
+        MockJarFile start = new MockJarFile(URI.create("ejb.jar"), "lib1.jar");
         URI resolutionURI = URI.create(".");
         ModuleList exclusions = new ModuleList();
         Map<URI, String> data = new HashMap<URI, String>();
@@ -156,13 +164,12 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
+        context.getCompleteManifestClassPath(start, start.getRelativeURI(), resolutionURI,
classPathList, exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(2, classPathList.size());
     }
 
     public void testManifestClassPath2() throws Exception {
-        JarFile start = new MockJarFile("../../lib1/lib1/lib1.jar");
-        URI moduleBaseURI = URI.create("ejb1/ejb1/ejb1.jar");
+        MockJarFile start = new MockJarFile(URI.create("ejb1/ejb1/ejb1.jar"), "../../lib1/lib1/lib1.jar");
         URI resolutionURI = URI.create(".");
         ModuleList exclusions = new ModuleList();
         Map<URI, String> data = new HashMap<URI, String>();
@@ -173,7 +180,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
+        context.getCompleteManifestClassPath(start, start.getRelativeURI(), resolutionURI,
classPathList, exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(4, classPathList.size());
         assertEquals("lib1/lib1/lib1.jar", classPathList.get(0));
         assertEquals("lib2/lib2.jar", classPathList.get(1));
@@ -182,8 +189,7 @@
     }
 
     public void testManifestClassPathWar1() throws Exception {
-        JarFile start = new MockJarFile("lib1.jar");
-        URI moduleBaseURI = URI.create("war1.war");
+        MockJarFile start = new MockJarFile(URI.create("war1.war"), "lib1.jar");
         URI resolutionURI = URI.create("../");
         ModuleList exclusions = new ModuleList();
         Map<URI, String> data = new HashMap<URI, String>();
@@ -192,7 +198,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
+        context.getCompleteManifestClassPath(start, start.getRelativeURI(), resolutionURI,
classPathList, exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(2, classPathList.size());
         assertEquals("../lib1.jar", classPathList.get(0));
         assertEquals("../lib2.jar", classPathList.get(1));
@@ -200,8 +206,7 @@
     }
 
     public void testManifestClassPathWar2() throws Exception {
-        JarFile start = new MockJarFile("../../lib1/lib1/lib1.jar");
-        URI moduleBaseURI = URI.create("war1/war1/war1.war");
+        MockJarFile start = new MockJarFile(URI.create("war1/war1/war1.war"), "../../lib1/lib1/lib1.jar");
         URI resolutionURI = URI.create("../../../");
         ModuleList exclusions = new ModuleList();
         Map<URI, String> data = new HashMap<URI, String>();
@@ -212,7 +217,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
+        context.getCompleteManifestClassPath(start, start.getRelativeURI(), resolutionURI,
classPathList, exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(4, classPathList.size());
         assertEquals("../../../lib1/lib1/lib1.jar", classPathList.get(0));
         assertEquals("../../../lib2/lib2/lib2.jar", classPathList.get(1));
@@ -221,8 +226,7 @@
     }
 
     public void testManifestClassPathWar3() throws Exception {
-        JarFile start = new MockJarFile("../../lib1/lib1/lib1.jar");
-        URI moduleBaseURI = URI.create("war1/war1/war1.war");
+        MockJarFile start = new MockJarFile(URI.create("war1/war1/war1.war"), "../../lib1/lib1/lib1.jar");
         URI resolutionURI = URI.create("../../../");
         ModuleList exclusions = new ModuleList();
         Map<URI, String> data = new HashMap<URI, String>();
@@ -233,7 +237,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
+        context.getCompleteManifestClassPath(start, start.getRelativeURI(), resolutionURI,
classPathList, exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(4, classPathList.size());
         assertEquals("../../../lib1/lib1/lib1.jar", classPathList.get(0));
         assertEquals("../../../lib2/lib2.jar", classPathList.get(1));
@@ -242,8 +246,7 @@
     }
 
     public void testManifestClassPathExcludeModules1() throws Exception {
-        JarFile start = new MockJarFile("lib1.jar");
-        URI moduleBaseURI = URI.create("ejb1.jar");
+        MockJarFile start = new MockJarFile(URI.create("ejb1.jar"), "lib1.jar");
         URI resolutionURI = URI.create(".");
         ModuleList exclusions = new ModuleList();
         exclusions.add("ejb1.jar");
@@ -256,7 +259,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
+        context.getCompleteManifestClassPath(start, start.getRelativeURI(), resolutionURI,
classPathList, exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(2, classPathList.size());
     }
 

Modified: geronimo/server/branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?view=diff&rev=558910&r1=558909&r2=558910
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
(original)
+++ geronimo/server/branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
Mon Jul 23 18:41:35 2007
@@ -329,11 +329,10 @@
         ModuleList moduleLocations = (ModuleList) module.getRootEarContext().getGeneralData().get(ModuleList.class);
         URI baseUri = URI.create(module.getTargetPath());
         URI resolutionUri = invertURI(baseUri);
-        moduleContext.getCompleteManifestClassPath(module.getModuleFile(), baseUri, resolutionUri,
manifestcp, moduleLocations);
+        earContext.getCompleteManifestClassPath(module.getModuleFile(), baseUri, resolutionUri,
manifestcp, moduleLocations);
 
 
         WebAppType webApp = (WebAppType) module.getSpecDD();
-//      makeMetadataComplete(webApp, module);
         if ((webApp.getSecurityConstraintArray().length > 0 || webApp.getSecurityRoleArray().length
> 0) &&
                 !hasSecurityRealmName) {
             throw new DeploymentException("web.xml for web app " + module.getName() + " includes
security elements but Geronimo deployment plan is not provided or does not contain <security-realm-name>
element necessary to configure security accordingly.");
@@ -817,8 +816,6 @@
         //N.B. we use the ear context which has all the gbeans we could possibly be looking
up from this ear.
         //nope, persistence units can be in the war.
         //This means that you cannot use the default environment of the web builder to add
configs that will be searched.
-        Configuration earConfiguration = earContext.getConfiguration();
-        Configuration localConfiguration = moduleContext.getConfiguration();
         getNamingBuilders().buildNaming(webApp, vendorPlan, webModule, buildingContext);
 
         Map compContext = NamingBuilder.JNDI_KEY.get(buildingContext);



Mime
View raw message