[jboss-cvs] JBossAS SVN: r93177 - in trunk/server/src/main/org/jboss: web/deployers and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 3 12:12:13 EDT 2009


Author: remy.maucherat at jboss.com
Date: 2009-09-03 12:12:12 -0400 (Thu, 03 Sep 2009)
New Revision: 93177

Added:
   trunk/server/src/main/org/jboss/deployment/TldParsingDeployer.java
   trunk/server/src/main/org/jboss/deployment/WebAppFragmentParsingDeployer.java
Modified:
   trunk/server/src/main/org/jboss/web/deployers/WARStructure.java
Log:
- Add the deployers to parse the tlds and web fragments.
- Needs an update to war-deployers-jboss-beans, but I've found (and fixed) a metadata bug with TLD 2.1,
  so I'm not enabling it yet.

Added: trunk/server/src/main/org/jboss/deployment/TldParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/TldParsingDeployer.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/deployment/TldParsingDeployer.java	2009-09-03 16:12:12 UTC (rev 93177)
@@ -0,0 +1,47 @@
+/*
+ * 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.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.web.spec.TldMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * An ObjectModelFactoryDeployer for translating tag library descriptors into
+ * TldMetaData instances.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision: 82920 $
+ */
+public class TldParsingDeployer extends SchemaResolverDeployer<TldMetaData>
+{
+   /**
+    * Create a new TldParsingDeployer.
+    */
+   public TldParsingDeployer()
+   {
+      super(TldMetaData.class);
+      setSuffix(".tld");
+      setAllowMultipleFiles(true);
+   }
+}

Added: trunk/server/src/main/org/jboss/deployment/WebAppFragmentParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/WebAppFragmentParsingDeployer.java	                        (rev 0)
+++ trunk/server/src/main/org/jboss/deployment/WebAppFragmentParsingDeployer.java	2009-09-03 16:12:12 UTC (rev 93177)
@@ -0,0 +1,67 @@
+/*
+ * 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.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.web.spec.WebFragmentMetaData;
+
+/**
+ * An ObjectModelFactoryDeployer for translating web-fragment.xml descriptors into
+ * WebFragmentMetaData instances.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @author adrian at jboss.org
+ * @version $Revision: 82920 $
+ */
+public class WebAppFragmentParsingDeployer extends SchemaResolverDeployer<WebFragmentMetaData>
+{
+   public WebAppFragmentParsingDeployer()
+   {
+      super(WebFragmentMetaData.class);
+      setName("web-fragment.xml");
+      setAllowMultipleFiles(true);
+   }
+
+   /**
+    * Get the virtual file path for the web-fragment descriptor in the
+    * DeploymentContext.getMetaDataPath.
+    * 
+    * @return the current virtual file path for the web-fragment descriptor
+    */
+   public String getWebFragmentXmlPath()
+   {
+      return getName();
+   }
+   /**
+    * Set the virtual file path for the web-fragment descriptor in the
+    * DeploymentContext.getMetaDataLocation. The standard path is web-fragment.xml
+    * to be found in the /META-INF/ metdata path in JARs located in /WEB-INF/lib
+    * in the webapp.
+    * 
+    * @param WebFragmentMetaData - new virtual file path for the web-fragment descriptor
+    */
+   public void setWebFragmentXmlPath(String WebFragmentMetaData)
+   {
+      setName(WebFragmentMetaData);
+   }
+
+}

Modified: trunk/server/src/main/org/jboss/web/deployers/WARStructure.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/WARStructure.java	2009-09-03 15:06:23 UTC (rev 93176)
+++ trunk/server/src/main/org/jboss/web/deployers/WARStructure.java	2009-09-03 16:12:12 UTC (rev 93177)
@@ -161,6 +161,21 @@
 
             List<String> metaDataLocations = new ArrayList<String>();
             metaDataLocations.add("WEB-INF");
+            
+            // Add all children as locations for TLDs (except classes and lib), recursively
+            webinf = file.getChild("WEB-INF");
+            if (webinf != null)
+            {
+               List<VirtualFile> children = webinf.getChildren();
+               for (VirtualFile child : children)
+               {
+                  if (!isLeaf(child) && (!"lib".equals(child.getName())) && (!"classes".equals(child.getName())))
+                  {
+                     metaDataLocations.add("WEB-INF/" + child.getName());
+                     addPathsRecursively(metaDataLocations, child, "WEB-INF/" + child.getName());
+                  }
+               }
+            }
 
             // Check for WEB-INF/classes
             VirtualFile classes = null;
@@ -170,6 +185,7 @@
                classes = file.getChild("WEB-INF/classes");
                
                // Check for a META-INF for metadata
+               // FIXME: This is not spec legal, descriptors could be loaded from this location
                if (classes != null)
                   metaDataLocations.add("WEB-INF/classes/META-INF");
             }
@@ -248,4 +264,19 @@
          throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);
       }
    }
+   
+   protected void addPathsRecursively(List<String> metaDataLocations, VirtualFile parent, String path)
+   throws IOException
+   {
+      List<VirtualFile> children = parent.getChildren();
+      for (VirtualFile child : children)
+      {
+         if (!isLeaf(child))
+         {
+            metaDataLocations.add(path + "/" + child.getName());
+            addPathsRecursively(metaDataLocations, child, path + "/" + child.getName());
+         }
+      }
+   }
+   
 }




More information about the jboss-cvs-commits mailing list