On Mon, 4 Feb 2002, Adam Heath wrote:

> Quick feature request for 3.0.
>
> Currently, (the spec and current jboss code) says web modules should be in the
> ear.  Jboss allows for this to be unpacked.  And this is great.  However,
> there are downsides to even this.
>
> We have a 650 meg website(lots and lots of images).  Putting this into .war,
> then into a .ear, which will then just get unpacked, would be insane.  So, we
> use unpacked ear support(on 2.4.4).
>
> However, it would be nice if we could specify an external path to a web
> module, instead of having to have the web module as a sub-dir of the unpacked
> ear.
>
> I'd love to help code this(I started to do what marc did on the 2.4 branch),
> but am currently swamped with helping to rewrite a 3 year old website into
> J2EE spec.
>
> Given a few pointers, I think this wouldn't be hard to do.  It requires mods
> to some dtds(would have to be jboss-specific), then to the deployer(s).

There are 2 patches here.  One fixes building of classpaths for sub-module's
MANIFEST.MF.  The other does the feature I requested above.

Ok, I have it done.  There is now support for jboss-app.xml in META-INF.  It
is similiar to application.xml, except it only allows for module definitions.

The uri's for the modules now take full urls, instead of relative paths.  This
allows for referencing external items from a packaged ear.

One downside, is that for packed ears, referenced external items must also be
packed.  For unpacked ears, they must also be unpacked.

These patches are for jboss 2.4.4.

We(work) haven't yet switched to 3.0(waiting for beta), so forgive me for not
making these patches for that version.
Depends: feature-sf-491497-autodeployer-magic

If ear modules have internal MANIFEST.MF files, that contain a Class-Path
entry, the code would build the file path based from the path of the
unpacked module.  This is different than the spec, and LegacyInstaller,
which builds the path based from the ear itself.

diff -ruN -x *.jar -x *.log -x *.zip -x *.rar -x *~ -x CVS 
JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/deployment/LocalDirInstaller.java 
JBoss-2.4.4-src/jboss/src/main/org/jboss/deployment/LocalDirInstaller.java
--- JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/deployment/LocalDirInstaller.java    
 Sun Dec  9 20:35:37 2001
+++ JBoss-2.4.4-src/jboss/src/main/org/jboss/deployment/LocalDirInstaller.java  Thu 
+Jan 31 21:48:04 2002
@@ -82,7 +82,7 @@
                log.info("install EJB module "+d.name);               
                // Check for libs declared in the EJB jar manifest
                
-               URL[] libs = resolveLibraries(localPkg);
+               URL[] libs = resolveLibraries(localPkg, src);
                URL localURL = localPkg.toURL();
                d.addEjbModule(d.name, localURL, libs);
             }
@@ -94,7 +94,7 @@
                
                log.info("inflate and install WEB module "+d.name);
                // Check for libs declared int the WAR jar manifest
-               URL[] libs = libs = resolveLibraries(localPkg);
+               URL[] libs = libs = resolveLibraries(localPkg, src);
                URL localURL = localPkg.toURL();
                d.addWebModule(d.name, webContext, localURL, libs);
             }
@@ -132,7 +132,7 @@
                         File ejbPkg = new File(localPkg, name);
                         if( ejbPkg.isDirectory() == false )
                            throw new J2eeDeploymentException("EJB module: "+ejbPkg+" 
is not a directory");
-                        URL[] libs = resolveLibraries(ejbPkg);
+                        URL[] libs = resolveLibraries(ejbPkg, src);
                         URL localURL = ejbPkg.toURL();
                         d.addEjbModule(name, localURL, libs);
                         ejbJars.add(localURL);
@@ -165,7 +165,7 @@
                         File warPkg = new File(localPkg, name);
                         if( warPkg.isDirectory() == false )
                            throw new J2eeDeploymentException("WAR module: "+warPkg+" 
is not a directory");
-                        URL[] libs = resolveLibraries(warPkg);
+                        URL[] libs = resolveLibraries(warPkg, src);
                         URL localURL = warPkg.toURL();
                         d.addWebModule(name, webContext, localURL, libs);
                      }
@@ -208,15 +208,13 @@
     *  @param baseURL the URL to which the Class-Path entries will be relative
     @return URL[] the array of URLs for the valid Class-Path entries
     */
-   private URL[] resolveLibraries(File localFile)
+   private URL[] resolveLibraries(File localFile, URL baseURL)
    {
       URL[] libs = {};
       // Locate a manifest
       Manifest mf = null;
-      URL baseURL = null;
       try
       {
-         baseURL = localFile.toURL();
          File mfFile = new File(localFile, "META-INF" + File.separator + 
"MANIFEST.MF");
          if( mfFile.exists() == false )
          {
Depends: fix-unpacked-ear-classpath

This allows for a jboss-app.xml, that mirrors application.xml.  The only
change, is that uris for the modules reference external files that exist
on the system, and not those that exist inside the packaged ear(be it
a zip file, or unpacked directory).

Note, that for ears packed as zips, the reference must be to an external,
module, packed into a zip.  For unpacked ear support, the reference must
be to a directory.

diff -ruN -x *.jar -x *.log -x *.zip -x *.rar -x *~ -x CVS JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/deployment/J2eeModuleMetaData.java JBoss-2.4.4-src/jboss/src/main/org/jboss/deployment/J2eeModuleMetaData.java
--- JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/deployment/J2eeModuleMetaData.java	Fri Nov  2 02:42:30 2001
+++ JBoss-2.4.4-src/jboss/src/main/org/jboss/deployment/J2eeModuleMetaData.java	Thu Feb  7 12:05:57 2002
@@ -30,6 +30,7 @@
 	 
    // Attributes ----------------------------------------------------
 	int type;
+	boolean jbossModule;
    
 	String fileName;
    String alternativeDD;
@@ -38,8 +39,9 @@
    // Static --------------------------------------------------------
    
    // Constructors --------------------------------------------------
-   public J2eeModuleMetaData (Element moduleElement)  throws DeploymentException
+   public J2eeModuleMetaData (Element moduleElement, boolean jbossModule)  throws DeploymentException
 	{
+		this.jbossModule = jbossModule;
 		importXml (moduleElement);
 	}
 	
@@ -65,6 +67,11 @@
 		return (type == CONNECTOR);
 	}
 	
+	public boolean isJbossModule ()
+	{
+		return jbossModule;
+	}
+
 	
 	
 	public String getFileName ()
diff -ruN -x *.jar -x *.log -x *.zip -x *.rar -x *~ -x CVS JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/deployment/LegacyInstaller.java JBoss-2.4.4-src/jboss/src/main/org/jboss/deployment/LegacyInstaller.java
--- JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/deployment/LegacyInstaller.java	Sun Dec  9 20:35:37 2001
+++ JBoss-2.4.4-src/jboss/src/main/org/jboss/deployment/LegacyInstaller.java	Thu Feb  7 12:11:21 2002
@@ -203,6 +203,27 @@
                   throw new J2eeDeploymentException("unexpected error: application.xml was found once but not a second time?!");
                }
                
+               try
+               {
+                  InputStream in = jarFile.getInputStream(jarFile.getEntry("META-INF/jboss-app.xml"));
+                  XmlFileLoader xfl = new XmlFileLoader();
+                  Element root = xfl.getDocument(in, files[type]).getDocumentElement();
+                  app.importXml(root); 
+               }
+               catch (IOException _ioe)
+               {
+                  // ignore, as jboss-app.xml may not exist
+               }
+               catch (DeploymentException _de)
+               {
+                  throw new J2eeDeploymentException("Error in parsing jboss-app.xml: "+_de.getMessage());
+               }
+               catch (NullPointerException _npe)
+               {
+                  throw new J2eeDeploymentException("unexpected error: jboss-app.xml was found once but not a second time?!");
+               }
+
+
                // iterating the ejb and web modules and install them
                File f = null;
                J2eeModuleMetaData mod;
@@ -220,7 +241,7 @@
                      try
                      {
                         String ejbJarName = mod.getFileName();
-                        InputStream in = jarFile.getInputStream(jarFile.getEntry(ejbJarName));
+                        InputStream in = mod.isJbossModule() ? new URL(name).openStream() : jarFile.getInputStream(jarFile.getEntry(ejbJarName));
                         f = install(in, "ejb");
                         // Check for libs declared int the EJB jar manifest
                         JarFile jar = new JarFile(f);
@@ -256,7 +277,7 @@
                      log.info("inflate and install WEB module "+name);
                      try
                      {
-                        InputStream in = jarFile.getInputStream(jarFile.getEntry(name));
+                        InputStream in = mod.isJbossModule() ? new URL(name).openStream() : jarFile.getInputStream(jarFile.getEntry(name));
                         f = installInflate(in, "web");
                         
                         // Check for libs declared int the WAR jar manifest
diff -ruN -x *.jar -x *.log -x *.zip -x *.rar -x *~ -x CVS JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/deployment/LocalDirInstaller.java JBoss-2.4.4-src/jboss/src/main/org/jboss/deployment/LocalDirInstaller.java
--- JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/deployment/LocalDirInstaller.java	Thu Feb  7 12:11:58 2002
+++ JBoss-2.4.4-src/jboss/src/main/org/jboss/deployment/LocalDirInstaller.java	Thu Feb  7 12:09:28 2002
@@ -115,6 +115,22 @@
                   throw new J2eeDeploymentException("Error in parsing application.xml", e);
                }
                
+               try
+               {
+                  URL jbossAppXml = new URL(localPkg.toURL(), "META-INF/jboss-app.xml");
+                  Document jbossAppDoc = XmlFileLoader.getDocument(jbossAppXml, false);
+                  Element root = jbossAppDoc.getDocumentElement();
+                  app.importXml(root);
+               }
+               catch (IOException e)
+               {
+                  // ignore, as jboss-app.xml may not exist
+               }
+               catch (DeploymentException e)
+               {
+                  throw new J2eeDeploymentException("Error in parsing jboss-app.xml", e);
+               }
+               
                // iterating the ejb and web modules and install them
                ArrayList ejbJars = new ArrayList();
                Iterator it = app.getModules();
@@ -129,7 +145,7 @@
                      log.debug("Process EJB module "+name);
                      try
                      {
-                        File ejbPkg = new File(localPkg, name);
+                        File ejbPkg = mod.isJbossModule() ? new File(new URL(name).getFile()) : new File(localPkg, name);
                         if( ejbPkg.isDirectory() == false )
                            throw new J2eeDeploymentException("EJB module: "+ejbPkg+" is not a directory");
                         URL[] libs = resolveLibraries(ejbPkg, src);
@@ -162,7 +179,7 @@
                      log.debug("Process WEB module "+name);
                      try
                      {                        
-                        File warPkg = new File(localPkg, name);
+                        File warPkg = mod.isJbossModule() ? new File(new URL(name).getFile()) : new File(localPkg, name);
                         if( warPkg.isDirectory() == false )
                            throw new J2eeDeploymentException("WAR module: "+warPkg+" is not a directory");
                         URL[] libs = resolveLibraries(warPkg, src);
diff -ruN -x *.jar -x *.log -x *.zip -x *.rar -x *~ -x CVS JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/metadata/XmlFileLoader.java JBoss-2.4.4-src/jboss/src/main/org/jboss/metadata/XmlFileLoader.java
--- JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/metadata/XmlFileLoader.java	Sun Dec  9 20:52:03 2001
+++ JBoss-2.4.4-src/jboss/src/main/org/jboss/metadata/XmlFileLoader.java	Thu Feb  7 12:05:57 2002
@@ -298,6 +298,7 @@
          registerDTD("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN", "ejb-jar_2_0.dtd");
          registerDTD("-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN", "application_1_2.dtd");
          registerDTD("-//Sun Microsystems, Inc.//DTD Connector 1.0//EN", "connector_1_0.dtd");
+         registerDTD("-//JBoss//DTD APPLICATION//EN", "jboss-app.dtd");
          registerDTD("-//JBoss//DTD JAWS//EN", "jaws.dtd");
          registerDTD("-//JBoss//DTD JAWS 2.4//EN", "jaws_2_4.dtd");
          registerDTD("-//JBoss//DTD JBOSS//EN","jboss.dtd");
diff -ruN -x *.jar -x *.log -x *.zip -x *.rar -x *~ -x CVS -x *.orig JBoss-2.4.4-src.orig/jboss/src/resources/org/jboss/metadata/jboss-app.dtd JBoss-2.4.4-src/jboss/src/resources/org/jboss/metadata/jboss-app.dtd
--- JBoss-2.4.4-src.orig/jboss/src/resources/org/jboss/metadata/jboss-app.dtd	Wed Dec 31 18:00:00 1969
+++ JBoss-2.4.4-src/jboss/src/resources/org/jboss/metadata/jboss-app.dtd	Thu Feb  7 13:27:03 2002
@@ -0,0 +1,142 @@
+<!--
+Copyright 1999 Sun Microsystems, Inc. 901 San Antonio Road,
+Palo Alto, CA  94303, U.S.A.  All rights reserved.
+ 
+This product or document is protected by copyright and distributed
+under licenses restricting its use, copying, distribution, and
+decompilation.  No part of this product or documentation may be
+reproduced in any form by any means without prior written authorization
+of Sun and its licensors, if any.  
+
+Third party software, including font technology, is copyrighted and 
+licensed from Sun suppliers. 
+
+Sun, Sun Microsystems, the Sun Logo, Solaris, Java, JavaServer Pages, Java 
+Naming and Directory Interface, JDBC, JDK, JavaMail and Enterprise JavaBeans, 
+are trademarks or registered trademarks of Sun Microsystems, Inc in the U.S. 
+and other countries.
+
+All SPARC trademarks are used under license and are trademarks
+or registered trademarks of SPARC International, Inc.
+in the U.S. and other countries. Products bearing SPARC
+trademarks are based upon an architecture developed by Sun Microsystems, Inc. 
+
+PostScript is a registered trademark of Adobe Systems, Inc. 
+
+ 
+Federal Acquisitions: Commercial Software - Government Users Subject to 
+Standard License Terms and Conditions.
+
+
+ 
+DOCUMENTATION IS PROVIDED "AS IS" AND ALL EXPRESS OR IMPLIED
+CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
+IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT
+TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY
+INVALID.
+
+_________________________________________________________________________
+Copyright 1999 Sun Microsystems, Inc., 
+901 San Antonio Road, Palo Alto, CA  94303, Etats-Unis. 
+Tous droits re'serve's.
+ 
+
+Ce produit ou document est prote'ge' par un copyright et distribue' avec 
+des licences qui en restreignent l'utilisation, la copie, la distribution,
+et la de'compilation.  Aucune partie de ce produit ou de sa documentation
+associe'e ne peut e^tre reproduite sous aucune forme, par quelque moyen 
+que ce soit, sans l'autorisation pre'alable et e'crite de Sun et de ses 
+bailleurs de licence, s'il y en a.  
+
+Le logiciel de'tenu par des tiers, et qui comprend la technologie 
+relative aux polices de caracte`res, est prote'ge' par un copyright 
+et licencie' par des fournisseurs de Sun.
+ 
+Sun, Sun Microsystems, le logo Sun, Solaris, Java, JavaServer Pages, Java 
+Naming and Directory Interface, JDBC, JDK, JavaMail, et Enterprise JavaBeans,  
+sont des marques de fabrique ou des marques de'pose'es de Sun 
+Microsystems, Inc. aux Etats-Unis et dans d'autres pays.
+ 
+Toutes les marques SPARC sont utilise'es sous licence et sont
+des marques de fabrique ou des marques de'pose'es de SPARC
+International, Inc. aux Etats-Unis et  dans
+d'autres pays. Les produits portant les marques SPARC sont
+base's sur une architecture de'veloppe'e par Sun Microsystems, Inc.  
+
+Postcript est une marque enregistre'e d'Adobe Systems Inc. 
+ 
+LA DOCUMENTATION EST FOURNIE "EN L'ETAT" ET TOUTES AUTRES CONDITIONS,
+DECLARATIONS ET GARANTIES EXPRESSES OU TACITES SONT FORMELLEMENT EXCLUES,
+DANS LA MESURE AUTORISEE PAR LA LOI APPLICABLE, Y COMPRIS NOTAMMENT
+TOUTE GARANTIE IMPLICITE RELATIVE A LA QUALITE MARCHANDE, A L'APTITUDE
+A UNE UTILISATION PARTICULIERE OU A L'ABSENCE DE CONTREFACON.
+-->
+
+<!--
+The alt-dd element specifies an optional URI to the post-assembly version of the
+deployment descriptor file for a particular J2EE module. The URI must specify
+the full pathname of the deployment descriptor file relative to the
+application's root directory. If alt-dd is not specified, the deployer must read
+the deployment descriptor from the default location and file name required by
+the respective component specification.
+-->
+<!ELEMENT alt-dd (#PCDATA)>
+
+<!--
+The jboss-app element is the root element of a J2EE application deployment
+descriptor.
+-->
+<!ELEMENT jboss-app (module+)>
+
+<!--
+The context-root element specifies the context root of a web application
+-->
+<!ELEMENT context-root (#PCDATA)>
+
+<!--
+The ejb element specifies the URI of a ejb-jar, relative to the top level of the
+application package.
+-->
+<!ELEMENT ejb (#PCDATA)>
+
+<!--
+The java element specifies the URI of a java application client module, relative
+to the top level of the application package.
+-->
+<!ELEMENT java (#PCDATA)>
+
+<!--
+The module element represents a single J2EE module and contains an ejb, java, or
+web element, which indicates the module type and contains a path to the module
+file, and an optional alt-dd element, which specifies an optional URI to the
+post-assembly version of the deployment descriptor.
+The application deployment descriptor must have one module element for each J2EE
+module in the application package.
+-->
+<!ELEMENT module ((ejb | java | web), alt-dd?)>
+
+<!--
+The web element contains the web-uri and context-root of a web application
+module.
+-->
+<!ELEMENT web (web-uri, context-root)>
+
+<!--
+The web-uri element specifies the URI of a web application file, relative to the
+top level of the application package.
+-->
+<!ELEMENT web-uri (#PCDATA)>
+
+<!--
+The ID mechanism is to allow tools to easily make tool-specific references to
+the elements of the deployment descriptor.
+ -->
+<!ATTLIST alt-dd id ID #IMPLIED>
+<!ATTLIST jboss-app id ID #IMPLIED>
+<!ATTLIST context-root id ID #IMPLIED>
+<!ATTLIST ejb id ID #IMPLIED>
+<!ATTLIST java id ID #IMPLIED>
+<!ATTLIST module id ID #IMPLIED>
+<!ATTLIST web id ID #IMPLIED>
+<!ATTLIST web-uri id ID #IMPLIED>
diff -ruN -x *.jar -x *.log -x *.zip -x *.rar -x *~ -x CVS -x *.orig JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/deployment/J2eeApplicationMetaData.java JBoss-2.4.4-src/jboss/src/main/org/jboss/deployment/J2eeApplicationMetaData.java
--- JBoss-2.4.4-src.orig/jboss/src/main/org/jboss/deployment/J2eeApplicationMetaData.java	Fri Nov  2 02:42:30 2001
+++ JBoss-2.4.4-src/jboss/src/main/org/jboss/deployment/J2eeApplicationMetaData.java	Thu Feb  7 14:00:51 2002
@@ -29,7 +29,7 @@
     
    // Attributes ----------------------------------------------------
 	String displayName;
-   String description;
+   String description = "";
    String smallIcon;
 	String largeIcon;
 	
@@ -70,46 +70,49 @@
    	return modules.iterator ();
    }
    
-
-
-
-    public void importXml (Element element) throws DeploymentException {
-		String rootTag = element.getOwnerDocument().getDocumentElement().getTagName();
-		
-		if (rootTag.equals("application")) {
-			
-			// get some general info
-         displayName = getElementContent (getUniqueChild (element, "display-name"));
-         Element e = getOptionalChild (element, "description");
-			description = e != null ? getElementContent (e) : "";
-
-         e = getOptionalChild (element, "icon");
-			if (e != null)
-			{
-            Element e2 = getOptionalChild (element, "small-icon");
-	 			smallIcon = e2 != null ? getElementContent (e2) : "";
-				
-            e2 = getOptionalChild (element, "large-icon");
-	 			largeIcon = e2 != null ? getElementContent (e2) : "";
-		   } else
-		   {
-				smallIcon = "";
-				largeIcon = "";
-			}
-			
-			// extract modules...
-			modules = new Vector ();
-			Iterator it = getChildrenByTagName (element, "module");
-			while (it.hasNext ())
-			{
-				modules.add (new J2eeModuleMetaData ((Element)it.next ()));
-			}
-		
-		} else 
-			throw new DeploymentException("Unrecognized root tag in EAR deployment descriptor: "+ element);
-	}
+   public void importXml (Element element) throws DeploymentException
+   {
+      String rootTag = element.getOwnerDocument().getDocumentElement().getTagName();
+      boolean jbossApp = rootTag.equals("jboss-app");
+      if (rootTag.equals("application") || jbossApp)
+      {
+         if (!jbossApp)
+         {
+            // get some general info
+            Element e = getUniqueChild (element, "display-name");
+            if (e != null)
+               displayName = getElementContent (e);
+            
+            e = getOptionalChild (element, "description");
+            if (e != null)
+               description = getElementContent (e);
+            
+            e = getOptionalChild (element, "icon");
+            if (e != null)
+            {
+               Element e2 = getOptionalChild (element, "small-icon");
+               if (e2 != null)
+                  smallIcon = getElementContent (e2);
+               
+               e2 = getOptionalChild (element, "large-icon");
+               if (e2 != null)
+                  largeIcon = getElementContent (e2);
+            }
+         }
+         
+         // extract modules...
+         if (modules == null)
+            modules = new Vector ();
+         Iterator it = getChildrenByTagName (element, "module");
+         while (it.hasNext ())
+         {
+            modules.add (new J2eeModuleMetaData ((Element)it.next (), jbossApp));
+         }
+      } else {
+         throw new DeploymentException("Unrecognized root tag in EAR deployment descriptor: "+ element);
+      }
+   }
    
-    
    // Y overrides ---------------------------------------------------
    
    // Package protected ---------------------------------------------

Reply via email to