You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2005/09/25 05:38:34 UTC

svn commit: r291373 - in /geronimo/trunk: modules/assembly/ modules/deploy-tool/src/java/org/apache/geronimo/deployment/ modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/ modules/deployment/src/java/org/apache/geronimo/deployment/ module...

Author: djencks
Date: Sat Sep 24 20:38:18 2005
New Revision: 291373

URL: http://svn.apache.org/viewcvs?rev=291373&view=rev
Log:
GERONIMO-310 Add support for extension directory: normally <geronimo.home>/lib/ext

Modified:
    geronimo/trunk/modules/assembly/maven.xml
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/Bootstrap.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandPackage.java
    geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLineManifest.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java
    geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java

Modified: geronimo/trunk/modules/assembly/maven.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/maven.xml?rev=291373&r1=291372&r2=291373&view=diff
==============================================================================
--- geronimo/trunk/modules/assembly/maven.xml (original)
+++ geronimo/trunk/modules/assembly/maven.xml Sat Sep 24 20:38:18 2005
@@ -94,6 +94,7 @@
         <j:set var="libDir" value="${geronimo.assembly.dir}/lib"/>
         <ant:mkdir dir="${libDir}"/>
         <ant:mkdir dir="${libDir}/endorsed"/>
+        <ant:mkdir dir="${libDir}/ext"/>
 
         <j:forEach var="artifact" items="${pom.artifacts}">
             <j:set var="dependency" value="${artifact.dependency}"/>
@@ -377,6 +378,8 @@
             <ant:arg value="org.apache.geronimo.system.main.Daemon"/>
             <ant:arg value="--endorsedDirs"/>
             <ant:arg value="lib/endorsed"/>
+            <ant:arg value="--extensionDirs"/>
+            <ant:arg value="lib/ext"/>
             <ant:arg value="--install"/>
             <ant:arg value="target/plan/system-plan.xml"/>
             <ant:arg value="${geronimo.assembly.dir}/bin/server.jar"/>

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/Bootstrap.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/Bootstrap.java?rev=291373&r1=291372&r2=291373&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/Bootstrap.java (original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/Bootstrap.java Sat Sep 24 20:38:18 2005
@@ -44,6 +44,7 @@
     private String j2eeDeployerPlan;
     private String deployerClassPath;
     private String deployerEndorsedDirs;
+    private String deployerExtensionDirs;
     private String deployerGBean;
     private String deploymentFactory;
 
@@ -103,6 +104,14 @@
         this.deployerEndorsedDirs = deployerEndorsedDirs;
     }
 
+    public String getDeployerExtensionDirs() {
+        return deployerExtensionDirs;
+    }
+
+    public void setDeployerExtensionDirs(String deployerExtensionDirs) {
+        this.deployerExtensionDirs = deployerExtensionDirs;
+    }
+
     public String getDeployerGBean() {
         return deployerGBean;
     }
@@ -145,6 +154,7 @@
             mainAttributes.putValue(CommandLineManifest.MAIN_METHOD.toString(), "deploy");
             mainAttributes.putValue(CommandLineManifest.CONFIGURATIONS.toString(), j2eeDeployerConfig.getConfigId());
             mainAttributes.putValue(CommandLineManifest.ENDORSED_DIRS.toString(), deployerEndorsedDirs);
+            mainAttributes.putValue(CommandLineManifest.EXTENSION_DIRS.toString(), deployerExtensionDirs);
 
             // attribute that indicates to a JSR-88 tool that we have a Deployment factory
             mainAttributes.putValue("J2EE-DeploymentFactory-Implementation-Class", deploymentFactory);
@@ -172,7 +182,7 @@
                 }
                 throw new Error(e);
             }
-            
+
             //get the domain and server from the parent xml config
             String domain = deployerSystemConfig.getDomain();
             String server = deployerSystemConfig.getServer();

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandPackage.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandPackage.java?rev=291373&r1=291372&r2=291373&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandPackage.java (original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandPackage.java Sat Sep 24 20:38:18 2005
@@ -51,35 +51,40 @@
     }
 
     public void execute(PrintWriter out, ServerConnection connection, String[] argArray) throws DeploymentException {
-        if(connection.isOnline()) {
+        if (connection.isOnline()) {
             throw new DeploymentException("This command cannot be run when the server is running.  Make sure the server is shut down first.");
         }
 
         String classPath = null;
         String mainClass = null;
         String endorsedDirs = null;
+        String extensionDirs = null;
         boolean install = false;
 
         // Read off the optional arguments (clasPath, mainClass, endorsedDirs, and install)
         LinkedList args = new LinkedList(Arrays.asList(argArray));
         for (Iterator iterator = args.iterator(); iterator.hasNext();) {
             String arg = (String) iterator.next();
-            if(arg.equals("--classPath")) {
+            if (arg.equals("--classPath")) {
                 iterator.remove();
                 classPath = (String) iterator.next();
                 iterator.remove();
-            } else if(arg.equals("--mainClass")) {
+            } else if (arg.equals("--mainClass")) {
                 iterator.remove();
                 mainClass = (String) iterator.next();
                 iterator.remove();
-            } else if(arg.equals("--endorsedDirs")) {
+            } else if (arg.equals("--endorsedDirs")) {
                 iterator.remove();
                 endorsedDirs = (String) iterator.next();
                 iterator.remove();
-            } else if(arg.equals("--install")) {
+            } else if (arg.equals("--extensionDirs")) {
+                iterator.remove();
+                extensionDirs = (String) iterator.next();
+                iterator.remove();
+            } else if (arg.equals("--install")) {
                 iterator.remove();
                 install = true;
-            } else if(arg.startsWith("--")) {
+            } else if (arg.startsWith("--")) {
                 throw new DeploymentSyntaxException("Invalid option '" + arg + "'");
             } else {
                 break;
@@ -89,12 +94,12 @@
         // if we have any other options on the comman line they are invalid
         for (Iterator iterator = args.iterator(); iterator.hasNext();) {
             String arg = (String) iterator.next();
-            if(arg.startsWith("--")) {
+            if (arg.startsWith("--")) {
                 throw new DeploymentSyntaxException("All command line options must appear before module, plan or packageFile: " + arg);
             }
         }
 
-        if(args.isEmpty()) {
+        if (args.isEmpty()) {
             throw new DeploymentSyntaxException("No fileName specified for package command");
         }
 
@@ -102,31 +107,31 @@
         File packageFile;
         packageFile = new File((String) args.removeLast());
         File parent = packageFile.getAbsoluteFile().getParentFile();
-        if(!parent.exists() || !parent.canWrite()) {
-            throw new DeploymentSyntaxException("Cannot write to output file "+packageFile.getAbsolutePath());
+        if (!parent.exists() || !parent.canWrite()) {
+            throw new DeploymentSyntaxException("Cannot write to output file " + packageFile.getAbsolutePath());
         }
 
         // Read off the plan and module
         File module = null;
         File plan = null;
-        if(!args.isEmpty()) {
+        if (!args.isEmpty()) {
             // if the arg is a directory or jar file, it must be the module; otherwise it is the plan
             File test = new File((String) args.removeLast()).getAbsoluteFile();
-            if(DeployUtils.isJarFile(test) || test.isDirectory()) {
+            if (DeployUtils.isJarFile(test) || test.isDirectory()) {
                 module = test;
             } else {
                 plan = test;
             }
         }
-        if(!args.isEmpty()) {
+        if (!args.isEmpty()) {
             File test = new File((String) args.removeLast()).getAbsoluteFile();
-            if(DeployUtils.isJarFile(test) || test.isDirectory()) {
-                if(module != null) {
+            if (DeployUtils.isJarFile(test) || test.isDirectory()) {
+                if (module != null) {
                     throw new DeploymentSyntaxException("Module and plan cannot both be JAR files or directories!");
                 }
                 module = test;
             } else {
-                if(plan != null) {
+                if (plan != null) {
                     throw new DeploymentSyntaxException("Module or plan must be a JAR file or directory!");
                 }
                 plan = test;
@@ -134,20 +139,20 @@
         }
 
         // are there extra left over args on the command prompt
-        if(!args.isEmpty()) {
+        if (!args.isEmpty()) {
             throw new DeploymentSyntaxException("Too many arguments for package command");
         }
 
         // invoke the deployer
-        List list = (List) connection.invokeOfflineDeployer(
-                new Object[]{
-                    plan,
-                    module,
-                    packageFile,
-                    install ? Boolean.TRUE : Boolean.FALSE,
-                    mainClass,
-                    classPath,
-                    endorsedDirs},
+        List list = (List) connection.invokeOfflineDeployer(new Object[]{
+            plan,
+            module,
+            packageFile,
+            install ? Boolean.TRUE : Boolean.FALSE,
+            mainClass,
+            classPath,
+            endorsedDirs,
+            extensionDirs},
                 new String[]{
                     File.class.getName(),
                     File.class.getName(),
@@ -155,11 +160,12 @@
                     boolean.class.getName(),
                     String.class.getName(),
                     String.class.getName(),
+                    String.class.getName(),
                     String.class.getName()});
 
         // print the configurations created
         for (int j = 0; j < list.size(); j++) {
-            out.println("Packaged configuration "+list.get(j)+" to "+packageFile);
+            out.println("Packaged configuration " + list.get(j) + " to " + packageFile);
         }
     }
 }

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java?rev=291373&r1=291372&r2=291373&view=diff
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java (original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java Sat Sep 24 20:38:18 2005
@@ -84,7 +84,7 @@
         }
 
         try {
-            return deploy(planFile, moduleFile, null, true, null, null, null);
+            return deploy(planFile, moduleFile, null, true, null, null, null, null);
         } catch (DeploymentException e) {
             log.debug("Deployment failed: plan=" + planFile +", module=" + originalModuleFile, e);
             throw cleanseDeploymentException(e);
@@ -105,7 +105,7 @@
         }
     }
 
-    public List deploy(File planFile, File moduleFile, File targetFile, boolean install, String mainClass, String classPath, String endorsedDirs) throws DeploymentException {
+    public List deploy(File planFile, File moduleFile, File targetFile, boolean install, String mainClass, String classPath, String endorsedDirs, String extensionDirs) throws DeploymentException {
         if (planFile == null && moduleFile == null) {
             throw new DeploymentException("No plan or module specified");
         }
@@ -180,6 +180,9 @@
                 if (endorsedDirs != null) {
                     mainAttributes.putValue(CommandLineManifest.ENDORSED_DIRS.toString(), endorsedDirs);
                 }
+                if (extensionDirs != null) {
+                    mainAttributes.putValue(CommandLineManifest.EXTENSION_DIRS.toString(), extensionDirs);
+                }
             } else {
                 manifest = null;
             }
@@ -238,7 +241,7 @@
 
         infoFactory.addAttribute("kernel", Kernel.class, false);
         infoFactory.addOperation("deploy", new Class[]{File.class, File.class});
-        infoFactory.addOperation("deploy", new Class[]{File.class, File.class, File.class, boolean.class, String.class, String.class, String.class});
+        infoFactory.addOperation("deploy", new Class[]{File.class, File.class, File.class, boolean.class, String.class, String.class, String.class, String.class});
 
         infoFactory.addReference("Builders", ConfigurationBuilder.class, "ConfigBuilder");
         infoFactory.addReference("Store", ConfigurationStore.class, "ConfigurationStore");

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLineManifest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLineManifest.java?rev=291373&r1=291372&r2=291373&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLineManifest.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLineManifest.java Sat Sep 24 20:38:18 2005
@@ -31,8 +31,8 @@
 import javax.management.MalformedObjectNameException;
 
 /**
- * 
- * 
+ *
+ *
  * @version $Rev$ $Date$
  */
 public class CommandLineManifest {
@@ -40,6 +40,7 @@
     public static final Attributes.Name MAIN_METHOD = new Attributes.Name("Main-Method");
     public static final Attributes.Name CONFIGURATIONS = new Attributes.Name("Configurations");
     public static final Attributes.Name ENDORSED_DIRS = new Attributes.Name("Endorsed-Dirs");
+    public static final Attributes.Name EXTENSION_DIRS = new Attributes.Name("Extension-Dirs");
 
     public static CommandLineManifest getManifestEntries() {
         // find the startup jar
@@ -99,12 +100,22 @@
         String endorsedDirsString = mainAttributes.getValue(ENDORSED_DIRS);
         if (endorsedDirsString != null) {
             for (StringTokenizer tokenizer = new StringTokenizer(endorsedDirsString, " "); tokenizer.hasMoreTokens();) {
-                String configuration = tokenizer.nextToken();
-                endorsedDirs.add(configuration);
+                String directory = tokenizer.nextToken();
+                endorsedDirs.add(directory);
+            }
+        }
+
+        // get the list of extension directories
+        List extensionDirs = new ArrayList();
+        String extensionDirsString = mainAttributes.getValue(EXTENSION_DIRS);
+        if (extensionDirsString != null) {
+            for (StringTokenizer tokenizer = new StringTokenizer(extensionDirsString, " "); tokenizer.hasMoreTokens();) {
+                String directory = tokenizer.nextToken();
+                extensionDirs.add(directory);
             }
         }
 
-        CommandLineManifest commandLineManifest = new CommandLineManifest(mainGBean, mainMethod, configurations, endorsedDirs);
+        CommandLineManifest commandLineManifest = new CommandLineManifest(mainGBean, mainMethod, configurations, endorsedDirs, extensionDirs);
         return commandLineManifest;
     }
 
@@ -112,12 +123,14 @@
     private final String mainMethod;
     private final List configurations;
     private final List endorsedDirs;
+    private final List extensionDirs;
 
-    public CommandLineManifest(ObjectName mainGBean, String mainMethod, List configurations, List endorsedDirs) {
+    public CommandLineManifest(ObjectName mainGBean, String mainMethod, List configurations, List endorsedDirs, List extensionDirs) {
         this.mainGBean = mainGBean;
         this.mainMethod = mainMethod;
         this.configurations = Collections.unmodifiableList(configurations);
         this.endorsedDirs = endorsedDirs;
+        this.extensionDirs = extensionDirs;
     }
 
     public ObjectName getMainGBean() {
@@ -134,5 +147,9 @@
 
     public List getEndorsedDirs() {
         return endorsedDirs;
+    }
+
+    public List getExtensionDirs() {
+        return extensionDirs;
     }
 }

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java?rev=291373&r1=291372&r2=291373&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java Sat Sep 24 20:38:18 2005
@@ -131,23 +131,14 @@
 
             // setup the endorsed dir entry
             CommandLineManifest manifestEntries = CommandLineManifest.getManifestEntries();
-            String endorsedDirs = System.getProperty("java.endorsed.dirs", "");
-            for (Iterator iterator = manifestEntries.getEndorsedDirs().iterator(); iterator.hasNext();) {
-                String directoryName = (String) iterator.next();
-                File directory = new File(directoryName);
-                if (!directory.isAbsolute()) {
-                    directory = new File(geronimoInstallDirectory, directoryName);
-                }
 
-                if (endorsedDirs.length() > 0) {
-                    endorsedDirs += File.pathSeparatorChar;
-                }
-                endorsedDirs += directory.getAbsolutePath();
-            }
-            if (endorsedDirs.length() > 0) {
-                System.setProperty("java.endorsed.dirs", endorsedDirs);
-            }
-            log.debug("java.endorsed.dirs=" + System.getProperty("java.endorsed.dirs"));
+            String endorsedDirs = "java.endorsed.dirs";
+            List endorsedDirsFromManifest = manifestEntries.getEndorsedDirs();
+            AddToSystemProperty(endorsedDirs, endorsedDirsFromManifest, geronimoInstallDirectory);
+
+            String extensionDirs = "java.ext.dirs";
+            List extensionDirsFromManifest = manifestEntries.getExtensionDirs();
+            AddToSystemProperty(extensionDirs, extensionDirsFromManifest, geronimoInstallDirectory);
 
 
             // load this configuration
@@ -289,6 +280,26 @@
             System.exit(3);
             throw new AssertionError();
         }
+    }
+
+    private void AddToSystemProperty(String propertyName, List dirsFromManifest, File geronimoInstallDirectory) {
+        String dirs = System.getProperty(propertyName, "");
+        for (Iterator iterator = dirsFromManifest.iterator(); iterator.hasNext();) {
+            String directoryName = (String) iterator.next();
+            File directory = new File(directoryName);
+            if (!directory.isAbsolute()) {
+                directory = new File(geronimoInstallDirectory, directoryName);
+            }
+
+            if (dirs.length() > 0) {
+                dirs += File.pathSeparatorChar;
+            }
+            dirs += directory.getAbsolutePath();
+        }
+        if (dirs.length() > 0) {
+            System.setProperty(propertyName, dirs);
+        }
+        log.debug(propertyName + "=" + System.getProperty(propertyName));
     }
 
     /**

Modified: geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java?rev=291373&r1=291372&r2=291373&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java (original)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java Sat Sep 24 20:38:18 2005
@@ -73,6 +73,7 @@
             String.class.getName(),
             String.class.getName(),
             String.class.getName(),
+            String.class.getName(),
     };
 
     static {
@@ -96,6 +97,7 @@
     private String mainClass;
     private String classPath;
     private String endorsedDirs;
+    private String extensionDirs;
 
     public File getRepository() {
         return repository;
@@ -208,6 +210,14 @@
         this.endorsedDirs = endorsedDirs;
     }
 
+    public String getExtensionDirs() {
+        return extensionDirs;
+    }
+
+    public void setExtensionDirs(String extensionDirs) {
+        this.extensionDirs = extensionDirs;
+    }
+
     public void execute() throws Exception {
         Kernel kernel = createKernel(repository);
 
@@ -301,7 +311,7 @@
     }
 
     private List invokeDeployer(Kernel kernel, ObjectName deployer) throws Exception {
-        Object[] args = {planFile, moduleFile, packageFile, Boolean.FALSE, mainClass, classPath, endorsedDirs};
+        Object[] args = {planFile, moduleFile, packageFile, Boolean.FALSE, mainClass, classPath, endorsedDirs, extensionDirs};
         return (List) kernel.invoke(deployer, "deploy", args, ARG_TYPES);
     }
 }