geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 53809 - in geronimo/trunk/modules: client-builder/src/java/org/apache/geronimo/client/builder connector/src/java/org/apache/geronimo/connector/deployment deployment/src/java/org/apache/geronimo/deployment deployment/src/java/org/apache/geronimo/deployment/util j2ee/src/java/org/apache/geronimo/j2ee/deployment jetty/src/java/org/apache/geronimo/jetty/deployment
Date Tue, 05 Oct 2004 17:17:50 GMT
Author: dain
Date: Tue Oct  5 10:17:41 2004
New Revision: 53809

Modified:
   geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Log:
Added support for manifest class path entries


Modified: geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
==============================================================================
--- 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
Tue Oct  5 10:17:41 2004
@@ -28,6 +28,8 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.HashSet;
+import java.util.StringTokenizer;
+import java.util.zip.ZipEntry;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
@@ -36,6 +38,7 @@
 import javax.naming.Reference;
 
 import org.apache.geronimo.deployment.DeploymentException;
+import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.service.GBeanHelper;
 import org.apache.geronimo.deployment.util.NestedJarFile;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
@@ -380,8 +383,8 @@
                     appClientDeploymentContext.addDependency(getDependencyURI(dependencies[i]));
                 }
 
-                appClientDeploymentContext.addManifestClassPath(appClientModule.getEarFile(),
appClientModule, moduleFile, moduleBase);
-
+                // add manifest class path entries to the app client context
+                addManifestClassPath(appClientDeploymentContext, appClientModule.getEarFile(),
moduleFile, moduleBase);
 
                 // get the classloader
                 ClassLoader appClientClassLoader = appClientDeploymentContext.getClassLoader(repository);
@@ -454,6 +457,7 @@
                     appClienContainerGBean.setAttribute("mainClassName", mainClasss);
                     appClienContainerGBean.setAttribute("appClientModuleName", appClientModuleName);
                     appClienContainerGBean.setReferencePattern("JNDIContext", new ObjectName("geronimo.client:type=StaticJndiContext"));
+                    appClienContainerGBean.setReferencePattern("TransactionContextManager",
new ObjectName("geronimo.client:type=TransactionContextManager"));
                 } catch (Exception e) {
                     throw new DeploymentException("Unable to initialize AppClientModule GBean",
e);
                 }
@@ -482,6 +486,73 @@
                 throw new DeploymentException(e);
             }
             throw new Error(e);
+        }
+    }
+
+    public void addManifestClassPath(DeploymentContext deploymentContext, JarFile earFile,
JarFile jarFile, URI jarFileLocation) throws DeploymentException {
+        Manifest manifest = null;
+        try {
+            manifest = jarFile.getManifest();
+        } catch (IOException e) {
+            throw new DeploymentException("Could not read manifest: " + jarFileLocation);
+        }
+
+        if (manifest == null) {
+            return;
+        }
+        String manifestClassPath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
+        if (manifestClassPath == null) {
+            return;
+        }
+
+        for (StringTokenizer tokenizer = new StringTokenizer(manifestClassPath, " "); tokenizer.hasMoreTokens();)
{
+            String path = tokenizer.nextToken();
+
+            URI pathUri;
+            try {
+                pathUri = new URI(path);
+            } catch (URISyntaxException e) {
+                throw new DeploymentException("Invalid manifest classpath entry: jarFile="
+ jarFileLocation + ", path=" + path);
+            }
+
+            if (!pathUri.getPath().endsWith(".jar")) {
+                throw new DeploymentException("Manifest class path entries must end with
the .jar extension (J2EE 1.4 Section 8.2): jarFile=" + jarFileLocation + ", path=" + path);
+            }
+            if (pathUri.isAbsolute()) {
+                throw new DeploymentException("Manifest class path entries must be relative
(J2EE 1.4 Section 8.2): jarFile=" + jarFileLocation + ", path=" + path);
+            }
+
+            // determine the target file
+            URI classPathJarLocation = jarFileLocation.resolve(pathUri);
+            File classPathFile = deploymentContext.getTargetFile(classPathJarLocation);
+
+            // we only recuse if the path entry is not already in the output context
+            // this will work for all current cases, but may not work in the future
+            if (!classPathFile.exists()) {
+                // check if the path exists in the earFile
+                ZipEntry entry = earFile.getEntry(classPathJarLocation.getPath());
+                if (entry == null) {
+                    throw new DeploymentException("Cound not find manifest class path entry:
jarFile=" + jarFileLocation + ", path=" + path);
+                }
+
+                try {
+                    // copy the file into the output context
+                    deploymentContext.addFile(classPathJarLocation, earFile, entry);
+                } catch (IOException e) {
+                    throw new DeploymentException("Cound not copy manifest class path entry
into configuration: jarFile=" + jarFileLocation + ", path=" + path, e);
+                }
+
+                JarFile classPathJarFile = null;
+                try {
+                    classPathJarFile = new JarFile(classPathFile);
+                } catch (IOException e) {
+                    throw new DeploymentException("Manifest class path entries must be a
valid jar file (J2EE 1.4 Section 8.2): jarFile=" + jarFileLocation + ", path=" + path, e);
+                }
+
+
+                // add the client jars of this class path jar
+                addManifestClassPath(deploymentContext, earFile, classPathJarFile, classPathJarLocation);
+            }
         }
     }
 

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Tue Oct  5 10:17:41 2004
@@ -189,10 +189,14 @@
 
     public void installModule(JarFile earFile, EARContext earContext, Module module) throws
DeploymentException {
         try {
-            URI targetURI = URI.create(module.getTargetPath() + "/");
-
             JarFile moduleFile = module.getModuleFile();
 
+            // add the manifest classpath entries declared in the connector to the class
loader
+            // we have to explicitly add these since we are unpacking the connector module
+            // and the url class loader will not pick up a manifiest from an unpacked dir
+            earContext.addManifestClassPath(moduleFile, URI.create(module.getTargetPath()));
+
+            URI targetURI = URI.create(module.getTargetPath() + "/");
             Enumeration entries = moduleFile.entries();
             while (entries.hasMoreElements()) {
                 ZipEntry entry = (ZipEntry) entries.nextElement();

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
Tue Oct  5 10:17:41 2004
@@ -29,6 +29,7 @@
 import java.net.URL;
 import java.net.MalformedURLException;
 import java.net.URLClassLoader;
+import java.net.URISyntaxException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -37,7 +38,10 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.ArrayList;
+import java.util.StringTokenizer;
 import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.jar.Attributes;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 import javax.management.MalformedObjectNameException;
@@ -178,6 +182,44 @@
         classPath.add(targetPath);
     }
 
+    public void addManifestClassPath(JarFile moduleFile, URI moduleBaseUri) throws DeploymentException
{
+        Manifest manifest = null;
+        try {
+            manifest = moduleFile.getManifest();
+        } catch (IOException e) {
+            throw new DeploymentException("Could not read manifest: " + moduleBaseUri);
+        }
+
+        if (manifest == null) {
+            return;
+        }
+        String manifestClassPath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
+        if (manifestClassPath == null) {
+            return;
+        }
+
+        for (StringTokenizer tokenizer = new StringTokenizer(manifestClassPath, " "); tokenizer.hasMoreTokens();)
{
+            String path = tokenizer.nextToken();
+
+            URI pathUri;
+            try {
+                pathUri = new URI(path);
+            } catch (URISyntaxException e) {
+                throw new DeploymentException("Invalid manifest classpath entry: module="
+ moduleBaseUri + ", path=" + path);
+            }
+
+            if (!pathUri.getPath().endsWith(".jar")) {
+                throw new DeploymentException("Manifest class path entries must end with
the .jar extension (J2EE 1.4 Section 8.2): module=" + moduleBaseUri);
+            }
+            if (pathUri.isAbsolute()) {
+                throw new DeploymentException("Manifest class path entries must be relative
(J2EE 1.4 Section 8.2): moduel=" + moduleBaseUri);
+            }
+
+            URI targetUri = moduleBaseUri.resolve(pathUri);
+            classPath.add(targetUri);
+        }
+    }
+
     public void addFile(URI targetPath, ZipFile zipFile, ZipEntry zipEntry) throws IOException
{
         addFile(getTargetFile(targetPath), zipFile, zipEntry);
     }
@@ -241,7 +283,7 @@
         }
     }
 
-    private File getTargetFile(URI targetPath) {
+    public File getTargetFile(URI targetPath) {
         assert !targetPath.isAbsolute() : "targetPath is absolute";
         assert !targetPath.isOpaque() : "targetPath is opaque";
         return new File(baseUri.resolve(targetPath));

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java
Tue Oct  5 10:17:41 2004
@@ -37,7 +37,7 @@
 import java.util.zip.ZipEntry;
 
 /**
- * @version $Revision$ $Date$
+ * @version $Rev$ $Date$
  */
 public final class DeploymentUtil {
     private DeploymentUtil() {

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java
(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java
Tue Oct  5 10:17:41 2004
@@ -17,22 +17,15 @@
 package org.apache.geronimo.j2ee.deployment;
 
 import java.io.File;
-import java.io.IOException;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.DeploymentException;
-import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 
@@ -162,51 +155,5 @@
 
     public String getResourceAdapterModule(String resourceAdapterName) {
         return (String) resourceAdapterModules.get(resourceAdapterName);
-    }
-
-    public void addManifestClassPath(JarFile earFile, Module module, JarFile jarFile, URI
baseUri) throws DeploymentException, URISyntaxException, IOException {
-        String classPath = null;
-        try {
-            Manifest manifest = jarFile.getManifest();
-            if (manifest == null) {
-                return;
-            }
-            classPath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
-            if (classPath == null) {
-                return;
-            }
-        } catch (IOException e) {
-            throw new DeploymentException("Could not get manifest from app client module:
" + jarFile.getName());
-        }
-
-        for (StringTokenizer tokenizer = new StringTokenizer(classPath, " "); tokenizer.hasMoreTokens();)
{
-            URI uri = new URI(tokenizer.nextToken());
-            if (!uri.getPath().endsWith(".jar")) {
-                throw new DeploymentException("Manifest class path entries must end with
the .jar extension (J2EE 1.4 Section 8.2)");
-            }
-            if (uri.isAbsolute()) {
-                throw new DeploymentException("Manifest class path entries must be relative
(J2EE 1.4 Section 8.2)");
-            }
-
-            URI path = baseUri.resolve(uri);
-            // todo no need to copy this into a temp file...
-            File classPathFile = DeploymentUtil.toFile(earFile, path.getPath());
-
-            // before going to the work of adding this file, let's make sure it really is
a jar file
-            JarFile classPathJar = null;
-            try {
-                classPathJar = new JarFile(classPathFile);
-
-                // add this class path jar to the output context
-                addInclude(path, classPathFile);
-
-                // add the client jars of this class path jar
-                addManifestClassPath(earFile, module, classPathJar, path);
-            } catch (IOException e) {
-                throw new DeploymentException("Manifest class path entries must be a valid
jar file (J2EE 1.4 Section 8.2)", e);
-            } finally {
-                DeploymentUtil.close(classPathJar);
-            }
-        }
     }
 }

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
Tue Oct  5 10:17:41 2004
@@ -228,6 +228,11 @@
                 }
             }
 
+            // add the manifest classpath entries declared in the war to the class loader
+            // we have to explicitly add these since we are unpacking the web module
+            // and the url class loader will not pick up a manifiest from an unpacked dir
+            earContext.addManifestClassPath(warFile, URI.create(module.getTargetPath()));
+
             // add the dependencies declared in the geronimo-jetty.xml file
             JettyWebAppType jettyWebApp = (JettyWebAppType) module.getVendorDD();
             JettyDependencyType[] dependencies = jettyWebApp.getDependencyArray();

Mime
View raw message