[jboss-cvs] JBossAS SVN: r90420 - in projects/spider/trunk: dependency-legacy and 25 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 18 08:33:32 EDT 2009


Author: wolfc
Date: 2009-06-18 08:33:32 -0400 (Thu, 18 Jun 2009)
New Revision: 90420

Added:
   projects/spider/trunk/dependency-legacy/
   projects/spider/trunk/dependency-legacy/src/
   projects/spider/trunk/dependency-legacy/src/main/
   projects/spider/trunk/dependency-legacy/src/main/java/
   projects/spider/trunk/dependency-legacy/src/main/java/org/
   projects/spider/trunk/dependency-legacy/src/main/java/org/jboss/
   projects/spider/trunk/dependency-legacy/src/main/java/org/jboss/deployment/
   projects/spider/trunk/dependency-legacy/src/main/java/org/jboss/deployment/dependency/
   projects/spider/trunk/security-legacy/
   projects/spider/trunk/security-legacy/src/
   projects/spider/trunk/security-legacy/src/main/
   projects/spider/trunk/security-legacy/src/main/java/
   projects/spider/trunk/security-legacy/src/main/java/org/
   projects/spider/trunk/security-legacy/src/main/java/org/jboss/
   projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/
   projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/
   projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/EJBPermissionMapping.java
   projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/WebPermissionMapping.java
   projects/spider/trunk/web-legacy/
   projects/spider/trunk/web-legacy/src/
   projects/spider/trunk/web-legacy/src/main/
   projects/spider/trunk/web-legacy/src/main/java/
   projects/spider/trunk/web-legacy/src/main/java/org/
   projects/spider/trunk/web-legacy/src/main/java/org/jboss/
   projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/
   projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/EjbUtil50.java
   projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/LegacyWebXmlLessDeployer.java
Modified:
   projects/spider/trunk/deployers/src/test/resources/conf/bootstrap/war-deployers.xml
   projects/spider/trunk/pom.xml
   projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/EjbJaccPolicy.java
   projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java
   projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/JaccPolicyUtil.java
   projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/WarJaccPolicy.java
   projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/WarPolicyConfigurationFacade.java
   projects/spider/trunk/tomcat-legacy/pom.xml
   projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
   projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/WarEjbResolver.java
   projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
   projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
   projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
Log:
JBAS-7019: forked web-legacy, dependency-legacy and security-legacy. refactored some minor bits to make it compile



Property changes on: projects/spider/trunk/dependency-legacy
___________________________________________________________________
Name: svn:ignore
   + eclipse-target
target


Copied: projects/spider/trunk/dependency-legacy/src/main/java/org/jboss/deployment/dependency (from rev 90404, trunk/server/src/main/org/jboss/deployment/dependency)

Modified: projects/spider/trunk/deployers/src/test/resources/conf/bootstrap/war-deployers.xml
===================================================================
--- projects/spider/trunk/deployers/src/test/resources/conf/bootstrap/war-deployers.xml	2009-06-18 12:06:04 UTC (rev 90419)
+++ projects/spider/trunk/deployers/src/test/resources/conf/bootstrap/war-deployers.xml	2009-06-18 12:33:32 UTC (rev 90420)
@@ -4,7 +4,7 @@
   -->
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
    <!-- See JBAS-6062 -->
-   <bean name="WebXmlLessDeployer" class="org.jboss.deployment.LegacyWebXmlLessDeployer"/>
+   <bean name="WebXmlLessDeployer" class="org.jboss.web.deployers.LegacyWebXmlLessDeployer"/>
    
    <bean name="WarDeployer" class="org.jboss.web.tomcat.service.deployers.TomcatDeployer">
       <property name="domain">jboss.web</property>

Modified: projects/spider/trunk/pom.xml
===================================================================
--- projects/spider/trunk/pom.xml	2009-06-18 12:06:04 UTC (rev 90419)
+++ projects/spider/trunk/pom.xml	2009-06-18 12:33:32 UTC (rev 90420)
@@ -35,6 +35,17 @@
     with the ability to run Servlets.
   </description>
 
+  <properties>
+    <version.jboss.web>2.1.3.GA</version.jboss.web>
+    <version.org.jboss.deployers>2.0.7.GA</version.org.jboss.deployers>
+    <version.org.jboss.jbossas>5.1.0.GA</version.org.jboss.jbossas>
+    <version.org.jboss.jpa>1.0.0</version.org.jboss.jpa>
+    <version.org.jboss.metadata>1.0.1.GA</version.org.jboss.metadata>
+    <version.org.jboss.microcontainer>2.0.6.GA</version.org.jboss.microcontainer>
+    <version.org.jboss.naming>5.0.3.GA</version.org.jboss.naming>
+    <version.org.jboss.security>2.1.0.20090318</version.org.jboss.security>
+  </properties>
+
   <dependencyManagement>
     <dependencies>
       <dependency>
@@ -43,6 +54,99 @@
         <version>4.4</version>
         <scope>test</scope>
       </dependency>
+
+      <!-- or org.jboss.javaee:jboss-jacc-api -->
+      <dependency>
+        <groupId>javax.security</groupId>
+        <artifactId>jacc</artifactId>
+        <version>1.0</version>
+      </dependency>
+
+      <dependency>
+        <groupId>jboss.web</groupId>
+        <artifactId>servlet-api</artifactId>
+        <version>${version.jboss.web}</version>
+      </dependency>
+
+      <!-- java.lang.AssertionError: cannot find method org.jboss.xb.annotations.JBossXmlType.modelGroup() -->
+      <dependency>
+        <groupId>org.jboss</groupId>
+        <artifactId>jbossxb</artifactId>
+        <version>2.0.1.GA</version>
+      </dependency>
+
+      <!-- or java.security:jacc
+      <dependency>
+        <groupId>org.jboss.javaee</groupId>
+        <artifactId>jboss-jacc-api</artifactId>
+      </dependency>
+      -->
+
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-vfs</artifactId>
+        <version>${version.org.jboss.deployers}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-structure-spi</artifactId>
+        <version>${version.org.jboss.deployers}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.deployers</groupId>
+        <artifactId>jboss-deployers-vfs-spi</artifactId>
+        <version>${version.org.jboss.deployers}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.jbossas</groupId>
+        <artifactId>jboss-as-system-jmx</artifactId>
+        <version>${version.org.jboss.jbossas}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.jpa</groupId>
+        <artifactId>jboss-jpa-deployers</artifactId>
+        <version>${version.org.jboss.jpa}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.metadata</groupId>
+        <artifactId>jboss-metadata</artifactId>
+        <version>${version.org.jboss.metadata}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.microcontainer</groupId>
+        <artifactId>jboss-dependency</artifactId>
+        <version>${version.org.jboss.microcontainer}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.microcontainer</groupId>
+        <artifactId>jboss-kernel</artifactId>
+        <version>${version.org.jboss.microcontainer}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.naming</groupId>
+        <artifactId>jnp-client</artifactId>
+        <version>${version.org.jboss.naming}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.security</groupId>
+        <artifactId>jboss-security-spi</artifactId>
+        <version>${version.org.jboss.security}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.security</groupId>
+        <artifactId>jbosssx</artifactId>
+        <version>${version.org.jboss.security}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
@@ -52,7 +156,20 @@
     <testOutputDirectory>${spider.testOutputDirectory}</testOutputDirectory>
 
     <plugins>
+      <!-- 
+        http://el4j.sourceforge.net/plugins/maven-depgraph-plugin/
+        mvn depgraph:depgraph to build a dependency graph
+      -->
       <plugin>
+        <groupId>ch.elca.el4j.maven.plugins</groupId>
+        <artifactId>maven-depgraph-plugin</artifactId>
+        <version>1.7</version>
+        <configuration>
+          <outDir>${project.build.directory}</outDir>
+        </configuration>
+      </plugin>
+
+      <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
 
         <configuration>
@@ -65,8 +182,11 @@
 
   <!-- Aggregate Modules -->
   <modules>
+    <module>dependency-legacy</module>
     <module>deployers</module>
+    <module>security-legacy</module>
     <module>tomcat-legacy</module>
+    <module>web-legacy</module>
   </modules>
 
   <profiles>


Property changes on: projects/spider/trunk/security-legacy
___________________________________________________________________
Name: svn:ignore
   + target
eclipse-target


Copied: projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security (from rev 90333, trunk/server/src/main/org/jboss/deployment/security)

Copied: projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/EJBPermissionMapping.java (from rev 90335, trunk/server/src/main/org/jboss/ejb/EJBPermissionMapping.java)
===================================================================
--- projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/EJBPermissionMapping.java	                        (rev 0)
+++ projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/EJBPermissionMapping.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.security;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.security.jacc.EJBMethodPermission;
+import javax.security.jacc.EJBRoleRefPermission;
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.ExcludeListMetaData;
+import org.jboss.metadata.ejb.spec.MethodInterfaceType;
+import org.jboss.metadata.ejb.spec.MethodPermissionMetaData;
+import org.jboss.metadata.ejb.spec.MethodPermissionsMetaData;
+import org.jboss.metadata.ejb.spec.MethodsMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRoleRefsMetaData;
+
+//$Id$
+
+/**
+ *  Utility class to create the EJB Permissions from the metadata available
+ *  @author Scott.Stark at jboss.org
+ *  @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ *  @since  Dec 12, 2006 
+ *  @version $Revision$
+ */
+public class EJBPermissionMapping
+{
+
+   public static void createPermissions(JBossEnterpriseBeanMetaData bean, PolicyConfiguration pc)
+         throws PolicyContextException
+   {
+      // Process the method-permission MethodMetaData
+      MethodPermissionsMetaData perms = bean.getMethodPermissions();
+      if (perms != null)
+         for (MethodPermissionMetaData perm : perms)
+         {
+            MethodsMetaData methods = perm.getMethods();
+            if (methods != null)
+               for (org.jboss.metadata.ejb.spec.MethodMetaData mmd : methods)
+               {
+                  String[] params =
+                  {};
+                  if (mmd.getMethodParams() != null)
+                     params = mmd.getMethodParams().toArray(params);
+                  else
+                     params = null;
+                  String methodName = mmd.getMethodName();
+                  if (methodName != null && methodName.equals("*"))
+                     methodName = null;
+                  MethodInterfaceType miType = mmd.getMethodIntf();
+                  String iface = miType != null ? miType.name() : null;
+                  EJBMethodPermission p = new EJBMethodPermission(mmd.getEjbName(), methodName, iface, params);
+                  if (perm.getUnchecked() != null)
+                  {
+                     pc.addToUncheckedPolicy(p);
+                  }
+                  else
+                  {
+                     Set<String> roles = perm.getRoles();
+                     Iterator riter = roles.iterator();
+                     while (riter.hasNext())
+                     {
+                        String role = (String) riter.next();
+                        pc.addToRole(role, p);
+                     }
+                  }
+               }
+         }
+
+      // Process the exclude-list MethodMetaData
+      ExcludeListMetaData excluded = bean.getExcludeList();
+      if (excluded != null)
+      {
+         MethodsMetaData methods = excluded.getMethods();
+         if (methods != null)
+            for (org.jboss.metadata.ejb.spec.MethodMetaData mmd : methods)
+            {
+               String[] params =
+               {};
+               if (mmd.getMethodParams() != null)
+                  params = mmd.getMethodParams().toArray(params);
+               else
+                  params = null;
+               String methodName = mmd.getMethodName();
+               if (methodName != null && methodName.equals("*"))
+                  methodName = null;
+               MethodInterfaceType miType = mmd.getMethodIntf();
+               String iface = miType != null ? miType.name() : null;
+               EJBMethodPermission p = new EJBMethodPermission(mmd.getEjbName(), methodName, iface, params);
+               pc.addToExcludedPolicy(p);
+            }
+      }
+
+      // Process the security-role-ref SecurityRoleRefMetaData
+      SecurityRoleRefsMetaData refs = bean.getSecurityRoleRefs();
+      if (refs != null)
+         for (org.jboss.metadata.javaee.spec.SecurityRoleRefMetaData ref : refs)
+         {
+            EJBRoleRefPermission p = new EJBRoleRefPermission(bean.getEjbName(), ref.getRoleName());
+            pc.addToRole(ref.getRoleLink(), p);
+         }
+
+      /* Special handling of stateful session bean getEJBObject due how the
+      stateful session handles acquire the proxy by sending an invocation to
+      the ejb container.
+       */
+      if (bean.isSession())
+      {
+         JBossSessionBeanMetaData smd = (JBossSessionBeanMetaData) bean;
+         if (smd.isStateful())
+         {
+            EJBMethodPermission p = new EJBMethodPermission(bean.getEjbName(), "getEJBObject", "Home", null);
+            pc.addToUncheckedPolicy(p);
+         }
+      }
+   }
+}

Modified: projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/EjbJaccPolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/EjbJaccPolicy.java	2009-06-17 14:22:43 UTC (rev 90333)
+++ projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/EjbJaccPolicy.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -24,7 +24,6 @@
 import javax.security.jacc.PolicyConfiguration;
 import javax.security.jacc.PolicyContextException;
 
-import org.jboss.ejb.EJBPermissionMapping;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
 import org.jboss.metadata.ejb.jboss.JBossMetaData;
@@ -60,4 +59,4 @@
                                                            policyConfiguration);
       } 
    } 
-}
\ No newline at end of file
+}

Modified: projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java	2009-06-17 14:22:43 UTC (rev 90333)
+++ projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -24,7 +24,6 @@
 import javax.security.jacc.PolicyConfiguration;
 import javax.security.jacc.PolicyContextException;
 
-import org.jboss.ejb.EJBPermissionMapping;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
 import org.jboss.metadata.ejb.jboss.JBossMetaData; 
@@ -56,4 +55,4 @@
                                                            policyConfiguration);
       } 
    } 
-}
\ No newline at end of file
+}

Modified: projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/JaccPolicyUtil.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/JaccPolicyUtil.java	2009-06-17 14:22:43 UTC (rev 90333)
+++ projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/JaccPolicyUtil.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -29,12 +29,10 @@
 import javax.security.jacc.PolicyContextException;
 
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.ejb.EJBPermissionMapping;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
 import org.jboss.metadata.ejb.jboss.JBossMetaData;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
 import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.web.WebPermissionMapping;
 
 //$Id$
 

Modified: projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/WarJaccPolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/WarJaccPolicy.java	2009-06-17 14:22:43 UTC (rev 90333)
+++ projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/WarJaccPolicy.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -25,7 +25,6 @@
 import javax.security.jacc.PolicyContextException;
 
 import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.web.WebPermissionMapping;
 
 //$Id$
 

Modified: projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/WarPolicyConfigurationFacade.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/security/WarPolicyConfigurationFacade.java	2009-06-17 14:22:43 UTC (rev 90333)
+++ projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/WarPolicyConfigurationFacade.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -25,7 +25,6 @@
 import javax.security.jacc.PolicyContextException;
 
 import org.jboss.metadata.web.jboss.JBossWebMetaData;
-import org.jboss.web.WebPermissionMapping;
 
 
 /**
@@ -50,4 +49,4 @@
    {
       WebPermissionMapping.createPermissions(metaData, policyConfiguration); 
    } 
-}
\ No newline at end of file
+}

Copied: projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/WebPermissionMapping.java (from rev 90335, trunk/server/src/main/org/jboss/web/WebPermissionMapping.java)
===================================================================
--- projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/WebPermissionMapping.java	                        (rev 0)
+++ projects/spider/trunk/security-legacy/src/main/java/org/jboss/deployment/security/WebPermissionMapping.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -0,0 +1,800 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.security;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.security.jacc.PolicyConfiguration;
+import javax.security.jacc.PolicyContextException;
+import javax.security.jacc.WebResourcePermission;
+import javax.security.jacc.WebRoleRefPermission;
+import javax.security.jacc.WebUserDataPermission;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.SecurityRoleMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRoleRefMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRoleRefsMetaData;
+import org.jboss.metadata.web.jboss.JBossServletMetaData;
+import org.jboss.metadata.web.jboss.JBossServletsMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
+import org.jboss.metadata.web.spec.TransportGuaranteeType;
+import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
+
+//$Id$
+
+/**
+ * A utility class encapsulating the logic for building the web container JACC
+ * permission from a deployment's metadata.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @author Anil.Saldhana at jboss.org
+ * @version $Revision$
+ */
+public class WebPermissionMapping
+{
+   static Logger log = Logger.getLogger(WebPermissionMapping.class);
+
+   /** An prefix pattern "/prefix/*" */
+   private static final int PREFIX = 1;
+   /** An extension pattern "*.ext" */
+   private static final int EXTENSION = 2;
+   /** The "/" default pattern */
+   private static final int DEFAULT  = 3;
+   /** An prefix pattern "/prefix/*" */   
+   private static final int EXACT = 4;
+
+   /**
+    * Apply the JACC rules for creating permissions from the web.xml
+    * security-constraints.
+    * 
+    * @param metaData - the web deployment web.xml/jboss-web.xml metadata
+    * @param pc - the active JACC policy configuration
+    * @throws PolicyContextException
+    */ 
+   public static void createPermissions(JBossWebMetaData metaData, PolicyConfiguration pc)
+      throws PolicyContextException
+   {
+      HashMap<String, PatternInfo> patternMap = qualifyURLPatterns(metaData);
+      log.debug("Qualified url patterns: "+patternMap);
+
+      List<SecurityConstraintMetaData> constraints = metaData.getSecurityContraints();
+      if(constraints != null)
+      {
+         for(SecurityConstraintMetaData sc : constraints)
+         {
+            WebResourceCollectionsMetaData resources = sc.getResourceCollections();
+            TransportGuaranteeType transport = sc.getTransportGuarantee();
+            if( sc.isExcluded() || sc.isUnchecked() )
+            {
+               // Process the permissions for the excluded/unchecked resources
+               if(resources != null)
+               for(WebResourceCollectionMetaData wrc : resources)
+               {
+                  List<String> httpMethods = wrc.getHttpMethods();
+                  List<String> urlPatterns = wrc.getUrlPatterns();
+                  int length = urlPatterns != null ? urlPatterns.size() : 0;
+                  for(int n = 0; n < length; n ++)
+                  {
+                     String url = urlPatterns.get(n);
+                     PatternInfo info = (PatternInfo) patternMap.get(url);
+                     // Add the excluded methods
+                     if( sc.isExcluded() )
+                     {
+                        info.addExcludedMethods(httpMethods);
+                     } 
+                  }
+               }
+            }
+            else
+            {
+               // Process the permission for the resources x roles
+               if(resources != null)
+               for(WebResourceCollectionMetaData wrc : resources)
+               {
+                  List<String> httpMethods = wrc.getHttpMethods();
+                  List<String> urlPatterns = wrc.getUrlPatterns();
+                  int length = urlPatterns != null ? urlPatterns.size() : 0;
+                  for(int n = 0; n < length; n ++)
+                  {
+                     String url = urlPatterns.get(n);
+                     // Get the qualified url pattern
+                     PatternInfo info = (PatternInfo) patternMap.get(url);
+                     HashSet<String> mappedRoles = new HashSet<String>();
+                     if(sc.getRoleNames() != null)
+                     for(String role : sc.getRoleNames())
+                     {
+                        if( role.equals("*") )
+                        {
+                           //JBAS-1824: Allow "*" to provide configurable authorization bypass
+                           if(metaData.isJaccAllStoreRole())
+                              mappedRoles.add("*");
+                           else
+                           { 
+                              // The wildcard ref maps to all declared security-role names
+                              for(SecurityRoleMetaData srmd : metaData.getSecurityRoles())
+                              {
+                                 role = srmd.getRoleName();
+                                 mappedRoles.add(role);
+                              }
+                           }
+                        }
+                        else
+                        {
+                           mappedRoles.add(role);
+                        }
+                     }
+                     info.addRoles(mappedRoles, httpMethods);
+                     // Add the transport to methods
+                     info.addTransport(transport.name(), httpMethods); 
+                     //SECURITY-63: Missing auth-constraint needs unchecked policy
+                     if(sc.getAuthConstraint() == null)
+                        info.isMissingAuthConstraint = true;
+                  }
+               }
+            }
+         }
+      }
+
+      // Create the permissions
+      for(PatternInfo info : patternMap.values())
+      {
+         String qurl = info.getQualifiedPattern();
+         if( info.isOverriden == true )
+         {
+            log.debug("Dropping overriden pattern: "+info);
+            continue;
+         }
+
+         // Create the excluded permissions
+         String[] httpMethods = info.getExcludedMethods();
+         if( httpMethods != null )
+         {
+            // There were excluded security-constraints
+            WebResourcePermission wrp = new WebResourcePermission(qurl, httpMethods);
+            WebUserDataPermission wudp = new WebUserDataPermission(qurl,
+               httpMethods, null);
+            pc.addToExcludedPolicy(wrp);
+            pc.addToExcludedPolicy(wudp);
+            
+            //!(excluded methods)  [JACC 1.1]
+            String excludedString = "!" + getCommaSeparatedString(httpMethods);
+            WebResourcePermission wrp1 = new WebResourcePermission(info.pattern, excludedString);
+            WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern,excludedString);
+            pc.addToUncheckedPolicy(wrp1);
+            pc.addToUncheckedPolicy(wudp1); 
+         }
+
+         // Create the role permissions
+         Iterator<Map.Entry<String, Set<String>>> roles = info.getRoleMethods();
+         while( roles.hasNext() )
+         {
+            Map.Entry<String, Set<String>> roleMethods = roles.next();
+            String role = (String) roleMethods.getKey();
+            WebResourcePermission wrp;
+            if("*".equals(role))
+            {
+               //JBAS-1824: <role-name>*</role-name>    
+               wrp = new WebResourcePermission(qurl, (String)null);
+            }
+            else
+            {
+               Set<String> methods = roleMethods.getValue();
+               httpMethods = new String[methods.size()];
+               methods.toArray(httpMethods);
+               wrp = new WebResourcePermission(qurl, httpMethods);
+            }
+            pc.addToRole(role, wrp);
+            
+            //JACC 1.1: create !(httpmethods) in unchecked perms
+            if(httpMethods != null)
+            {
+               WebResourcePermission wrpUnchecked = new WebResourcePermission(info.pattern, 
+                     "!" + getCommaSeparatedString(httpMethods));
+               pc.addToUncheckedPolicy(wrpUnchecked); 
+            }
+         }
+
+         // Create the unchecked permissions
+         String[] missingHttpMethods = info.getMissingMethods(); 
+         if( missingHttpMethods.length > 0 )
+         {
+            // Create the unchecked permissions WebResourcePermissions
+            WebResourcePermission wrp = new WebResourcePermission(qurl, missingHttpMethods);
+            pc.addToUncheckedPolicy(wrp);  
+         }
+         else
+            pc.addToUncheckedPolicy(new WebResourcePermission(qurl, (String)null));
+         
+         //SECURITY-63: Missing auth-constraint needs unchecked policy 
+         if(info.isMissingAuthConstraint)
+         {
+            pc.addToUncheckedPolicy(new WebResourcePermission(qurl, (String)null));
+         }
+
+         // Create the unchecked permissions WebUserDataPermissions
+         Iterator<Map.Entry<String, Set<String>>> transportContraints = info.getTransportMethods();
+         while( transportContraints.hasNext() )
+         {
+            Map.Entry<String, Set<String>> transportMethods = transportContraints.next();
+            String transport = transportMethods.getKey();
+            Set<String> methods = transportMethods.getValue();
+            httpMethods = new String[methods.size()];
+            methods.toArray(httpMethods);
+            WebUserDataPermission wudp = new WebUserDataPermission(qurl, httpMethods, transport);
+            pc.addToUncheckedPolicy(wudp);
+            
+            //If the transport is "NONE", then add an exlusive WebUserDataPermission
+            //with the url pattern and null
+            if("NONE".equals(transport))
+            {
+               WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern, null);
+               pc.addToUncheckedPolicy(wudp1);
+            } 
+            else
+            {
+               //JACC 1.1: Transport is CONFIDENTIAL/INTEGRAL, add a !(http methods)
+               if(httpMethods != null)
+               {
+                  WebUserDataPermission wudpNonNull = new WebUserDataPermission(info.pattern, 
+                        "!" + getCommaSeparatedString(httpMethods));
+                  pc.addToUncheckedPolicy(wudpNonNull); 
+               }
+            }
+         }
+      }
+
+      /* Create WebRoleRefPermissions for all servlet/security-role-refs along
+      with all the cross product of servlets and security-role elements that
+      are not referenced via a security-role-ref as described in JACC section
+      3.1.3.2
+      */ 
+      JBossServletsMetaData servlets = metaData.getServlets();
+      for(JBossServletMetaData servlet : servlets)
+      {
+         String servletName = servlet.getServletName();
+         SecurityRoleRefsMetaData roleRefs = servlet.getSecurityRoleRefs();
+         //Perform the unreferenced roles processing for every servlet name
+         Set<String> unreferencedRoles = metaData.getSecurityRoleNames();
+         if(roleRefs != null)
+         for(SecurityRoleRefMetaData roleRef : roleRefs)
+         {
+            String roleName = roleRef.getRoleLink();
+            WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, roleRef.getName());
+            pc.addToRole(roleName, wrrp);
+            /* A bit of a hack due to how tomcat calls out to its Realm.hasRole()
+            with a role name that has been mapped to the role-link value. We
+            may need to handle this with a custom request wrapper.
+            */
+            wrrp = new WebRoleRefPermission(servletName, roleName);
+            pc.addToRole(roleRef.getName(), wrrp);
+            // Remove the role from the unreferencedRoles
+            unreferencedRoles.remove(roleName);
+         }
+         
+         //Spec 3.1.3.2: For each servlet element in the deployment descriptor 
+         //a WebRoleRefPermission must be added to each security-role of the 
+         //application whose name does not appear as the rolename 
+         //in a security-role-ref within the servlet element.  
+         if(unreferencedRoles != null)
+         for(String unrefRole : unreferencedRoles)
+         {
+            WebRoleRefPermission unrefP = new WebRoleRefPermission(servletName,unrefRole);
+            pc.addToRole(unrefRole, unrefP);
+         }
+      }
+
+      Set<String> unreferencedRoles = metaData.getSecurityRoleNames();
+      //JACC 1.1:Spec 3.1.3.2: For each security-role defined in the deployment descriptor, an
+      //additional WebRoleRefPermission must be added to the corresponding role by
+      //calling the addToRole method on the PolicyConfiguration object. The
+      //name of all such permissions must be the empty string, and the actions of each
+      //such permission must be the role-name of the corresponding role.
+      if(unreferencedRoles != null)
+      for(String unreferencedRole : unreferencedRoles)
+      {
+        WebRoleRefPermission wrrep = new WebRoleRefPermission("", unreferencedRole);
+        pc.addToRole(unreferencedRole, wrrep); 
+      }
+      
+      // Now build the cross product of the unreferencedRoles and servlets
+      Set<String> servletNames = servlets.keySet();
+      if(servletNames != null)
+      for(String servletName : servletNames)
+      {
+         if(unreferencedRoles != null)
+         for(String role : unreferencedRoles)
+         {
+            WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, role);
+            pc.addToRole(role, wrrp);            
+         }
+      }
+      /**
+       * The programmatic security checks are made from jsps.
+       * JBAS-3054:Use of isCallerInRole from jsp does not work for JACC
+       */
+      if(unreferencedRoles != null)
+      for(String role : unreferencedRoles)
+      {
+         WebRoleRefPermission wrrp = new WebRoleRefPermission("", role);
+         pc.addToRole(role, wrrp);  
+      } 
+   }
+   
+   static String getCommaSeparatedString(String[] str)
+   {
+      int len = str.length; 
+      Arrays.sort(str);
+      
+      StringBuilder buf = new StringBuilder();
+      for(int i = 0; i < len ; i++)
+      {
+         if(i > 0) buf.append(",");
+         buf.append(str[i]);
+      }
+      return buf.toString();
+   }
+
+   /**
+    * Determine the url-pattern type
+    * @param urlPattern - the raw url-pattern value
+    * @return one of EXACT, EXTENSION, PREFIX, DEFAULT
+    */ 
+   static int getPatternType(String urlPattern)
+   {
+      int type = EXACT;
+      if( urlPattern.startsWith("*.") )
+         type = EXTENSION;
+      else if( urlPattern.startsWith("/") && urlPattern.endsWith("/*") ) 
+         type = PREFIX;
+      else if( urlPattern.equals("/") )
+         type = DEFAULT;
+      return type;
+   }
+
+   /**
+    JACC url pattern Qualified URL Pattern Names.
+
+    The rules for qualifying a URL pattern are dependent on the rules for
+    determining if one URL pattern matches another as defined in Section 3.1.3.3,
+    Servlet URL-Pattern Matching Rules, and are described as follows:
+    - If the pattern is a path prefix pattern, it must be qualified by every
+    path-prefix pattern in the deployment descriptor matched by and different from
+    the pattern being qualified. The pattern must also be qualified by every exact
+    pattern appearing in the deployment descriptor that is matched by the pattern
+    being qualified.
+    - If the pattern is an extension pattern, it must be qualified by every
+    path-prefix pattern appearing in the deployment descriptor and every exact
+    pattern in the deployment descriptor that is matched by the pattern being
+    qualified.
+    - If the pattern is the default pattern, "/", it must be qualified by every
+    other pattern except the default pattern appearing in the deployment descriptor.
+    - If the pattern is an exact pattern, its qualified form must not contain any
+    qualifying patterns.
+
+    URL patterns are qualified by appending to their String representation, a
+    colon separated representation of the list of patterns that qualify the pattern.
+    Duplicates must not be included in the list of qualifying patterns, and any
+    qualifying pattern matched by another qualifying pattern may5 be dropped from
+    the list.
+
+    Any pattern, qualified by a pattern that matches it, is overridden and made
+    irrelevant (in the translation) by the qualifying pattern. Specifically, all
+    extension patterns and the default pattern are made irrelevant by the presence
+    of the path prefix pattern "/*" in a deployment descriptor. Patterns qualified
+    by the "/*" pattern violate the URLPatternSpec constraints of
+    WebResourcePermission and WebUserDataPermission names and must be rejected by
+    the corresponding permission constructors.
+
+    @param metaData - the web deployment metadata
+    @return HashMap<String, PatternInfo> 
+    */ 
+   static HashMap<String, PatternInfo> qualifyURLPatterns(JBossWebMetaData metaData)
+   {
+      ArrayList<PatternInfo> prefixList = new ArrayList<PatternInfo>();
+      ArrayList<PatternInfo> extensionList = new ArrayList<PatternInfo>();
+      ArrayList<PatternInfo> exactList = new ArrayList<PatternInfo>();
+      HashMap<String, PatternInfo> patternMap = new HashMap<String, PatternInfo>();
+      PatternInfo defaultInfo = null;
+
+      List<SecurityConstraintMetaData> constraints = metaData.getSecurityContraints();
+      if(constraints != null)
+      {
+         for(SecurityConstraintMetaData sc : constraints)
+         {
+            WebResourceCollectionsMetaData resources = sc.getResourceCollections();
+            for(WebResourceCollectionMetaData wrc : resources)
+            {
+               List<String> urlPatterns = wrc.getUrlPatterns();
+               int length = urlPatterns != null ? urlPatterns.size() : 0;
+               for(int n = 0; n < length; n ++)
+               {
+                  String url = urlPatterns.get(n);
+                  int type = getPatternType(url);
+                  PatternInfo info = (PatternInfo) patternMap.get(url);
+                  if( info == null )
+                  {
+                     info = new PatternInfo(url, type);
+                     patternMap.put(url, info);
+                     switch( type )
+                     {
+                        case PREFIX:
+                           prefixList.add(info);
+                        break;
+                        case EXTENSION:
+                           extensionList.add(info);
+                        break;
+                        case EXACT:
+                           exactList.add(info);
+                        break;
+                        case DEFAULT:
+                           defaultInfo = info;
+                        break;
+                     }
+                  }
+               }
+            }
+         }
+      }
+
+      // Qualify all prefix patterns
+      for(int i = 0; i < prefixList.size(); i ++)
+      {
+         PatternInfo info = (PatternInfo) prefixList.get(i);
+         // Qualify by every other prefix pattern matching this pattern
+         for(int j = 0; j < prefixList.size(); j ++)
+         {
+            if( i == j )
+               continue;
+            PatternInfo other = (PatternInfo) prefixList.get(j);
+            if( info.matches(other) )
+               info.addQualifier(other);
+         }
+         // Qualify by every exact pattern that is matched by this pattern
+         for(int j = 0; j < exactList.size(); j ++)
+         {
+            PatternInfo other = (PatternInfo) exactList.get(j);
+            if( info.matches(other) )
+               info.addQualifier(other);            
+         }
+      }
+
+      // Qualify all extension patterns
+      for(int i = 0; i < extensionList.size(); i ++)
+      {
+         PatternInfo info = (PatternInfo) extensionList.get(i);
+         // Qualify by every path prefix pattern
+         for(int j = 0; j < prefixList.size(); j ++)
+         {
+            PatternInfo other = (PatternInfo) prefixList.get(j);
+            {
+               // Any extension 
+               info.addQualifier(other);
+            }
+         }
+         // Qualify by every matching exact pattern
+         for(int j = 0; j < exactList.size(); j ++)
+         {
+            PatternInfo other = (PatternInfo) exactList.get(j);
+            if( info.isExtensionFor(other) )
+               info.addQualifier(other);            
+         }
+      }
+
+      // Qualify the default pattern
+      if( defaultInfo == null )
+      {
+         defaultInfo = new PatternInfo("/", DEFAULT);
+         patternMap.put("/", defaultInfo);
+      }
+      Iterator iter = patternMap.values().iterator();
+      while( iter.hasNext() )
+      {
+         PatternInfo info = (PatternInfo) iter.next();
+         if( info == defaultInfo )
+            continue;
+         defaultInfo.addQualifier(info);
+      }
+
+      return patternMap;
+   }
+
+   /**
+    * A representation of all security-constraint mappings for a unique
+    * url-pattern
+    */ 
+   static class PatternInfo
+   {
+      static final HashMap<String, Set<String>> ALL_TRANSPORTS = new HashMap<String, Set<String>>();
+      static
+      {
+         ALL_TRANSPORTS.put("NONE", WebResourceCollectionMetaData.ALL_HTTP_METHODS);
+      }
+
+      /** The raw url-pattern string from the web.xml */
+      String pattern;
+      /** The qualified url pattern as determined by qualifyURLPatterns */
+      String qpattern;
+      /** The list of qualifying patterns as determined by qualifyURLPatterns */
+      ArrayList<PatternInfo> qualifiers = new ArrayList<PatternInfo>();
+      /** One of PREFIX, EXTENSION, DEFAULT, EXACT */
+      int type;
+      /** HashSet<String> Union of all http methods seen in excluded statements */
+      HashSet<String> excludedMethods;
+      /** HashMap<String, HashSet<String>> role to http methods */
+      HashMap<String, Set<String>> roles;
+      /** HashMap<String, HashSet<String>> transport to http methods */
+      HashMap<String, Set<String>> transports;
+      // The url pattern to http methods for patterns for 
+      HashSet<String> allMethods = new HashSet<String>();
+      /** Does a qualifying pattern match this pattern and make this pattern
+       * obsolete?
+       */
+      boolean isOverriden;
+      
+      /**
+       * A Security Constraint is missing an <auth-constraint/>
+       */
+      boolean isMissingAuthConstraint;
+
+      /**
+       * @param pattern - the url-pattern value
+       * @param type - one of EXACT, EXTENSION, PREFIX, DEFAULT
+       */ 
+      PatternInfo(String pattern, int type)
+      {
+         this.pattern = pattern;
+         this.type = type;
+      }
+
+      /**
+       * Augment the excluded methods associated with this url 
+       * @param httpMethods
+       */ 
+      void addExcludedMethods(List<String> httpMethods)
+      {
+         Collection<String> methods = httpMethods;
+         if( methods.size() == 0 )
+            methods = WebResourceCollectionMetaData.ALL_HTTP_METHODS;
+         if( excludedMethods == null )
+            excludedMethods = new HashSet<String>();
+         excludedMethods.addAll(methods);
+         allMethods.addAll(methods);
+      }
+      /**
+       * Get the list of excluded http methods
+       * @return excluded http methods if the exist, null if there were no
+       *    excluded security constraints
+       */ 
+      public String[] getExcludedMethods()
+      {
+         String[] httpMethods = null;
+         if( excludedMethods != null )
+         {
+            httpMethods = new String[excludedMethods.size()];
+            excludedMethods.toArray(httpMethods);
+         }
+         return httpMethods;
+      }
+
+      /**
+       * Update the role to http methods mapping for this url.
+       * @param mappedRoles - the role-name values for the auth-constraint
+       * @param httpMethods - the http-method values for the web-resource-collection
+       */ 
+      public void addRoles(HashSet<String> mappedRoles, List<String> httpMethods)
+      {
+         Collection<String> methods = httpMethods;
+         if( methods.size() == 0 )
+            methods = WebResourceCollectionMetaData.ALL_HTTP_METHODS;
+         allMethods.addAll(methods);
+         if( roles == null )
+            roles = new HashMap<String, Set<String>>();
+
+         for(String role : mappedRoles)
+         {
+            Set<String> roleMethods = roles.get(role);
+            if( roleMethods == null )
+            {
+               roleMethods = new HashSet<String>();
+               roles.put(role, roleMethods);
+            }
+            roleMethods.addAll(methods);
+         }
+      }
+      /**
+       * Get the role to http method mappings
+       * @return Iterator<Map.Entry<String, Set<String>>> for the role
+       *    to http method mappings.
+       */ 
+      public Iterator<Map.Entry<String, Set<String>>> getRoleMethods()
+      {
+         HashMap<String, Set<String>> tmp = roles;
+         if( tmp == null )
+            tmp = new HashMap<String, Set<String>>(0);
+         Iterator<Map.Entry<String, Set<String>>> iter = tmp.entrySet().iterator();
+         return iter;
+      }
+
+      /**
+       * Update the role to http methods mapping for this url.
+       * @param transport - the transport-guarantee value
+       * @param httpMethods - the http-method values for the web-resource-collection
+       */ 
+      void addTransport(String transport, List<String> httpMethods)
+      {
+         Collection<String> methods = httpMethods;
+         if( methods.size() == 0 )
+            methods = WebResourceCollectionMetaData.ALL_HTTP_METHODS;
+         if( transports == null )
+            transports = new HashMap<String, Set<String>>();
+
+         Set<String> transportMethods = transports.get(transport);
+         if( transportMethods == null )
+         {
+            transportMethods = new HashSet<String>();
+            transports.put(transport, transportMethods);
+         }
+         transportMethods.addAll(methods);
+      }
+      /**
+       * Get the transport to http method mappings
+       * @return Iterator<Map.Entry<String, Set<String>>> for the transport
+       *    to http method mappings.
+       */ 
+      public Iterator<Map.Entry<String, Set<String>>> getTransportMethods()
+      {
+         HashMap<String, Set<String>> tmp = transports;
+         if( tmp == null )
+            tmp = ALL_TRANSPORTS;
+         Iterator<Map.Entry<String, Set<String>>> iter = tmp.entrySet().iterator();
+         return iter;         
+      }
+
+      /**
+       * Get the list of http methods that were not associated with an excluded
+       * or role based mapping of this url.
+       * 
+       * @return the subset of http methods that should be unchecked
+       */ 
+      public String[] getMissingMethods()
+      {
+         String[] httpMethods = {};
+         if( allMethods.size() == 0 )
+         {
+            // There were no excluded or role based security-constraints
+            httpMethods = WebResourceCollectionMetaData.ALL_HTTP_METHOD_NAMES;
+         }
+         else
+         {
+            httpMethods = WebResourceCollectionMetaData.getMissingHttpMethods(allMethods);
+         }
+         return httpMethods;
+      } 
+
+      /**
+       * Add the qualifying pattern. If info is a prefix pattern that matches
+       * this pattern, it overrides this pattern and will exclude it from
+       * inclusion in the policy.
+       * 
+       * @param info - a url pattern that should qualify this pattern
+       */ 
+      void addQualifier(PatternInfo info)
+      {
+         if( qualifiers.contains(info) == false )
+         {
+            // See if this pattern is matched by the qualifier
+            if( info.type == PREFIX && info.matches(this) )
+               isOverriden = true;
+            qualifiers.add(info);
+         }
+      }
+
+      /**
+       * Get the url pattern with its qualifications
+       * @see WebPermissionMapping#qualifyURLPatterns(org.jboss.metadata.WebMetaData)
+       * @return the qualified form of the url pattern
+       */ 
+      public String getQualifiedPattern()
+      {
+         if( qpattern == null )
+         {
+            StringBuffer tmp = new StringBuffer(pattern);
+            for(int n = 0; n < qualifiers.size(); n ++)
+            {
+               tmp.append(':');
+               PatternInfo info = (PatternInfo) qualifiers.get(n);
+               tmp.append(info.pattern);
+            }
+            qpattern = tmp.toString();
+         }
+         return qpattern;
+      }
+
+      public int hashCode()
+      {
+         return pattern.hashCode();
+      }
+
+      public boolean equals(Object obj)
+      {
+         PatternInfo pi = (PatternInfo) obj;
+         return pattern.equals(pi.pattern);
+      }
+
+      /**
+       * See if this pattern is matches the other pattern
+       * @param other - another pattern
+       * @return true if the other pattern starts with this
+       *    pattern less the "/*", false otherwise
+       */ 
+      public boolean matches(PatternInfo other)
+      {
+         int matchLength = pattern.length()-2;
+         boolean matches = pattern.regionMatches(0, other.pattern, 0, matchLength);
+         return matches;
+      }
+
+      /**
+       * See if this is an extension pattern that matches other
+       * @param other - another pattern
+       * @return true if is an extension pattern and other ends with this
+       *    pattern
+       */ 
+      public boolean isExtensionFor(PatternInfo other)
+      {
+         int offset = other.pattern.lastIndexOf('.');
+         int length = pattern.length() - 1;
+         boolean isExtensionFor = false;
+         if( offset > 0 )
+         {
+            isExtensionFor = pattern.regionMatches(1, other.pattern, offset, length);
+         }
+         return isExtensionFor;
+      } 
+
+      public String toString()
+      {
+         StringBuffer tmp = new StringBuffer("PatternInfo[");
+         tmp.append("pattern=");
+         tmp.append(pattern);
+         tmp.append(",type=");
+         tmp.append(type);
+         tmp.append(",isOverriden=");
+         tmp.append(isOverriden);
+         tmp.append(",qualifiers=");
+         tmp.append(qualifiers);
+         tmp.append("]");
+         return tmp.toString();
+      }
+
+   }
+}

Modified: projects/spider/trunk/tomcat-legacy/pom.xml
===================================================================
--- projects/spider/trunk/tomcat-legacy/pom.xml	2009-06-18 12:06:04 UTC (rev 90419)
+++ projects/spider/trunk/tomcat-legacy/pom.xml	2009-06-18 12:33:32 UTC (rev 90420)
@@ -97,19 +97,33 @@
       <groupId>org.jboss.jbossas</groupId>
       <artifactId>jboss-as-connector</artifactId>
       <version>${version.org.jboss.jbossas}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss.jbossas</groupId>
+          <artifactId>jboss-as-server</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
 
     <dependency>
       <groupId>org.jboss.jbossas</groupId>
       <artifactId>jboss-as-iiop</artifactId>
       <version>${version.org.jboss.jbossas}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss.jbossas</groupId>
+          <artifactId>jboss-as-server</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
 
+<!--
     <dependency>
       <groupId>org.jboss.jbossas</groupId>
       <artifactId>jboss-as-server</artifactId>
       <version>${version.org.jboss.jbossas}</version>
     </dependency>
+-->
 
     <dependency>
       <groupId>org.jboss.security</groupId>
@@ -117,5 +131,17 @@
       <version>2.1.0.20090318</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.jboss.spider</groupId>
+      <artifactId>jboss-spider-dependency-legacy</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.spider</groupId>
+      <artifactId>jboss-spider-web-legacy</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
   </dependencies>
 </project>

Modified: projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
===================================================================
--- projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/TomcatInjectionContainer.java	2009-06-18 12:06:04 UTC (rev 90419)
+++ projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/TomcatInjectionContainer.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -21,6 +21,8 @@
  */
 package org.jboss.web.tomcat.service;
 
+import static org.jboss.deployment.dependency.EndpointMapAttachment.ENDPOINT_MAP_KEY;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
@@ -47,7 +49,6 @@
 import org.apache.InstanceManager;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.deployment.MappedReferenceMetaDataResolverDeployer;
 import org.jboss.deployment.dependency.ContainerDependencyMetaData;
 import org.jboss.deployment.spi.DeploymentEndpointResolver;
 import org.jboss.ejb3.Container;
@@ -207,7 +208,7 @@
       this.catalinaContext = catalinaContext;
       this.persistenceUnitDependencyResolver = resolver;
       this.deploymentEndpointResolver = unit.getAttachment(DeploymentEndpointResolver.class);
-      this.endpointMap = unit.getTopLevel().getAttachment(MappedReferenceMetaDataResolverDeployer.ENDPOINT_MAP_KEY, Map.class);
+      this.endpointMap = unit.getTopLevel().getAttachment(ENDPOINT_MAP_KEY, Map.class);
 
       this.webDD = unit.getAttachment(JBossWebMetaData.class);
       assert this.webDD != null : "webDD is null (no JBossWebMetaData attachment in VFSDeploymentUnit)";

Modified: projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/WarEjbResolver.java
===================================================================
--- projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/WarEjbResolver.java	2009-06-18 12:06:04 UTC (rev 90419)
+++ projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/WarEjbResolver.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -26,10 +26,10 @@
 
 import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.ejb.EjbUtil50;
 import org.jboss.ejb3.DeploymentScope;
 import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.enc.DeploymentEjbResolver;
+import org.jboss.web.deployers.EjbUtil50;
 
 /**
  * Comment

Modified: projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java	2009-06-18 12:06:04 UTC (rev 90419)
+++ projects/spider/trunk/tomcat-legacy/src/main/java/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -53,7 +53,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.metadata.web.jboss.JBossWebMetaData;
 import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.naming.NonSerializableFactory;
+import org.jboss.util.naming.NonSerializableFactory;
 import org.jboss.security.SecurityUtil;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.web.WebApplication;


Property changes on: projects/spider/trunk/web-legacy
___________________________________________________________________
Name: svn:ignore
   + eclipse-target
target


Copied: projects/spider/trunk/web-legacy/src/main/java/org/jboss/web (from rev 90315, trunk/server/src/main/org/jboss/web)

Modified: projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/AbstractWarDeployment.java	2009-06-17 10:51:02 UTC (rev 90315)
+++ projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -40,7 +40,7 @@
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.ejb.EjbUtil50;
+//import org.jboss.ejb.EjbUtil50;
 import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
 import org.jboss.kernel.Kernel;
 import org.jboss.logging.Logger;
@@ -63,7 +63,7 @@
 import org.jboss.metadata.serviceref.VirtualFileAdaptor;
 import org.jboss.metadata.web.jboss.JBossWebMetaData;
 import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.jboss.naming.NonSerializableFactory;
+import org.jboss.util.naming.NonSerializableFactory;
 import org.jboss.naming.Util;
 import org.jboss.security.ISecurityManagement;
 import org.jboss.security.SecurityConstants;

Copied: projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/EjbUtil50.java (from rev 90387, trunk/server/src/main/org/jboss/ejb/EjbUtil50.java)
===================================================================
--- projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/EjbUtil50.java	                        (rev 0)
+++ projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/EjbUtil50.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -0,0 +1,435 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.web.deployers;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEntityBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.util.Strings;
+
+/** 
+ * Utility methods for resolving ejb-ref and ejb-local-ref within the
+ * scope of a deployment.
+ *
+ * @deprecated duplicates logic provided by resolvers
+ *
+ * @author <a href="mailto:criege at riege.com">Christian Riege</a>
+ * @author Scott.Stark at jboss.org
+ * @author Thomas.Diesler at jboss.org
+ *
+ * @version $Revision$
+ */
+public final class EjbUtil50
+{
+   private static final Logger log = Logger.getLogger(EjbUtil50.class);
+
+   /**
+    * Resolves an &lt;ejb-link&gt; target for an &lt;ejb-ref&gt; entry and
+    * returns the name of the target in the JNDI tree.
+    *
+    * @param server the main deployer
+    * @param unit DeploymentUnit
+    * @param link Content of the &lt;ejb-link&gt; entry.
+    *
+    * @return The JNDI Entry of the target bean; <code>null</code> if
+    *         no appropriate target could be found.
+    */
+   public static String findEjbLink(MainDeployerStructure server, DeploymentUnit unit, String link)
+   {
+      return resolveLink(server, unit, link, false);
+   }
+
+   /**
+    * Resolves an &lt;ejb-link&gt; target for an &lt;ejb-local-ref&gt; entry
+    * and returns the name of the target in the JNDI tree.
+    *
+    * @param server the main deployer
+    * @param unit DeploymentUnit
+    * @param link Content of the &lt;ejb-link&gt; entry.
+    *
+    * @return The JNDI Entry of the target bean; <code>null</code> if
+    *         no appropriate target could be found.
+    */
+   public static String findLocalEjbLink(MainDeployerStructure server, DeploymentUnit unit, String link)
+   {
+      return resolveLink(server, unit, link, true);
+   }
+
+   /**
+    * Resolves a &lt;message-destination&gt; target for a &lt;message-destination-link&gt; 
+    * entry and returns the name of the target in the JNDI tree.
+    *
+    * @param server the main deployer
+    * @param di DeploymentUnit
+    * @param link Content of the &lt;message-driven-link&gt; entry.
+    *
+    * @return The JNDI Entry of the target; <code>null</code> if
+    *         no appropriate target could be found.
+    */
+   public static MessageDestinationMetaData findMessageDestination(MainDeployerStructure server, DeploymentUnit di, String link)
+   {
+      return resolveMessageDestination(server, di, link);
+   }
+
+   private static String resolveLink(MainDeployerStructure server, DeploymentUnit di, String link, boolean isLocal)
+   {
+      if (link == null)
+      {
+         return null;
+      }
+
+      if (log.isTraceEnabled())
+      {
+         log.trace("resolveLink( {" + di + "}, {" + link + "}, {" + isLocal + "}");
+      }
+
+      if (di == null)
+      {
+         // We should throw an IllegalArgumentException here probably?
+         return null;
+      }
+
+      if (link.indexOf('#') != -1)
+      {
+         // <ejb-link> is specified in the form path/file.jar#Bean
+         return resolveRelativeLink(server, di, link, isLocal);
+      }
+      else
+      {
+         // <ejb-link> contains a Bean Name, scan the DeploymentUnit tree
+         DeploymentUnit top = di.getTopLevel();
+         return resolveAbsoluteLink(top, link, isLocal);
+      }
+   }
+
+   private static String resolveRelativeLink(MainDeployerStructure server, DeploymentUnit unit, String link, boolean isLocal)
+   {
+
+      String path = link.substring(0, link.indexOf('#'));
+      String ejbName = link.substring(link.indexOf('#') + 1);
+      String us = unit.getName();
+
+      // Remove the trailing slash for unpacked deployments
+      if (us.charAt(us.length() - 1) == '/')
+         us = us.substring(0, us.length() - 1);
+
+      String ourPath = us.substring(0, us.lastIndexOf('/'));
+
+      if (log.isTraceEnabled())
+      {
+         log.trace("Resolving relative link: " + link);
+         log.trace("Looking for: '" + link + "', we're located at: '" + ourPath + "'");
+      }
+
+      for (StringTokenizer st = new StringTokenizer(path, "/"); st.hasMoreTokens();)
+      {
+         String s = st.nextToken();
+         if (s.equals(".."))
+         {
+            ourPath = ourPath.substring(0, ourPath.lastIndexOf('/'));
+         }
+         else
+         {
+            ourPath += "/" + s;
+         }
+      }
+
+      URL target = null;
+
+      try
+      {
+         target = Strings.toURL(ourPath);
+      }
+      catch (MalformedURLException mue)
+      {
+         log.warn("Can't construct URL for: " + ourPath);
+         return null;
+      }
+
+      DeploymentUnit targetUnit = null;
+      try
+      {
+         DeploymentContext ctx = server.getDeploymentContext(target.toString());
+         targetUnit = ctx.getDeploymentUnit();
+      }
+      catch (Exception e)
+      {
+         log.warn("Got Exception when looking for DeploymentUnit: " + e);
+         return null;
+      }
+
+      if (targetUnit == null)
+      {
+         log.warn("Can't locate DeploymentUnit for target: " + target);
+         return null;
+      }
+
+      if (log.isTraceEnabled())
+      {
+         log.trace("Found appropriate DeploymentUnit: " + targetUnit);
+      }
+
+      String linkTarget = null;
+      if (targetUnit.getAttachment(JBossMetaData.class) != null)
+      {
+         JBossMetaData appMD = targetUnit.getAttachment(JBossMetaData.class);
+         JBossEnterpriseBeanMetaData beanMD = appMD.getEnterpriseBean(ejbName);
+
+         if (beanMD != null)
+         {
+            linkTarget = getJndiName(beanMD, isLocal);
+         }
+         else
+         {
+            log.warn("No Bean named '" + ejbName + "' found in '" + path + "'!");
+         }
+      }
+      else
+      {
+         log.warn("DeploymentUnit " + targetUnit + " is not an EJB .jar " + "file!");
+      }
+
+      return linkTarget;
+   }
+
+   private static String resolveAbsoluteLink(DeploymentUnit unit, String link, boolean isLocal)
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Resolving absolute link, di: " + unit);
+      }
+
+      String ejbName = null;
+
+      // Search current DeploymentUnit
+      if (unit.getAttachment(JBossMetaData.class) != null)
+      {
+         JBossMetaData appMD = unit.getAttachment(JBossMetaData.class);
+         JBossEnterpriseBeanMetaData beanMD = appMD.getEnterpriseBean(link);
+         if (beanMD != null)
+         {
+            ejbName = getJndiName(beanMD, isLocal);
+            if (log.isTraceEnabled())
+            {
+               log.trace("Found Bean: " + beanMD + ", resolves to: " + ejbName);
+            }
+
+            return ejbName;
+         }
+         else if (log.isTraceEnabled())
+         {
+            // Dump the ejb module ejbNames
+            log.trace("No match for ejb-link: " + link + ", module names:");
+            for(JBossEnterpriseBeanMetaData md : appMD.getEnterpriseBeans())
+            {
+               String beanEjbName = getJndiName(md, isLocal);
+               log.trace("... ejbName: " + beanEjbName);
+            }
+         }
+      }
+      else if (unit.getAttachment("EJB_DEPLOYMENTS") != null)
+      {
+         log.debug("Saw EJB3 module, cannot resolve it");
+      }
+
+      // Search each subcontext
+      Iterator<DeploymentUnit> it = unit.getChildren().iterator();
+      while (it.hasNext() && ejbName == null)
+      {
+         DeploymentUnit child = it.next();
+         ejbName = resolveAbsoluteLink(child, link, isLocal);
+      }
+
+      return ejbName;
+   }
+
+   private static String getJndiName(JBossEnterpriseBeanMetaData beanMD, boolean isLocal)
+   {
+      String jndiName = null;
+      if (isLocal)
+      {
+         // Validate that there is a local home associated with this bean
+         jndiName = beanMD.determineLocalJndiName();
+         if (jndiName == null)
+         {
+            log.warn("LocalHome jndi name requested for: '" + beanMD.getEjbName() + "' but there is no LocalHome class");
+         }
+      }
+      else
+      {
+         if( beanMD.isEntity() )
+         {
+            JBossEntityBeanMetaData md = (JBossEntityBeanMetaData) beanMD;
+            jndiName = md.determineJndiName();
+         }
+         else if( beanMD.isSession())
+         {
+            JBossSessionBeanMetaData md = (JBossSessionBeanMetaData) beanMD;
+            jndiName = md.determineJndiName();
+         }
+      }
+      return jndiName;
+   }
+
+   private static MessageDestinationMetaData resolveMessageDestination(MainDeployerStructure server, DeploymentUnit di, String link)
+   {
+      if (link == null)
+         return null;
+
+      if (log.isTraceEnabled())
+         log.trace("resolveLink( {" + di + "}, {" + link + "})");
+
+      if (di == null)
+         // We should throw an IllegalArgumentException here probably?
+         return null;
+
+      if (link.indexOf('#') != -1)
+         // link is specified in the form path/file.jar#Bean
+         return resolveRelativeMessageDestination(server, di, link);
+      else
+      {
+         // link contains a Bean Name, scan the DeploymentUnit tree
+         DeploymentUnit top = di.getTopLevel();
+         return resolveAbsoluteMessageDestination(top, link);
+      }
+   }
+
+   private static MessageDestinationMetaData resolveRelativeMessageDestination(MainDeployerStructure server, DeploymentUnit unit, String link)
+   {
+      String path = link.substring(0, link.indexOf('#'));
+      String destinationName = link.substring(link.indexOf('#') + 1);
+      String us = unit.getName();
+
+      // Remove the trailing slash for unpacked deployments
+      if (us.charAt(us.length() - 1) == '/')
+         us = us.substring(0, us.length() - 1);
+
+      String ourPath = us.substring(0, us.lastIndexOf('/'));
+
+      if (log.isTraceEnabled())
+      {
+         log.trace("Resolving relative message-destination-link: " + link);
+         log.trace("Looking for: '" + link + "', we're located at: '" + ourPath + "'");
+      }
+
+      for (StringTokenizer st = new StringTokenizer(path, "/"); st.hasMoreTokens();)
+      {
+         String s = st.nextToken();
+         if (s.equals(".."))
+            ourPath = ourPath.substring(0, ourPath.lastIndexOf('/'));
+         else ourPath += "/" + s;
+      }
+
+      URL target = null;
+      try
+      {
+         target = Strings.toURL(ourPath);
+      }
+      catch (MalformedURLException mue)
+      {
+         log.warn("Can't construct URL for: " + ourPath);
+         return null;
+      }
+
+      DeploymentUnit targetUnit = null;
+      try
+      {
+         DeploymentContext ctx = server.getDeploymentContext(target.toString());
+         targetUnit = ctx.getDeploymentUnit();
+      }
+      catch (Exception e)
+      {
+         log.warn("Got Exception when looking for DeploymentUnit: " + e);
+         return null;
+      }
+
+      if (targetUnit == null)
+      {
+         log.warn("Can't locate DeploymentUnit for target: " + target);
+         return null;
+      }
+
+      if (log.isTraceEnabled())
+         log.trace("Found appropriate DeploymentUnit: " + targetUnit);
+
+      if (targetUnit.getAttachment(JBossMetaData.class) != null)
+      {
+         JBossMetaData appMD = targetUnit.getAttachment(JBossMetaData.class);
+         return appMD.getAssemblyDescriptor().getMessageDestination(destinationName);
+      }
+      if (targetUnit.getAttachment(JBossWebMetaData.class) != null)
+      {
+         JBossWebMetaData webMD = targetUnit.getAttachment(JBossWebMetaData.class);
+         return webMD.getMessageDestination(destinationName);
+      }
+      else
+      {
+         log.warn("DeploymentUnit " + targetUnit + " is not an EJB .jar " + "file!");
+         return null;
+      }
+   }
+
+   private static MessageDestinationMetaData resolveAbsoluteMessageDestination(DeploymentUnit unit, String link)
+   {
+      if (log.isTraceEnabled())
+         log.trace("Resolving absolute link, di: " + unit);
+
+      // Search current DeploymentUnit
+      if (unit.getAttachment(JBossMetaData.class) != null)
+      {
+         JBossMetaData appMD = unit.getAttachment(JBossMetaData.class);
+         MessageDestinationMetaData mdMD = appMD.getAssemblyDescriptor().getMessageDestination(link);
+         if (mdMD != null)
+            return mdMD;
+      }
+      if (unit.getAttachment(JBossWebMetaData.class) != null)
+      {
+         JBossWebMetaData webMD = unit.getAttachment(JBossWebMetaData.class);
+         return webMD.getMessageDestination(link);
+      }
+
+      // Search each subcontext
+      Iterator<DeploymentUnit> it = unit.getChildren().iterator();
+      while (it.hasNext())
+      {
+         DeploymentUnit child = it.next();
+         MessageDestinationMetaData mdMD = resolveAbsoluteMessageDestination(child, link);
+         if (mdMD != null)
+            return mdMD;
+      }
+
+      // Not found
+      return null;
+   }
+}

Copied: projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/LegacyWebXmlLessDeployer.java (from rev 90415, trunk/server/src/main/org/jboss/deployment/LegacyWebXmlLessDeployer.java)
===================================================================
--- projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/LegacyWebXmlLessDeployer.java	                        (rev 0)
+++ projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/LegacyWebXmlLessDeployer.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -0,0 +1,63 @@
+/*
+ * 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.web.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
+
+/**
+ * Support jsp's w/o web.xml.
+ * See JBAS-6062 for more details.
+ *
+ * @author ales.justin at jboss.org
+ */
+public class LegacyWebXmlLessDeployer extends AbstractDeployer
+{
+   public LegacyWebXmlLessDeployer()
+   {
+      addInput(WebMetaData.class);
+      addInput(JBossWebMetaData.class);
+      setOutput(JBossWebMetaData.class);
+      setStage(DeploymentStages.POST_PARSE);
+   }
+
+   public void deploy(DeploymentUnit unit) throws DeploymentException
+   {
+      if (unit.getSimpleName().endsWith(".war"))
+      {
+         if (unit.isAttachmentPresent(JBossWebMetaData.class))
+            return;
+
+         // only care about true deployments
+         if (unit instanceof VFSDeploymentUnit == false)
+            return;
+
+         log.debug("Web archive doesn't contain web.xml: " + unit.getName());
+         unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, new JBossWebMetaData());
+      }
+   }
+}

Modified: projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java	2009-06-17 10:51:02 UTC (rev 90315)
+++ projects/spider/trunk/web-legacy/src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java	2009-06-18 12:33:32 UTC (rev 90420)
@@ -25,7 +25,7 @@
 import org.jboss.deployers.spi.deployer.DeploymentStages;
 import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployment.AnnotationMetaDataDeployer;
+//import org.jboss.deployment.AnnotationMetaDataDeployer;
 import org.jboss.metadata.ear.jboss.JBossAppMetaData;
 import org.jboss.metadata.web.spec.AnnotationMergedView;
 import org.jboss.metadata.web.jboss.JBossWebMetaData;
@@ -44,6 +44,9 @@
  */
 public class MergedJBossWebMetaDataDeployer extends AbstractDeployer
 {
+   // FIXME: this is actually defined in AnnotationMetaDataDeployer
+   //public static final String WEB_ANNOTATED_ATTACHMENT_NAME = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME;
+   public static final String WEB_ANNOTATED_ATTACHMENT_NAME = "annotated."+WebMetaData.class.getName();
    public static final String WEB_MERGED_ATTACHMENT_NAME = "merged."+JBossWebMetaData.class.getName();
 
    /**
@@ -57,7 +60,7 @@
       // jboss.xml metadata
       addInput(JBossWebMetaData.class);
       // annotated metadata view
-      addInput(AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME);
+      addInput(WEB_ANNOTATED_ATTACHMENT_NAME);
       // Output is the merge JBossWebMetaData view
       setOutput(JBossWebMetaData.class);
       // 
@@ -72,7 +75,7 @@
          return;
 
       // Check for an annotated view
-      String key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME;
+      String key = WEB_ANNOTATED_ATTACHMENT_NAME;
       Web25MetaData annotatedMetaData = unit.getAttachment(key, Web25MetaData.class);
       if(annotatedMetaData != null)
       {




More information about the jboss-cvs-commits mailing list