[jboss-cvs] JBossAS SVN: r58086 - trunk/server/src/main/org/jboss/deployment
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 3 14:23:41 EST 2006
Author: scott.stark at jboss.org
Date: 2006-11-03 14:23:39 -0500 (Fri, 03 Nov 2006)
New Revision: 58086
Modified:
trunk/server/src/main/org/jboss/deployment/EARStructure.java
Log:
Merge the JEE5_TCK EARDeployer archive detection changes
Modified: trunk/server/src/main/org/jboss/deployment/EARStructure.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EARStructure.java 2006-11-03 19:07:28 UTC (rev 58085)
+++ trunk/server/src/main/org/jboss/deployment/EARStructure.java 2006-11-03 19:23:39 UTC (rev 58086)
@@ -25,6 +25,8 @@
import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
import org.jboss.deployers.plugins.structure.ContextInfoImpl;
import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
@@ -33,7 +35,6 @@
import org.jboss.metadata.XmlFileLoader;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
import org.w3c.dom.Element;
@@ -157,20 +158,7 @@
// TODO: need to scan for annotationss
if( scan )
{
- // Just include the top-level archives for now
- SuffixMatchFilter jarFilter = new SuffixMatchFilter(JarUtils.getSuffixes());
- List<VirtualFile> archives = root.getChildren(jarFilter);
- if( archives != null )
- {
- String earPath = root.getPathName();
- for(VirtualFile archive : archives)
- {
- String path = earRelativePath(earPath, archive.getPathName());
- int type = typeFromSuffix(path, archive);
- J2eeModuleMetaData mod = new J2eeModuleMetaData(type, path);
- j2eeMetaData.addModule(mod);
- }
- }
+ scanEar(root, j2eeMetaData);
}
// Create subdeployments for the ear modules
@@ -212,7 +200,48 @@
return valid;
}
+ /**
+ For an ear without an application.xml, determine modules via:
+ a. All ear modules with an extension of .war are considered web modules. The
+ context root of the web module is the name of the file relative to the root
+ of the application package, with the .war extension removed.
+ b. All ear modules with extension of .rar are considered resource adapters.
+ c. A directory named lib is considered to be the library directory, as
+ described in Section�EE.8.2.1, �Bundled Libraries.�
+ d. For all ear modules with a filename extension of .jar, but not in the lib
+ directory, do the following:
+ i. If the JAR file contains a META-INF/MANIFEST.MF file with a Main-Class
+ attribute, or contains a META-INF/application-client.xml file, consider the
+ jar file to be an application client module.
+ ii. If the JAR file contains a META-INF/ejb-jar.xml file, or contains any
+ class with an EJB component annotation (Stateless, etc.), consider the JAR
+ file to be an EJB module.
+ iii. All other JAR files are ignored unless referenced by a JAR file
+ discovered above using one of the JAR file reference mechanisms such as the
+ Class-Path header in a manifest file.
+ * TODO: rewrite using vfs
+ * @param metaData
+ * @param di
+ */
+ private void scanEar(VirtualFile root, J2eeApplicationMetaData j2eeMetaData)
+ throws IOException
+ {
+ List<VirtualFile> archives = root.getChildren();
+ if( archives != null )
+ {
+ String earPath = root.getPathName();
+ for(VirtualFile archive : archives)
+ {
+ String module = earRelativePath(earPath, archive.getPathName());
+ int type = typeFromSuffix(module, archive);
+ J2eeModuleMetaData mod = new J2eeModuleMetaData(type, module);
+ j2eeMetaData.addModule(mod);
+ }
+ }
+ }
+
private int typeFromSuffix(String path, VirtualFile archive)
+ throws IOException
{
int type = 0;
if( path.endsWith(".war") )
@@ -226,11 +255,35 @@
else if( path.endsWith(".jar") )
{
// Look for a META-INF/application-client.xml
- VirtualFile xml = getMetaDataFile(archive, "META-INF/application-client.xml");
- if( xml != null )
+ VirtualFile mfFile = getMetaDataFile(archive, "META-INF/MANIFEST.MF");
+ VirtualFile clientXml = getMetaDataFile(archive, "META-INF/application-client.xml");
+ VirtualFile ejbXml = getMetaDataFile(archive, "META-INF/ejb-jar.xml");
+ VirtualFile jbossXml = getMetaDataFile(archive, "META-INF/jboss.xml");
+
+ if( clientXml != null )
+ {
type = J2eeModuleMetaData.CLIENT;
+ }
+ else if( mfFile != null )
+ {
+ InputStream is = mfFile.openStream();
+ Manifest mf = new Manifest(is);
+ is.close();
+ Attributes attrs = mf.getMainAttributes();
+ if( attrs.containsKey(Attributes.Name.MAIN_CLASS) )
+ {
+ type = J2eeModuleMetaData.CLIENT;
+ }
+ }
+ else if( ejbXml != null || jbossXml != null )
+ {
+ type = J2eeModuleMetaData.EJB;
+ }
else
+ {
+ // TODO: scan for annotations. Assume EJB for now
type = J2eeModuleMetaData.EJB;
+ }
}
return type;
More information about the jboss-cvs-commits
mailing list