[jboss-cvs] JBossAS SVN: r57837 - trunk/server/src/main/org/jboss/deployment
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 25 19:43:45 EDT 2006
Author: scott.stark at jboss.org
Date: 2006-10-25 19:43:41 -0400 (Wed, 25 Oct 2006)
New Revision: 57837
Added:
trunk/server/src/main/org/jboss/deployment/AppParsingDeployer.java
trunk/server/src/main/org/jboss/deployment/J2eeApplicationObjectFactory.java
trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java
trunk/server/src/main/org/jboss/deployment/JBossApplicationObjectFactory.java
Modified:
trunk/server/src/main/org/jboss/deployment/EARStructure.java
trunk/server/src/main/org/jboss/deployment/J2eeApplicationMetaData.java
trunk/server/src/main/org/jboss/deployment/J2eeModuleMetaData.java
Log:
Update for the structure deployer changes, JBMICROCONT-105
Split the EARStructure deployer into EARStructure, AppParsingDeployer, and JBossAppParsingDeployer
Added: trunk/server/src/main/org/jboss/deployment/AppParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/AppParsingDeployer.java 2006-10-25 23:12:12 UTC (rev 57836)
+++ trunk/server/src/main/org/jboss/deployment/AppParsingDeployer.java 2006-10-25 23:43:41 UTC (rev 57837)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.deployment;
+
+import org.jboss.deployers.plugins.deployers.helpers.ObjectModelFactoryDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.xb.binding.ObjectModelFactory;
+
+/**
+ * An ObjectModelFactoryDeployer for translating application.xml descriptors into
+ * J2eeApplicationMetaData instances.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class AppParsingDeployer extends ObjectModelFactoryDeployer<J2eeApplicationMetaData>
+{
+ /** The name of the application descriptor in the deployment context metadata path */
+ private String appXmlPath = "application.xml";
+
+ public AppParsingDeployer()
+ {
+ super(J2eeApplicationMetaData.class);
+ }
+
+ /**
+ * Get the virtual file path for the application descriptor in the
+ * DeploymentContext.getMetaDataPath.
+ *
+ * @return the current virtual file path for the application descriptor
+ */
+ public String getAppXmlPath()
+ {
+ return appXmlPath;
+ }
+ /**
+ * Set the virtual file path for the application descriptor in the
+ * DeploymentContext.getMetaDataLocation. The standard path is application.xml
+ * to be found in the META-INF metdata path.
+ *
+ * @param appXmlPath - new virtual file path for the application descriptor
+ */
+ public void setAppXmlPath(String appXmlPath)
+ {
+ this.appXmlPath = appXmlPath;
+ }
+
+ /**
+ * Return WebMetaDataObjectFactory as our ObjectModelFactory.
+ * @return a new WebMetaDataObjectFactory instance
+ */
+ @Override
+ protected ObjectModelFactory getObjectModelFactory(J2eeApplicationMetaData root)
+ {
+ return new J2eeApplicationObjectFactory();
+ }
+
+ /**
+ * Overriden to invoke createMetaData(unit, webXmlPath, null) to parse any
+ * webXmlPath descriptor into a WebMetaData instance.
+ */
+ @Override
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ createMetaData(unit, appXmlPath, null);
+ }
+
+}
Modified: trunk/server/src/main/org/jboss/deployment/EARStructure.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/EARStructure.java 2006-10-25 23:12:12 UTC (rev 57836)
+++ trunk/server/src/main/org/jboss/deployment/EARStructure.java 2006-10-25 23:43:41 UTC (rev 57837)
@@ -1,221 +1,206 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployment;
-
-import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
-import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
-import org.jboss.deployers.plugins.structure.vfs.jar.JARCandidateStructureVisitorFactory;
-import org.jboss.deployers.spi.structure.DeploymentContext;
-import org.jboss.metadata.XmlFileLoader;
-import org.jboss.metadata.MetaData;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
-import org.jboss.virtual.VirtualFileVisitor;
-import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.w3c.dom.Element;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * WARStructure.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class EARStructure extends AbstractStructureDeployer
-{
- /**
- * The default filter
- */
- public static final VirtualFileFilter DEFAULT_EAR_LIB_FILTER = new SuffixMatchFilter(".jar");
-
- /**
- * The web-inf/lib filter
- */
- private VirtualFileFilter earLibFilter = DEFAULT_EAR_LIB_FILTER;
-
- @Override
- public int getRelativeOrder()
- {
- return 1000;
- }
-
- /**
- * Get the webInfLibFilter.
- *
- * @return the webInfLibFilter.
- */
- public VirtualFileFilter getEarLibFilter()
- {
- return earLibFilter;
- }
-
- /**
- * Set the webInfLibFilter.
- *
- * @param earLibFilter the webInfLibFilter.
- * @throws IllegalArgumentException for a null filter
- */
- public void setEarLibFilter(VirtualFileFilter earLibFilter)
- {
- if (earLibFilter == null)
- throw new IllegalArgumentException("Null filter");
- this.earLibFilter = earLibFilter;
- }
-
- public boolean determineStructure(DeploymentContext context)
- {
- try
- {
- VirtualFile root = context.getRoot();
- if (root.isLeaf() == false)
- {
- // We require either a WEB-INF or the name ends in .war
- if (root.getName().endsWith(".ear") == false)
- {
- return false;
- }
- else
- {
- log.trace("... ok - name ends in .ear.");
- }
-
- // The metadata path is WEB-INF
- context.setMetaDataPath("META-INF");
-
- VirtualFile applicationXml = context.getMetaDataFile("application.xml");
- VirtualFile jbossAppXml = context.getMetaDataFile("jboss-app.xml");
- VirtualFile lib = null;
- J2eeApplicationMetaData metaData = new J2eeApplicationMetaData();
- boolean scan = true;
- context.getTransientAttachments().addAttachment(J2eeApplicationMetaData.class, metaData);
-
- if (applicationXml != null)
- {
- InputStream in = applicationXml.openStream();
- XmlFileLoader xfl = new XmlFileLoader(false);
- Element application = xfl.getDocument(in, "META-INF/application.xml").getDocumentElement();
- metaData.importXml(application);
- in.close();
- scan = false;
- }
- if (jbossAppXml != null)
- {
- InputStream in = jbossAppXml.openStream();
- XmlFileLoader xfl = new XmlFileLoader(false);
- Element jbossApp = xfl.getDocument(in, "META-INF/jboss-app.xml").getDocumentElement();
- metaData.importXml(jbossApp);
-
- Element loader = MetaData.getOptionalChild(jbossApp, "loader-repository");
- if (loader != null)
- {
- LoaderRepositoryFactory.LoaderRepositoryConfig config = LoaderRepositoryFactory.parseRepositoryConfig(loader);
- context.getTransientAttachments().addAttachment(LoaderRepositoryFactory.LoaderRepositoryConfig.class, config);
- }
- in.close();
- }
-
- // set up classpaths
- List<VirtualFile> classpaths = new ArrayList<VirtualFile>();
- String libDir = metaData.getLibraryDirectory() == null ? "lib" : metaData.getLibraryDirectory();
- if (metaData.getLibraryDirectory() != null)
- {
- try
- {
- lib = root.findChild(libDir);
- if (lib != null)
- {
- List<VirtualFile> archives = lib.getChildren(earLibFilter);
- for (VirtualFile archive : archives)
- classpaths.add(archive);
- }
- }
- catch (IOException ignored)
- {
- // lib directory does not exist
- }
- }
-
- // Add the manifest locations
- VFSUtils.addManifestLocations(root, classpaths);
- context.setClassPath(classpaths);
-
- // Create subdeployments for the ear modules
- for (Iterator iter = metaData.getModules(); iter.hasNext();)
- {
- J2eeModuleMetaData mod = (J2eeModuleMetaData) iter.next();
- String fileName = mod.getFileName();
- if (fileName != null && (fileName = fileName.trim()).length() > 0)
- {
- try
- {
- VirtualFile module = root.findChild(fileName);
- if (module == null)
- {
- throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + root.getName());
- }
- AbstractDeploymentContext moduleContext = new AbstractDeploymentContext(module, true, context);
- moduleContext.getTransientAttachments().addAttachment(J2eeModuleMetaData.class, mod);
- context.addChild(moduleContext);
- }
- catch (IOException ignored)
- {
- throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + root.getName(), ignored);
- }
- }
- }
-
- if (scan)
- {
- JARCandidateStructureVisitorFactory factory = new JARCandidateStructureVisitorFactory();
- final J2eeApplicationMetaData my = metaData;
- factory.setFilter(new VirtualFileFilter() {
- public boolean accepts(VirtualFile file)
- {
- if (my.hasModule(file.getName())) return false;
- return true;
- }
- });
- VirtualFileVisitor visitor = factory.createVisitor(context, null);
- root.visit(visitor);
- }
-
- return true;
- }
- else
- {
- log.trace("... no - not a directory or an archive.");
- return false;
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error determining structure: " + context.getName(), e);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.deployment;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
+import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.metadata.XmlFileLoader;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
+import org.w3c.dom.Element;
+
+/**
+ * Structure deployer for EARs.
+ *
+ * @author Bill Burke
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class EARStructure extends AbstractStructureDeployer
+{
+ /**
+ * The default ear/lib filter
+ */
+ public static final VirtualFileFilter DEFAULT_EAR_LIB_FILTER = new SuffixMatchFilter(".jar");
+
+ /**
+ * The ear/lib filter
+ */
+ private VirtualFileFilter earLibFilter = DEFAULT_EAR_LIB_FILTER;
+
+ @Override
+ public int getRelativeOrder()
+ {
+ return 1000;
+ }
+
+ /**
+ * Get the webInfLibFilter.
+ *
+ * @return the webInfLibFilter.
+ */
+ public VirtualFileFilter getEarLibFilter()
+ {
+ return earLibFilter;
+ }
+
+ /**
+ * Set the webInfLibFilter.
+ *
+ * @param earLibFilter the webInfLibFilter.
+ * @throws IllegalArgumentException for a null filter
+ */
+ public void setEarLibFilter(VirtualFileFilter earLibFilter)
+ {
+ if (earLibFilter == null)
+ throw new IllegalArgumentException("Null filter");
+ this.earLibFilter = earLibFilter;
+ }
+
+ /**
+ * Determine the structure of the ear.
+ * @param root - a candidate ear file
+ * @param metaData - the structure metadata to populate
+ * @param deployers - the deployer chain to use for subdeployment recoginition.
+ */
+ public boolean determineStructure(VirtualFile root,
+ StructureMetaData metaData, StructuredDeployers deployers)
+ {
+ boolean valid = false;
+ try
+ {
+ if( root.isLeaf() == true || root.getName().endsWith(".ear") == false)
+ return false;
+ ContextInfoImpl context = new ContextInfoImpl(root.getPathName());
+ context.setMetaDataPath("META-INF");
+
+ VirtualFile applicationXml = getMetaDataFile(root, "META-INF/application.xml");
+ VirtualFile jbossAppXml = getMetaDataFile(root, "META-INF/jboss-app.xml");
+ VirtualFile lib = null;
+ J2eeApplicationMetaData j2eeMetaData = new J2eeApplicationMetaData();
+ boolean scan = true;
+
+ if (applicationXml != null)
+ {
+ InputStream in = applicationXml.openStream();
+ XmlFileLoader xfl = new XmlFileLoader(false);
+ Element application = xfl.getDocument(in, "META-INF/application.xml").getDocumentElement();
+ j2eeMetaData.importXml(application);
+ in.close();
+ scan = false;
+ }
+ if (jbossAppXml != null)
+ {
+ InputStream in = jbossAppXml.openStream();
+ XmlFileLoader xfl = new XmlFileLoader(false);
+ Element jbossApp = xfl.getDocument(in, "META-INF/jboss-app.xml").getDocumentElement();
+ j2eeMetaData.importXml(jbossApp);
+ in.close();
+ }
+
+ // Add the ear lib contents to the classpath
+ String libDir = j2eeMetaData.getLibraryDirectory() == null ? "lib" : j2eeMetaData.getLibraryDirectory();
+ if (j2eeMetaData.getLibraryDirectory() != null)
+ {
+ try
+ {
+ lib = root.findChild(libDir);
+ if (lib != null)
+ {
+ List<VirtualFile> archives = lib.getChildren(earLibFilter);
+ for (VirtualFile archive : archives)
+ super.addClassPath(root, archive, true, true, context);
+ }
+ }
+ catch (IOException ignored)
+ {
+ // lib directory does not exist
+ }
+ }
+
+ // Add the ear manifest locations?
+ super.addClassPath(root, root, false, true, context);
+ metaData.addContext(context);
+
+ // TODO: need to scan for annotationss
+ if( scan )
+ {
+
+ }
+
+ // Create subdeployments for the ear modules
+ for (Iterator iter = j2eeMetaData.getModules(); iter.hasNext();)
+ {
+ J2eeModuleMetaData mod = (J2eeModuleMetaData) iter.next();
+ String fileName = mod.getFileName();
+ if (fileName != null && (fileName = fileName.trim()).length() > 0)
+ {
+ try
+ {
+ VirtualFile module = root.findChild(fileName);
+ if (module == null)
+ {
+ throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + root.getName());
+ }
+ ContextInfoImpl moduleContext = new ContextInfoImpl(module.getPathName());
+ //moduleContext.getTransientAttachments().addAttachment(J2eeModuleMetaData.class, mod);
+ metaData.addContext(moduleContext);
+ // Add the manifest locations
+ addClassPath(root, module, false, true, moduleContext);
+ }
+ catch (IOException ignored)
+ {
+ throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + root.getName(), ignored);
+ }
+ }
+ }
+
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException("Error determining structure: " + root.getName(), e);
+ }
+
+ return valid;
+ }
+
+ private VirtualFile getMetaDataFile(VirtualFile file, String path)
+ {
+ VirtualFile metaFile = null;
+ try
+ {
+ metaFile = file.findChild(path);
+ }
+ catch(IOException e)
+ {
+ }
+ return metaFile;
+ }
+}
Modified: trunk/server/src/main/org/jboss/deployment/J2eeApplicationMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/J2eeApplicationMetaData.java 2006-10-25 23:12:12 UTC (rev 57836)
+++ trunk/server/src/main/org/jboss/deployment/J2eeApplicationMetaData.java 2006-10-25 23:43:41 UTC (rev 57837)
@@ -29,8 +29,10 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import org.jboss.metadata.IconMetaData;
import org.jboss.metadata.MetaData;
import org.jboss.metadata.SecurityRoleMetaData;
+import org.jboss.mx.loading.LoaderRepositoryFactory;
import org.jboss.mx.util.MBeanServerLocator;
import org.w3c.dom.Element;
@@ -51,17 +53,17 @@
// Attributes ----------------------------------------------------
private String displayName;
private String description;
- private String smallIcon;
- private String largeIcon;
+ private IconMetaData icon = new IconMetaData();
/** The library-directory name, defaults to lib */
private String libDirName = "lib";
/** The application element version */
private String version;
+ private LoaderRepositoryFactory.LoaderRepositoryConfig loaderCfg;
/**
* The security-roles
*/
- private HashMap securityRoles = new HashMap();
+ private HashMap<String, SecurityRoleMetaData> securityRoles = new HashMap<String, SecurityRoleMetaData>();
/**
* The jboss-app.xml JNDI name of the security domain implementation
*/
@@ -71,7 +73,7 @@
*/
private String unauthenticatedPrincipal;
/** The application.xml name->modules in definition order */
- private Map modules = new LinkedHashMap();
+ private Map<String, J2eeModuleMetaData> modules = new LinkedHashMap<String, J2eeModuleMetaData>();
/** The jmx name */
private String jmxName;
@@ -84,25 +86,37 @@
{
return version;
}
+ public void setVersion(String version)
+ {
+ this.version = version;
+ }
public String getDisplayName()
{
return displayName;
}
+ public void setDisplayName(String name)
+ {
+ this.displayName = name;
+ }
public String getDescription()
{
return description;
}
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
public String getSmallIcon()
{
- return smallIcon;
+ return icon.getSmallIcon();
}
public String getLargeIcon()
{
- return largeIcon;
+ return icon.getLargeIcon();
}
public Iterator getModules()
@@ -115,31 +129,63 @@
return modules.containsKey(name);
}
- public Map getSecurityRoles()
+ public Map<String, SecurityRoleMetaData> getSecurityRoles()
{
- return new HashMap(securityRoles);
+ return new HashMap<String, SecurityRoleMetaData>(securityRoles);
}
+ public void addSecurityRole(SecurityRoleMetaData role)
+ {
+ securityRoles.put(role.getRoleName(), role);
+ }
+ public SecurityRoleMetaData getSecurityRole(String name)
+ {
+ return securityRoles.get(name);
+ }
public String getSecurityDomain()
{
return securityDomain;
}
+ public void setSecurityDomain(String domain)
+ {
+ this.securityDomain = domain;
+ }
public String getUnauthenticatedPrincipal()
{
return unauthenticatedPrincipal;
}
+ public void setUnauthenticatedPrincipal(String principal)
+ {
+ this.unauthenticatedPrincipal = principal;
+ }
public String getJMXName()
{
return jmxName;
}
+ public void setJMXName(String name)
+ {
+ this.jmxName = name;
+ }
public String getLibraryDirectory()
{
return libDirName;
}
+ public void setLibraryDirectory(String name)
+ {
+ this.libDirName = name;
+ }
+ public LoaderRepositoryFactory.LoaderRepositoryConfig getLoaderCfg()
+ {
+ return loaderCfg;
+ }
+ public void setLoaderCfg(LoaderRepositoryFactory.LoaderRepositoryConfig loaderCfg)
+ {
+ this.loaderCfg = loaderCfg;
+ }
/**
* Add a module to the module map.
* @param moduleMetaData
@@ -185,16 +231,13 @@
if (iconElement != null)
{
Element element = getOptionalChild(iconElement, "small-icon");
- smallIcon = element != null ? getElementContent(element) : "";
+ String value = element != null ? getElementContent(element) : "";
+ icon.setSmallIcon(value);
element = getOptionalChild(iconElement, "large-icon");
- largeIcon = element != null ? getElementContent(element) : "";
+ value = element != null ? getElementContent(element) : "";
+ icon.setLargeIcon(value);
}
- else
- {
- smallIcon = "";
- largeIcon = "";
- }
// Look for an ear library-directory
libDirName = getOptionalChildContent(rootElement, "library-directory", "lib");
Added: trunk/server/src/main/org/jboss/deployment/J2eeApplicationObjectFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/J2eeApplicationObjectFactory.java 2006-10-25 23:12:12 UTC (rev 57836)
+++ trunk/server/src/main/org/jboss/deployment/J2eeApplicationObjectFactory.java 2006-10-25 23:43:41 UTC (rev 57837)
@@ -0,0 +1,221 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.deployment;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.IconMetaData;
+import org.jboss.metadata.SecurityRoleMetaData;
+import org.jboss.metadata.SecurityRoleRefMetaData;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * An ObjectModelFactory implementation for parsing web.xml descriptors.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class J2eeApplicationObjectFactory implements ObjectModelFactory
+{
+ private static Logger log = Logger.getLogger(J2eeApplicationObjectFactory.class);
+
+ public J2eeApplicationMetaData newRoot(Object root, UnmarshallingContext navigator,
+ String namespaceURI, String localName, Attributes attrs)
+ {
+ J2eeApplicationMetaData metaData = null;
+ if (root != null)
+ metaData = (J2eeApplicationMetaData) root;
+ else
+ metaData = new J2eeApplicationMetaData();
+ return metaData;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx,
+ String uri, String name)
+ {
+ return root;
+ }
+
+ /**
+ * Create the application child elements
+ *
+ * @param dd
+ * @param navigator
+ * @param namespaceURI
+ * @param localName
+ * @param attrs
+ * @return
+ */
+ public Object newChild(J2eeApplicationMetaData dd, UnmarshallingContext navigator,
+ String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+ log.debug("newChild, " + localName);
+
+ // Check attributes
+ String version = attrs.getValue(namespaceURI, "version");
+ if( version != null )
+ dd.setVersion(version);
+
+ // Check elements
+ if (localName.equals("icon"))
+ child = new IconMetaData();
+ else if(localName.equals("module"))
+ child = new J2eeModuleMetaData();
+ else if( localName.equals("security-role"))
+ child = new SecurityRoleMetaData();
+ else if (log.isTraceEnabled())
+ {
+ log.trace("Ignoring: " + localName);
+ }
+ return child;
+ }
+
+ /**
+ * application/module children
+ *
+ * @param module
+ * @param navigator
+ * @param namespaceURI
+ * @param localName
+ * @param attrs
+ * @return
+ */
+ public Object newChild(J2eeModuleMetaData module, UnmarshallingContext navigator,
+ String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+ if (localName.equals("web"))
+ {
+ child = new WebModuleMetaData();
+ }
+ else if (localName.equals("security-role-ref"))
+ {
+ child = new SecurityRoleRefMetaData();
+ }
+ return child;
+ }
+
+ public void addChild(J2eeApplicationMetaData parent, J2eeModuleMetaData module,
+ UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addModule(module);
+ }
+ public void addChild(J2eeApplicationMetaData parent, SecurityRoleMetaData role,
+ UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addSecurityRole(role);
+ }
+
+ /**
+ * Set text values of application/* children
+ * @param dd
+ * @param navigator
+ * @param namespaceURI
+ * @param localName
+ * @param value
+ */
+ public void setValue(J2eeApplicationMetaData dd,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ if( localName.equals("display-name") )
+ dd.setDisplayName(value);
+ else if( localName.equals("description") )
+ dd.setDescription(value);
+ else if( localName.equals("library-directory") )
+ dd.setLibraryDirectory(value);
+ }
+
+ public void setValue(IconMetaData icon,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ if( localName.equals("small-icon") )
+ icon.setSmallIcon(value);
+ if( localName.equals("large-icon") )
+ icon.setLargeIcon(value);
+ }
+ public void setValue(J2eeModuleMetaData module,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ if( localName.equals("ejb") )
+ {
+ module.setType(J2eeModuleMetaData.EJB);
+ module.setFileName(value);
+ }
+ else if( localName.equals("java") )
+ {
+ module.setType(J2eeModuleMetaData.CLIENT);
+ module.setFileName(value);
+ }
+ else if( localName.equals("connector") )
+ {
+ module.setType(J2eeModuleMetaData.CONNECTOR);
+ module.setFileName(value);
+ }
+ else if( localName.equals("service") )
+ {
+ module.setType(J2eeModuleMetaData.SERVICE);
+ module.setFileName(value);
+ }
+ else if( localName.equals("har") )
+ {
+ module.setType(J2eeModuleMetaData.HAR);
+ module.setFileName(value);
+ }
+ else if( localName.equals("alt-dd") )
+ module.setAlternativeDD(value);
+ }
+ public void setValue(WebModuleMetaData module,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ if( localName.equals("web-uri") )
+ {
+ module.setFileName(value);
+ }
+ else if( localName.equals("web-context") )
+ {
+ module.setWebContext(value);
+ }
+ else if( localName.equals("alt-dd") )
+ module.setAlternativeDD(value);
+ }
+
+ public void setValue(SecurityRoleMetaData role,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ if( localName.equals("description") )
+ {
+ role.setDescription(value);
+ }
+ else if( localName.equals("role-name") )
+ {
+ role.setRoleName(value);
+ }
+ }
+
+}
Modified: trunk/server/src/main/org/jboss/deployment/J2eeModuleMetaData.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/J2eeModuleMetaData.java 2006-10-25 23:12:12 UTC (rev 57836)
+++ trunk/server/src/main/org/jboss/deployment/J2eeModuleMetaData.java 2006-10-25 23:43:41 UTC (rev 57837)
@@ -82,6 +82,15 @@
}
}
+ public int getType()
+ {
+ return type;
+ }
+ public void setType(int type)
+ {
+ this.type = type;
+ }
+
public boolean isEjb()
{
return (type == EJB);
@@ -107,11 +116,25 @@
{
return fileName;
}
+ public void setFileName(String name)
+ {
+ this.fileName = name;
+ if( type == WEB )
+ {
+ int dot = fileName.lastIndexOf('.');
+ if( dot >= 0 )
+ webContext = fileName.substring(0, dot);
+ }
+ }
public String getAlternativeDD()
{
return alternativeDD;
}
+ public void setAlternativeDD(String dd)
+ {
+ this.alternativeDD = dd;
+ }
public String getWebContext()
{
@@ -124,6 +147,10 @@
return null;
}
}
+ public void setWebContext(String context)
+ {
+ this.webContext = context;
+ }
public void importXml(Element rootElement) throws DeploymentException
{
Added: trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java 2006-10-25 23:12:12 UTC (rev 57836)
+++ trunk/server/src/main/org/jboss/deployment/JBossAppParsingDeployer.java 2006-10-25 23:43:41 UTC (rev 57837)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.deployment;
+
+import org.jboss.deployers.plugins.deployers.helpers.ObjectModelFactoryDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.xb.binding.ObjectModelFactory;
+
+/**
+ * An ObjectModelFactoryDeployer for translating jboss-app.xml descriptors into
+ * J2eeApplicationMetaData instances.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class JBossAppParsingDeployer extends ObjectModelFactoryDeployer<J2eeApplicationMetaData>
+{
+ /** The name of the application descriptor in the deployment context metadata path */
+ private String appXmlPath = "jboss-app.xml";
+
+ public JBossAppParsingDeployer()
+ {
+ super(J2eeApplicationMetaData.class);
+ }
+
+ /**
+ * Get the virtual file path for the application descriptor in the
+ * DeploymentContext.getMetaDataPath.
+ *
+ * @return the current virtual file path for the application descriptor
+ */
+ public String getAppXmlPath()
+ {
+ return appXmlPath;
+ }
+ /**
+ * Set the virtual file path for the application descriptor in the
+ * DeploymentContext.getMetaDataLocation. The standard path is jboss-app.xml
+ * to be found in the META-INF metdata path.
+ *
+ * @param appXmlPath - new virtual file path for the application descriptor
+ */
+ public void setAppXmlPath(String appXmlPath)
+ {
+ this.appXmlPath = appXmlPath;
+ }
+
+ /**
+ * Overriden to indicate we expect to run the parse even if an existing
+ * J2eeApplicationMetaData attachment is found.
+ * @return true.
+ */
+ @Override
+ protected boolean allowsReparse()
+ {
+ return true;
+ }
+
+ /**
+ * Overriden to order this deployer after the AppParsingDeployer
+ * @return PARSER_DEPLOYER+1
+ */
+ @Override
+ public int getRelativeOrder()
+ {
+ return PARSER_DEPLOYER+1;
+ }
+
+ /**
+ * Return J2eeApplicationObjectFactory as our ObjectModelFactory.
+ * @return a new J2eeApplicationObjectFactory instance
+ */
+ @Override
+ protected ObjectModelFactory getObjectModelFactory(J2eeApplicationMetaData root)
+ {
+ return new JBossApplicationObjectFactory();
+ }
+
+ /**
+ * Overriden to invoke createMetaData(unit, webXmlPath, null) to parse any
+ * webXmlPath descriptor into a WebMetaData instance.
+ */
+ @Override
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ createMetaData(unit, appXmlPath, null);
+ }
+
+}
Added: trunk/server/src/main/org/jboss/deployment/JBossApplicationObjectFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossApplicationObjectFactory.java 2006-10-25 23:12:12 UTC (rev 57836)
+++ trunk/server/src/main/org/jboss/deployment/JBossApplicationObjectFactory.java 2006-10-25 23:43:41 UTC (rev 57837)
@@ -0,0 +1,183 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.deployment;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.SecurityRoleMetaData;
+import org.jboss.mx.loading.LoaderRepositoryFactory;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * An ObjectModelFactory implementation for parsing jboss-app.xml descriptors.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class JBossApplicationObjectFactory implements ObjectModelFactory
+{
+ private static Logger log = Logger.getLogger(JBossApplicationObjectFactory.class);
+ private static ThreadLocal<J2eeApplicationMetaData> activeMetaData
+ = new ThreadLocal<J2eeApplicationMetaData>();
+
+ public J2eeApplicationMetaData newRoot(Object root, UnmarshallingContext navigator,
+ String namespaceURI, String localName, Attributes attrs)
+ {
+ J2eeApplicationMetaData metaData = null;
+ if (root != null)
+ metaData = (J2eeApplicationMetaData) root;
+ else
+ metaData = new J2eeApplicationMetaData();
+ activeMetaData.set(metaData);
+ return metaData;
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx,
+ String uri, String name)
+ {
+ activeMetaData.set(null);
+ return root;
+ }
+
+ /**
+ * Create the application child elements
+ *
+ * @param dd
+ * @param navigator
+ * @param namespaceURI
+ * @param localName
+ * @param attrs
+ * @return
+ */
+ public Object newChild(J2eeApplicationMetaData dd, UnmarshallingContext navigator,
+ String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+ log.debug("newChild, " + localName);
+
+ // Check elements
+ if(localName.equals("module"))
+ child = new J2eeModuleMetaData();
+ else if( localName.equals("security-role"))
+ child = new SecurityRoleMetaData();
+ else if( localName.equals("loader-repository") )
+ child = new LoaderRepositoryFactory.LoaderRepositoryConfig();
+ else if (log.isTraceEnabled())
+ {
+ log.trace("Ignoring: " + localName);
+ }
+ return child;
+ }
+
+ /**
+ *
+ * @param module
+ * @param navigator
+ * @param namespaceURI
+ * @param localName
+ * @param value
+ */
+ public void setValue(J2eeModuleMetaData module,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ if( localName.equals("service") )
+ {
+ module.setType(J2eeModuleMetaData.SERVICE);
+ module.setFileName(value);
+ }
+ else if( localName.equals("har") )
+ {
+ module.setType(J2eeModuleMetaData.HAR);
+ module.setFileName(value);
+ }
+ }
+
+ public void addChild(J2eeApplicationMetaData parent, J2eeModuleMetaData module,
+ UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.addModule(module);
+ }
+
+ public void addChild(J2eeApplicationMetaData parent, LoaderRepositoryFactory.LoaderRepositoryConfig cfg,
+ UnmarshallingContext navigator, String namespaceURI, String localName)
+ {
+ parent.setLoaderCfg(cfg);
+ }
+
+ /**
+ * Set text values of jboss-app/* children
+ * @param dd
+ * @param navigator
+ * @param namespaceURI
+ * @param localName
+ * @param value
+ */
+ public void setValue(J2eeApplicationMetaData dd,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ if( localName.equals("security-domain") )
+ dd.setSecurityDomain(value);
+ else if( localName.equals("unauthenticated-principal") )
+ dd.setUnauthenticatedPrincipal(value);
+ else if( localName.equals("jmx-name") )
+ dd.setJMXName(value);
+
+ }
+
+ public void setValue(SecurityRoleMetaData role,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ if( localName.equals("role-name") )
+ {
+ role.setRoleName(value);
+ }
+ else if( localName.equals("principal-name") )
+ {
+ J2eeApplicationMetaData metaData = activeMetaData.get();
+ SecurityRoleMetaData srmd = metaData.getSecurityRole(role.getRoleName());
+ srmd.addPrincipalName(value);
+ }
+ }
+
+ /*
+ <loader-repository loaderRepositoryClass='dot.com.LoaderRepository'>
+ dot.com:loader=unique-archive-name
+ <loader-repository-config configParserClass='dot.com.LoaderParser'>
+ java2ParentDelegaton=true
+ </loader-repository-config>
+ </loader-repository>
+ */
+ public void setValue(LoaderRepositoryFactory.LoaderRepositoryConfig cfg,
+ UnmarshallingContext navigator, String namespaceURI, String localName,
+ String value)
+ {
+ if( localName.equals("loader-repository-config") )
+ {
+ cfg.repositoryConfig = value;
+ }
+ }
+
+}
More information about the jboss-cvs-commits
mailing list