[jboss-cvs] JBossAS SVN: r60677 - in branches/Branch_4_2/server/src: main/org/jboss/deployment and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 19 16:17:01 EST 2007


Author: scott.stark at jboss.org
Date: 2007-02-19 16:17:01 -0500 (Mon, 19 Feb 2007)
New Revision: 60677

Modified:
   branches/Branch_4_2/server/src/etc/deploy/ear-deployer.xml
   branches/Branch_4_2/server/src/main/org/jboss/deployment/EARDeployer.java
   branches/Branch_4_2/server/src/main/org/jboss/deployment/J2eeApplicationMetaData.java
Log:
JBAS-4037, add a library-directory support for ears

Modified: branches/Branch_4_2/server/src/etc/deploy/ear-deployer.xml
===================================================================
--- branches/Branch_4_2/server/src/etc/deploy/ear-deployer.xml	2007-02-19 21:16:10 UTC (rev 60676)
+++ branches/Branch_4_2/server/src/etc/deploy/ear-deployer.xml	2007-02-19 21:17:01 UTC (rev 60677)
@@ -15,5 +15,11 @@
       optimization disabled.
       -->
       <attribute name="CallByValue">false</attribute>
+      <!-- A flag the enables the default behavior of the ee5 library-directory. If true,
+      the lib contents of an ear are assumed to be the default value for library-directory
+      in the absence of an explicit library-directory. If false, there must be an
+      explicit library-directory.
+      --
+      <attribute name="EnablelibDirectoryByDefault">true</attribute>
    </mbean>
 </server>

Modified: branches/Branch_4_2/server/src/main/org/jboss/deployment/EARDeployer.java
===================================================================
--- branches/Branch_4_2/server/src/main/org/jboss/deployment/EARDeployer.java	2007-02-19 21:16:10 UTC (rev 60676)
+++ branches/Branch_4_2/server/src/main/org/jboss/deployment/EARDeployer.java	2007-02-19 21:17:01 UTC (rev 60677)
@@ -22,6 +22,7 @@
 package org.jboss.deployment;
 
 import java.io.File;
+import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -65,10 +66,12 @@
    };
    
    private ServiceControllerMBean serviceController;
-
+   /** */
    private boolean isolated = false;
-
+   /** */
    private boolean callByValue = false;
+   /** Should the default library-directory of lib be assumed if no explicit library-directory was specified */
+   private boolean enablelibDirectoryByDefault = true;
    
    /**
     * Default CTOR
@@ -114,6 +117,16 @@
       this.callByValue = callByValue;
    }
    
+   public boolean isEnablelibDirectoryByDefault()
+   {
+      return enablelibDirectoryByDefault;
+   }
+
+   public void setEnablelibDirectoryByDefault(boolean enablelibDirectoryByDefault)
+   {
+      this.enablelibDirectoryByDefault = enablelibDirectoryByDefault;
+   }
+
    protected void startService() throws Exception
    {
       serviceController = (ServiceControllerMBean)
@@ -158,6 +171,30 @@
          }
          initLoaderRepository(di, loader);
 
+         // Add any library-directory contents
+         String libraryDirectory = metaData.getLibraryDirectory();
+         // Allow for the default lib unless disabled at the ear deployer level
+         if( libraryDirectory == null && isEnablelibDirectoryByDefault() )
+            libraryDirectory = "lib";
+         if( libraryDirectory != null && libraryDirectory.length() > 0 )
+         {
+            // This only resolves against the local url
+            URL docURL = di.localUrl;
+            if( docURL == null || docURL.getProtocol().equals("file") == false)
+               log.warn("Skipping ear library-directory since the deployment has no local file url");
+            else
+            {
+               File lib = new File(docURL.getPath());
+               String[] jars = lib.list(new JarFilter());
+               for(int n = 0; jars != null && n < jars.length; n ++)
+               {
+                  String jar = jars[n];
+                  URL libJar = new URL(docURL, jar);
+                  di.addLibraryJar(libJar);
+               }
+            }
+         }
+
          // resolve the watch
          if (di.url.getProtocol().equals("file"))
          {
@@ -179,7 +216,7 @@
             // We watch the top only, no directory support
             di.watch = di.url;
          }
-         
+
          // Obtain the sub-deployment list
          File parentDir = null;
          HashMap extractedJars = new HashMap();
@@ -419,4 +456,12 @@
    protected void processNestedDeployments(DeploymentInfo di)
    {
    }
+
+   static class JarFilter implements FilenameFilter
+   {
+      public boolean accept(File dir, String name)
+      {
+         return name.endsWith(".jar");
+      }
+   }
 }

Modified: branches/Branch_4_2/server/src/main/org/jboss/deployment/J2eeApplicationMetaData.java
===================================================================
--- branches/Branch_4_2/server/src/main/org/jboss/deployment/J2eeApplicationMetaData.java	2007-02-19 21:16:10 UTC (rev 60676)
+++ branches/Branch_4_2/server/src/main/org/jboss/deployment/J2eeApplicationMetaData.java	2007-02-19 21:17:01 UTC (rev 60677)
@@ -39,6 +39,7 @@
  * descriptors.
  *
  * @author Thomas.Diesler at jboss.org
+ * @author Scott.Stark at jboss.org
  * @version $Revision$
  * @see org.jboss.metadata.XmlLoadable
  */
@@ -71,6 +72,9 @@
    /** The jmx name */
    private String jmxName;
 
+   /** The library-directory name */
+   private String libraryDirectory;
+
    /** 
     * Module order will be based on the deployment sorter (implicit) or on the
     * ordering of modules defined in application.xml and jboss-app.xml (strict). 
@@ -130,7 +134,12 @@
    {
       return jmxName;
    }
-   
+
+   public String getLibraryDirectory()
+   {
+      return libraryDirectory;
+   }
+
    public String getModuleOrder()
    {
 	  return moduleOrder; 
@@ -241,6 +250,11 @@
       if (jmxNameElement != null)
          jmxName = getElementContent(jmxNameElement);
 
+      // Get any library-directory. The default empty elements means there is no library directory
+      Element libDirElement = getOptionalChild(rootElement, "library-directory");
+      if (libDirElement != null)
+         libraryDirectory = getElementContent(libDirElement, "");
+
       // extract modules...
       for (Iterator it = getChildrenByTagName(rootElement, "module"); it.hasNext();)
       {




More information about the jboss-cvs-commits mailing list