[Jboss-cvs] JBossAS SVN: r55497 - in trunk/tomcat: . src/main/org/jboss/web/metamodel/descriptor src/main/org/jboss/web/tomcat/tc6

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 10 15:11:39 EDT 2006


Author: bill.burke at jboss.com
Date: 2006-08-10 15:11:32 -0400 (Thu, 10 Aug 2006)
New Revision: 55497

Modified:
   trunk/tomcat/build.xml
   trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/JBossWebDDObjectFactory.java
   trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/WebDDObjectFactory.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatDeployer.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/WebAppLoader.java
Log:
implementation and some testing of injeciton annotations for WAR components

Modified: trunk/tomcat/build.xml
===================================================================
--- trunk/tomcat/build.xml	2006-08-10 19:09:37 UTC (rev 55496)
+++ trunk/tomcat/build.xml	2006-08-10 19:11:32 UTC (rev 55497)
@@ -80,6 +80,8 @@
       <path refid="jboss.cache.classpath"/>
       <path refid="jboss.aop.classpath"/>
       <path refid="jboss.aspects.classpath"/>
+      <path refid="jboss.ejb3x.classpath"/>
+      <path refid="jboss.ejb3.classpath"/>
       <path refid="jboss.jca.classpath"/>
       <path refid="jboss.transaction.classpath"/>
     </path>

Modified: trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/JBossWebDDObjectFactory.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/JBossWebDDObjectFactory.java	2006-08-10 19:09:37 UTC (rev 55496)
+++ trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/JBossWebDDObjectFactory.java	2006-08-10 19:11:32 UTC (rev 55497)
@@ -18,13 +18,17 @@
 * 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.metamodel.descriptor;
 
-import java.io.IOException;
-import java.net.URL;
-
 import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
+import org.jboss.metamodel.descriptor.EjbRef;
+import org.jboss.metamodel.descriptor.EnvEntry;
+import org.jboss.metamodel.descriptor.MessageDestinationRef;
+import org.jboss.metamodel.descriptor.ResourceEnvRef;
+import org.jboss.metamodel.descriptor.ResourceRef;
 import org.jboss.util.xml.JBossEntityResolver;
 import org.jboss.xb.binding.JBossXBException;
 import org.jboss.xb.binding.ObjectModelFactory;
@@ -33,13 +37,9 @@
 import org.jboss.xb.binding.UnmarshallingContext;
 import org.xml.sax.Attributes;
 
-import org.jboss.metamodel.descriptor.DDObjectFactory;
-import org.jboss.metamodel.descriptor.EjbRef;
-import org.jboss.metamodel.descriptor.EjbLocalRef;
-import org.jboss.metamodel.descriptor.EnvEntry;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
-import org.jboss.metamodel.descriptor.ResourceRef;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
 
 /**
  * org.jboss.xb.binding.ObjectModelFactory implementation that accepts data
@@ -52,37 +52,41 @@
 {
    private static final Logger log = Logger
            .getLogger(JBossWebDDObjectFactory.class);
-   
+
    private WebDD dd;
-   
+
    public static WebDD parse(URL ddResource, WebDD dd)
-      throws JBossXBException, IOException
+           throws JBossXBException, IOException
    {
+      if (ddResource == null) return null;
+      log.debug("found jboss-web.xml " + ddResource);
+
+      InputStream is = ddResource.openStream();
+
+      return parse(dd, is);
+   }
+
+   public static WebDD parse(WebDD dd, InputStream is)
+           throws JBossXBException
+   {
       ObjectModelFactory factory = null;
       Unmarshaller unmarshaller = null;
-      
-      if (ddResource != null)
-      {
-         log.debug("found jboss-web.xml " + ddResource);
-         
-         if (dd == null)
-            dd = new WebDD();
-      
-         factory = new JBossWebDDObjectFactory(dd);
-         UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory
-               .newInstance();
-  //       unmarshallerFactory.setFeature(Unmarshaller.SCHEMA_VALIDATION, Boolean.TRUE);
-         unmarshaller = unmarshallerFactory.newUnmarshaller();
-         JBossEntityResolver entityResolver = new JBossEntityResolver();
-         unmarshaller.setEntityResolver(entityResolver);
-      
-         dd = (WebDD) unmarshaller.unmarshal(ddResource.openStream(),
-               factory, null);
-      }
-   
+
+      if (dd == null) dd = new WebDD();
+
+      factory = new JBossWebDDObjectFactory(dd);
+      UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory
+              .newInstance();
+      //       unmarshallerFactory.setFeature(Unmarshaller.SCHEMA_VALIDATION, Boolean.TRUE);
+      unmarshaller = unmarshallerFactory.newUnmarshaller();
+      JBossEntityResolver entityResolver = new JBossEntityResolver();
+      unmarshaller.setEntityResolver(entityResolver);
+
+      dd = (WebDD) unmarshaller.unmarshal(is, factory, null);
+
       return dd;
    }
-   
+
    public JBossWebDDObjectFactory(WebDD dd)
    {
       super();
@@ -125,11 +129,11 @@
 
       return child;
    }
-   
+
    public void addChild(WebDD parent, ReplicationConfig config,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
-    parent.setReplicationConfig(config);
+      parent.setReplicationConfig(config);
    }
 
    public void addChild(WebDD parent, EjbLocalRef ref,
@@ -137,52 +141,52 @@
    {
       parent.updateEjbLocalRef(ref);
    }
-   
+
    public void addChild(WebDD parent, EjbRef ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.updateEjbRef(ref);
    }
-  
+
    public void addChild(WebDD parent, EnvEntry ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addEnvEntry(ref);
    }
-   
+
    public void addChild(WebDD parent, MessageDestinationRef ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.updateMessageDestinationRef(ref);
    }
-   
+
    public void addChild(WebDD parent, ResourceEnvRef ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.updateResourceEnvRef(ref);
    }
-   
+
    public void addChild(WebDD parent, ResourceRef ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.updateResourceRef(ref);
    }
-   
+
    public void addChild(WebDD parent, SecurityRole role,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.updateSecurityRole(role);
    }
-   
+
    public void addChild(WebDD parent, Servlet servlet,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.updateServlet(servlet);
    }
-   
+
    public void setValue(WebDD dd,
-         UnmarshallingContext navigator, String namespaceURI, String localName,
-         String value)
+                        UnmarshallingContext navigator, String namespaceURI, String localName,
+                        String value)
    {
       if (localName.equals("depends"))
       {
@@ -193,10 +197,10 @@
          dd.setSecurityDomain(value);
       }
    }
-   
+
    public void setValue(ReplicationConfig config,
-         UnmarshallingContext navigator, String namespaceURI, String localName,
-         String value)
+                        UnmarshallingContext navigator, String namespaceURI, String localName,
+                        String value)
    {
       if (localName.equals("replication-trigger"))
       {
@@ -225,7 +229,7 @@
          servlet.addRunAsPrincipal(value);
       }
    }
-   
+
    public void setValue(ServletMapping mapping,
                         UnmarshallingContext navigator, String namespaceURI, String localName,
                         String value)
@@ -239,16 +243,16 @@
          mapping.setUrlPattern(value);
       }
    }
-   
+
    public void setValue(SecurityRole role,
-         UnmarshallingContext navigator, String namespaceURI, String localName,
-         String value)
+                        UnmarshallingContext navigator, String namespaceURI, String localName,
+                        String value)
    {
       if (localName.equals("principal-name"))
       {
          role.setPrincipalName(value);
       }
-      else 
+      else
          super.setValue(role, navigator, namespaceURI, localName, value);
    }
 }

Modified: trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/WebDDObjectFactory.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/WebDDObjectFactory.java	2006-08-10 19:09:37 UTC (rev 55496)
+++ trunk/tomcat/src/main/org/jboss/web/metamodel/descriptor/WebDDObjectFactory.java	2006-08-10 19:11:32 UTC (rev 55497)
@@ -18,24 +18,13 @@
 * 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.metamodel.descriptor;
 
-import java.io.IOException;
-import java.net.URL;
-
 import org.jboss.logging.Logger;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.xml.sax.Attributes;
-
 import org.jboss.metamodel.descriptor.DDObjectFactory;
+import org.jboss.metamodel.descriptor.EjbLocalRef;
 import org.jboss.metamodel.descriptor.EjbRef;
-import org.jboss.metamodel.descriptor.EjbLocalRef;
 import org.jboss.metamodel.descriptor.EnvEntry;
 import org.jboss.metamodel.descriptor.Listener;
 import org.jboss.metamodel.descriptor.MessageDestination;
@@ -45,7 +34,18 @@
 import org.jboss.metamodel.descriptor.ResourceRef;
 import org.jboss.metamodel.descriptor.RunAs;
 import org.jboss.metamodel.descriptor.SecurityRoleRef;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
 /**
  * org.jboss.xb.binding.ObjectModelFactory implementation that accepts data
  * chuncks from unmarshaller and assembles them into an WebDD instance.
@@ -57,30 +57,34 @@
 {
    private static final Logger log = Logger
            .getLogger(WebDDObjectFactory.class);
-   
+
    public static WebDD parse(URL ddResource)
-      throws JBossXBException, IOException
+           throws JBossXBException, IOException
    {
+      if (ddResource == null) return null;
+      log.debug("found web.xml " + ddResource);
+      InputStream is = ddResource.openStream();
+
+      return parse(is);
+   }
+
+   public static WebDD parse(InputStream is)
+           throws JBossXBException
+   {
       ObjectModelFactory factory = null;
       Unmarshaller unmarshaller = null;
       WebDD dd = null;
-      
-      if (ddResource != null)
-      {
-         log.debug("found web.xml " + ddResource);
-      
-         factory = new WebDDObjectFactory();
-         UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory
-               .newInstance();
- //        unmarshallerFactory.setFeature(Unmarshaller.SCHEMA_VALIDATION, Boolean.TRUE);
-         unmarshaller = unmarshallerFactory.newUnmarshaller();
-         JBossEntityResolver entityResolver = new JBossEntityResolver();
-         unmarshaller.setEntityResolver(entityResolver);
-      
-         dd = (WebDD) unmarshaller.unmarshal(ddResource.openStream(),
-               factory, null);
-      }
-   
+
+      factory = new WebDDObjectFactory();
+      UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory
+              .newInstance();
+      //        unmarshallerFactory.setFeature(Unmarshaller.SCHEMA_VALIDATION, Boolean.TRUE);
+      unmarshaller = unmarshallerFactory.newUnmarshaller();
+      JBossEntityResolver entityResolver = new JBossEntityResolver();
+      unmarshaller.setEntityResolver(entityResolver);
+
+      dd = (WebDD) unmarshaller.unmarshal(is,
+              factory, null);
       return dd;
    }
 
@@ -113,7 +117,7 @@
 
       if ((child = newEnvRefGroupChild(localName)) != null)
          return child;
-      
+
       if (localName.equals("filter"))
       {
          child = new Filter();
@@ -161,25 +165,25 @@
 
       return child;
    }
-   
+
    public Object newChild(Filter filter, UnmarshallingContext navigator,
-         String namespaceURI, String localName, Attributes attrs)
+                          String namespaceURI, String localName, Attributes attrs)
    {
       Object child = null;
-      
+
       if (localName.equals("init-param"))
       {
          child = new NameValuePair();
       }
-      
+
       return child;
    }
-   
+
    public Object newChild(Servlet servlet, UnmarshallingContext navigator,
-         String namespaceURI, String localName, Attributes attrs)
+                          String namespaceURI, String localName, Attributes attrs)
    {
       Object child = null;
-      
+
       if (localName.equals("init-param"))
       {
          child = new NameValuePair();
@@ -192,15 +196,15 @@
       {
          child = new SecurityRoleRef();
       }
-      
+
       return child;
    }
-   
+
    public Object newChild(SecurityConstraint constraint, UnmarshallingContext navigator,
-         String namespaceURI, String localName, Attributes attrs)
+                          String namespaceURI, String localName, Attributes attrs)
    {
       Object child = null;
-      
+
       if (localName.equals("web-resource-collection"))
       {
          child = new WebResourceCollection();
@@ -213,176 +217,176 @@
       {
          child = new UserDataConstraint();
       }
-      
+
       return child;
    }
-   
+
    public Object newChild(LoginConfig config, UnmarshallingContext navigator,
-         String namespaceURI, String localName, Attributes attrs)
+                          String namespaceURI, String localName, Attributes attrs)
    {
       Object child = null;
-      
+
       if (localName.equals("form-login-config"))
       {
          child = new FormLoginConfig();
       }
-      
+
       return child;
    }
 
    public void addChild(WebDD parent, Filter filter,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addFilter(filter);
    }
-   
+
    public void addChild(WebDD parent, FilterMapping mapping,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addFilterMapping(mapping);
    }
-   
+
    public void addChild(WebDD parent, Listener listener,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addListener(listener);
    }
-   
+
    public void addChild(WebDD parent, Servlet servlet,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addServlet(servlet);
    }
-   
+
    public void addChild(WebDD parent, ServletMapping mapping,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addServletMapping(mapping);
    }
-   
+
    public void addChild(WebDD parent, SessionConfig config,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addSessionConfig(config);
    }
-   
+
    public void addChild(WebDD parent, SecurityConstraint constraint,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addSecurityConstraint(constraint);
    }
-   
+
    public void addChild(WebDD parent, ErrorPage page,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addErrorPage(page);
    }
-   
+
    public void addChild(WebDD parent, SecurityRole role,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addSecurityRole(role);
    }
-   
+
    public void addChild(WebDD parent, EjbLocalRef ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addEjbLocalRef(ref);
    }
-   
+
    public void addChild(WebDD parent, EjbRef ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addEjbRef(ref);
    }
-   
+
    public void addChild(WebDD parent, EnvEntry ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addEnvEntry(ref);
    }
-   
+
    public void addChild(WebDD parent, MessageDestinationRef ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addMessageDestinationRef(ref);
    }
-   
+
    public void addChild(WebDD parent, ResourceEnvRef ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addResourceEnvRef(ref);
    }
-   
+
    public void addChild(WebDD parent, ResourceRef ref,
                         UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addResourceRef(ref);
    }
-   
+
    public void addChild(WebDD parent, LoginConfig config,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setLoginConfig(config);
    }
-   
+
    public void addChild(WebDD parent, MessageDestination destination,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addMessageDestination(destination);
    }
-   
+
    public void addChild(Filter parent, NameValuePair param,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addInitParam(param);
    }
-   
+
    public void addChild(Servlet parent, NameValuePair param,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addInitParam(param);
    }
-   
+
    public void addChild(Servlet parent, RunAs runAs,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setRunAs(runAs);
    }
-   
+
    public void addChild(Servlet parent, SecurityRoleRef ref,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.addSecurityRoleRef(ref);
    }
-   
+
    public void addChild(SecurityConstraint parent, WebResourceCollection collection,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setWebResourceCollection(collection);
    }
-   
+
    public void addChild(SecurityConstraint parent, AuthConstraint constraint,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setAuthConstraint(constraint);
    }
-   
+
    public void addChild(SecurityConstraint parent, UserDataConstraint constraint,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setUserDataConstraint(constraint);
    }
-   
+
    public void addChild(LoginConfig parent, FormLoginConfig config,
-         UnmarshallingContext navigator, String namespaceURI, String localName)
+                        UnmarshallingContext navigator, String namespaceURI, String localName)
    {
       parent.setFormLoginConfig(config);
    }
-   
+
    public void setValue(Filter filter,
-         UnmarshallingContext navigator, String namespaceURI, String localName,
-         String value)
+                        UnmarshallingContext navigator, String namespaceURI, String localName,
+                        String value)
    {
       if (localName.equals("filter-name"))
       {
@@ -393,10 +397,10 @@
          filter.setFilterClass(value);
       }
    }
-   
+
    public void setValue(FilterMapping mapping,
-         UnmarshallingContext navigator, String namespaceURI, String localName,
-         String value)
+                        UnmarshallingContext navigator, String namespaceURI, String localName,
+                        String value)
    {
       if (localName.equals("filter-name"))
       {
@@ -433,7 +437,7 @@
          servlet.setLoadOnStartup(value);
       }
    }
-  
+
    public void setValue(ServletMapping mapping,
                         UnmarshallingContext navigator, String namespaceURI, String localName,
                         String value)
@@ -447,10 +451,10 @@
          mapping.setUrlPattern(value);
       }
    }
-   
+
    public void setValue(ErrorPage page,
-         UnmarshallingContext navigator, String namespaceURI, String localName,
-         String value)
+                        UnmarshallingContext navigator, String namespaceURI, String localName,
+                        String value)
    {
       if (localName.equals("error-code"))
       {
@@ -461,19 +465,19 @@
          page.setLocation(value);
       }
    }
-   
+
    public void setValue(SessionConfig config,
-         UnmarshallingContext navigator, String namespaceURI, String localName,
-         String value)
+                        UnmarshallingContext navigator, String namespaceURI, String localName,
+                        String value)
    {
       if (localName.equals("session-timeout"))
       {
          config.setSessionTimeout(value);
       }
    }
-   
+
    public void setValue(NameValuePair param, UnmarshallingContext navigator,
-         String namespaceURI, String localName, String value)
+                        String namespaceURI, String localName, String value)
    {
       if (localName.equals("param-name"))
       {
@@ -484,9 +488,9 @@
          param.setValue(value);
       }
    }
-   
+
    public void setValue(WebResourceCollection collection, UnmarshallingContext navigator,
-         String namespaceURI, String localName, String value)
+                        String namespaceURI, String localName, String value)
    {
       if (localName.equals("web-resource-name"))
       {
@@ -497,27 +501,27 @@
          collection.setUrlPattern(value);
       }
    }
-   
+
    public void setValue(AuthConstraint contraint, UnmarshallingContext navigator,
-         String namespaceURI, String localName, String value)
+                        String namespaceURI, String localName, String value)
    {
       if (localName.equals("role-name"))
       {
          contraint.setRoleName(value);
       }
    }
-   
+
    public void setValue(UserDataConstraint contraint, UnmarshallingContext navigator,
-         String namespaceURI, String localName, String value)
+                        String namespaceURI, String localName, String value)
    {
       if (localName.equals("transport-guarantee"))
       {
          contraint.setTransportGuarantee(value);
       }
    }
-   
+
    public void setValue(LoginConfig config, UnmarshallingContext navigator,
-         String namespaceURI, String localName, String value)
+                        String namespaceURI, String localName, String value)
    {
       if (localName.equals("auth-method"))
       {
@@ -528,9 +532,9 @@
          config.setRealmName(value);
       }
    }
-   
+
    public void setValue(FormLoginConfig config, UnmarshallingContext navigator,
-         String namespaceURI, String localName, String value)
+                        String namespaceURI, String localName, String value)
    {
       if (localName.equals("form-login-page"))
       {

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6.java	2006-08-10 19:09:37 UTC (rev 55496)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/Tomcat6.java	2006-08-10 19:11:32 UTC (rev 55497)
@@ -24,6 +24,9 @@
 import java.io.File; 
 import java.util.Iterator; 
 import java.util.Properties;
+import java.util.ArrayList;
+import java.net.URL;
+import java.net.URLClassLoader;
 
 import javax.management.Attribute;
 import javax.management.MBeanServer;
@@ -33,7 +36,8 @@
 import javax.management.ObjectName;
 import javax.security.jacc.PolicyContext; 
 
-import org.apache.catalina.Lifecycle; 
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.Loader;
 import org.apache.catalina.connector.Connector;
 import org.apache.commons.modeler.Registry;
 import org.jboss.deployment.DeploymentInfo;
@@ -47,7 +51,9 @@
 import org.jboss.web.AbstractWebContainer;
 import org.jboss.web.AbstractWebDeployer;
 import org.jboss.web.tomcat.security.HttpServletRequestPolicyContextHandler;
-import org.jboss.web.tomcat.tc6.session.SessionIDGenerator; 
+import org.jboss.web.tomcat.tc6.session.SessionIDGenerator;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.ejb3.JmxDependencyPolicy;
 
 
 /**
@@ -81,7 +87,7 @@
    // that provide JMX-based deployment.
    private String contextClassName =
       "org.apache.catalina.core.StandardContext";
-   
+
    /**
     * Configurable map of tomcat authenticators
     * Keyed in by the http auth method that gets 
@@ -142,23 +148,23 @@
     * Get the request attribute name under which the JAAS Subject is store
     */
    private String subjectAttributeName = null;
-   
+
    /**
     * Flag indicating whether web-app specific context xmls may set the privileged flag.
     */
    private boolean allowSelfPrivilegedWebApps = false;
-   
+
    /** The service used to flush authentication cache on session invalidation. */
    private JaasSecurityManagerServiceMBean secMgrService;
-   
+
    /** Authorization Manager Service that is used to register xacml policies */
    private AuthorizationManagerServiceMBean authorizationMgrService;
-   
+
    /** */
    private String[] filteredPackages;
-   
+
    /** Hold a proxy reference to myself, used when registering to MainDeployer */
-   private SubDeployerExt thisProxy;  
+   private SubDeployerExt thisProxy;
 
    public Tomcat6()
    {
@@ -185,12 +191,12 @@
    {
       return this.catalinaDomain;
    }
-   
+
    public Properties getAuthenticators()
    {
-      return this.authenticators; 
+      return this.authenticators;
    }
-   
+
    public void setAuthenticators(Properties prop)
    {
       this.authenticators = prop;
@@ -217,8 +223,8 @@
    public String getContextMBeanCode()
    {
       return contextClassName;
-   }  
- 
+   }
+
    /**
     * Set the snapshot interval in milliseconds for snapshot mode = interval
     */
@@ -312,7 +318,7 @@
    {
        return SessionIDGenerator.getInstance().getSessionIdAlphabet();
    }
-   
+
    public boolean getUseJBossWebLoader()
    {
       return useJBossWebLoader;
@@ -351,7 +357,7 @@
    public void setAllowSelfPrivilegedWebApps(boolean allowSelfPrivilegedWebApps)
    {
       this.allowSelfPrivilegedWebApps = allowSelfPrivilegedWebApps;
-   } 
+   }
 
    public void setAuthorizationManagerService(AuthorizationManagerServiceMBean mgr)
    {
@@ -372,6 +378,11 @@
       this.filteredPackages = pkgs;
    }
 
+   @Override
+   protected void processMetaData(DeploymentInfo di)
+   {
+   }
+
    public void startService()
       throws Exception
    {
@@ -412,7 +423,7 @@
          new String[]{});
 
       // Configure any SingleSignOn valves      
-      
+
       ObjectName ssoQuery = new ObjectName(catalinaDomain + ":type=Valve,*");
       Iterator iterator = server.queryMBeans(ssoQuery, null).iterator();
       while (iterator.hasNext())
@@ -420,7 +431,7 @@
          ObjectName ssoObjectName =
             ((ObjectInstance) iterator.next()).getObjectName();
          String name = ssoObjectName.getKeyProperty("name");
-         
+
          /* Ensure that the SingleSignOn valve requires that each
             request be reauthenticated to the security mgr. Should not
             be neccessary now that we cache the principal in the session.
@@ -432,7 +443,7 @@
                ("requireReauthentication", Boolean.TRUE));
          }
          */
-            
+
          // If the valve is a ClusteredSingleSignOn and we have a shared
          // TreeCache configured, configure the valve to use the shared one
          if (cacheName != null && "ClusteredSingleSignOn".equals(name))
@@ -478,8 +489,8 @@
       if (started.booleanValue() == true)
       {
          log.debug("Server '" + ServerImplMBean.OBJECT_NAME +
-               "' already started, starting connectors now");         
-         
+               "' already started, starting connectors now");
+
          startConnectors();
       }
       else
@@ -487,8 +498,8 @@
          // Register for notification of the overall server startup
          log.debug("Server '" + ServerImplMBean.OBJECT_NAME +
                "' not started, registering for start-up notification");
-         
-         server.addNotificationListener(ServerImplMBean.OBJECT_NAME, this, null, null);         
+
+         server.addNotificationListener(ServerImplMBean.OBJECT_NAME, this, null, null);
       }
    }
 
@@ -590,12 +601,73 @@
       }
    }
 
+   /**
+    * A trival extension of URLClassLoader that uses an empty URL[] as its
+    * classpath so that all work is delegated to its parent.
+    */
+   static class ENCLoader extends URLClassLoader
+   {
+      private boolean parentFirst;
+
+      ENCLoader(URL[] urls, ClassLoader parent, boolean parentFirst)
+      {
+         super(urls, parent);
+         this.parentFirst = parentFirst;
+      }
+
+      protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
+      {
+         if (parentFirst) return super.loadClass(name, resolve);
+         try
+         {
+            Class clazz = findClass(name);
+            if (resolve) {
+                resolveClass(clazz);
+            }
+            return clazz;
+         }
+         catch (ClassNotFoundException e)
+         {
+            return getParent().loadClass(name);
+         }
+      }
+
+   }
+
+   public static ClassLoader getTmpLoader(URL warURL, ClassLoader parent, boolean parentFirst) throws Exception
+   {
+
+      String path = warURL.getFile();
+      ArrayList<URL> list = new ArrayList<URL>();
+      File classesDir = new File(path, "WEB-INF/classes");
+      if (classesDir.exists())
+      {
+         list.add(classesDir.toURL());
+      }
+      File libDir = new File(path, "WEB-INF/lib");
+      if (libDir.exists())
+      {
+         File[] jars = libDir.listFiles();
+         int length = jars != null ? jars.length : 0;
+         for (int j = 0; j < length; j++)
+         {
+            File jar = jars[j];
+            if(jar.getAbsolutePath().endsWith(".jar"))
+            {
+               list.add(jar.toURL());
+            }
+         }
+      }
+      ENCLoader loader = new ENCLoader(list.toArray(new URL[list.size()]), parent, parentFirst);
+      return loader;
+
+   }
+
+
    public AbstractWebDeployer getDeployer(DeploymentInfo di) throws Exception
    {
-      ClassLoader loader = di.ucl;
-      Class deployerClass = loader.loadClass("org.jboss.web.tomcat.tc6.TomcatDeployer");
-      AbstractWebDeployer deployer = (AbstractWebDeployer) deployerClass.newInstance();
-      DeployerConfig config = new DeployerConfig();  
+      TomcatDeployer deployer = new TomcatDeployer();
+      DeployerConfig config = new DeployerConfig();
       config.setDefaultSecurityDomain(this.defaultSecurityDomain);
       config.setSubjectAttributeName(this.subjectAttributeName);
       config.setServiceClassLoader(getClass().getClassLoader());
@@ -618,6 +690,21 @@
       config.setFilteredPackages(filteredPackages);
       deployer.setServer(server);
       deployer.init(config);
+
+      /*
+      // new JavaEE5 stuff
+      WebMetaData metadata = (WebMetaData)di.metaData;
+      TomcatInjectionContainer ic = new TomcatInjectionContainer(di);
+      URL warURL = di.localUrl != null ? di.localUrl : di.url;
+      ClassLoader parent = di.ucl;
+      if (di.parent != null) parent = di.parent.ucl;
+      ClassLoader tmpLoader = getTmpLoader(warURL, parent, java2ClassLoadingCompliance);
+      ic.setClassLoader(tmpLoader);
+
+      ic.processMetadata();
+      JmxDependencyPolicy dependencyPolicy = (JmxDependencyPolicy)ic.getDependencyPolicy();
+      metadata.setDepends(dependencyPolicy.getDependencies(metadata.getDepends()));
+      */
       return deployer;
-   } 
+   }
 }

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatDeployer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatDeployer.java	2006-08-10 19:09:37 UTC (rev 55496)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatDeployer.java	2006-08-10 19:11:32 UTC (rev 55497)
@@ -26,6 +26,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.net.MalformedURLException;
+import java.net.URLClassLoader;
 import java.security.CodeSource;
 import java.security.cert.Certificate;
 import java.util.HashMap;
@@ -39,6 +41,8 @@
 import javax.management.JMException;
 import javax.management.ObjectInstance;
 import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.NamingException;
 
 import org.apache.catalina.Loader;
 import org.jboss.deployment.DeploymentException;
@@ -70,8 +74,8 @@
    /**
     * The name of the war level context configuration descriptor
     */
-   private static final String CONTEXT_CONFIG_FILE = "WEB-INF/context.xml"; 
-   
+   private static final String CONTEXT_CONFIG_FILE = "WEB-INF/context.xml";
+
    /**
     * Optional XACML Policy File
     */
@@ -82,6 +86,7 @@
       {" jboss.management.local:J2EEServer=Local,j2eeType=JVM,name=localhost"};
    private String serverName = "jboss";
    private HashMap vhostToHostNames = new HashMap();
+   private TomcatInjectionContainer injectionContainer;
 
    public void init(Object containerConfig) throws Exception
    {
@@ -92,11 +97,24 @@
       super.setDefaultSecurityDomain(config.getDefaultSecurityDomain());
    }
 
+   @Override
+   protected void processEncReferences(WebMetaData metaData, Context envCtx, DeploymentInfo di) throws ClassNotFoundException, NamingException, DeploymentException
+   {
+      if (injectionContainer == null)
+      {
+         super.processEncReferences(metaData, envCtx, di);
+      }
+      else
+      {
+         injectionContainer.populateEnc();
+      }
+   }
+
    /**
     * Perform the tomcat specific deployment steps.
     */
    protected void performDeploy(WebApplication appInfo, String warUrl,
-      AbstractWebContainer.WebDescriptorParser webAppParser)
+                                AbstractWebContainer.WebDescriptorParser webAppParser)
       throws Exception
    {
       WebMetaData metaData = appInfo.getMetaData();
@@ -118,8 +136,8 @@
    }
 
    protected void performDeployInternal(String hostName,
-      WebApplication appInfo, String warUrl,
-      AbstractWebContainer.WebDescriptorParser webAppParser)
+                                        WebApplication appInfo, String warUrl,
+                                        AbstractWebContainer.WebDescriptorParser webAppParser)
       throws Exception
    {
 
@@ -137,34 +155,9 @@
       URL url = new URL(warUrl);
 
       ClassLoader loader = Thread.currentThread().getContextClassLoader();
-      /* If we are using the jboss class loader we need to augment its path
-      to include the WEB-INF/{lib,classes} dirs or else scoped class loading
-      does not see the war level overrides. The call to setWarURL adds these
-      paths to the deployment UCL.
-      */
-      Loader webLoader = null;
-      if (config.isUseJBossWebLoader())
-      {
-         WebCtxLoader jbossLoader = new WebCtxLoader(loader);
-         jbossLoader.setWarURL(url);
-         webLoader = jbossLoader;
-      }
-      else
-      {
-         String[] pkgs = config.getFilteredPackages();
-         WebAppLoader jbossLoader = new WebAppLoader(loader, pkgs);
-         jbossLoader.setDelegate(getJava2ClassLoadingCompliance());
-         webLoader = jbossLoader;
-      }
+      injectionContainer = new TomcatInjectionContainer(webAppParser, appInfo);
+         Loader webLoader = getWebLoader(loader, url);
 
-      // We need to establish the JNDI ENC prior to the start 
-      // of the web container so that init on startup servlets are able 
-      // to interact with their ENC. We hook into the context lifecycle 
-      // events to be notified of the start of the
-      // context as this occurs before the servlets are started.
-      if (appInfo.getAppData() == null)
-         webAppParser.parseWebAppDescriptors(loader, appInfo.getMetaData());
-
       appInfo.setName(url.getPath());
       appInfo.setClassLoader(loader);
       appInfo.setURL(url);
@@ -181,13 +174,13 @@
          log.debug("Already exists, destroying " + objectName);
          server.invoke(objectName, "destroy", new Object[]{},
             new String[]{});
-      }  
+      }
 
       server.createMBean("org.apache.commons.modeler.BaseModelMBean",
          objectName, new Object[]{config.getContextClassName()},
-         new String[]{"java.lang.String"}); 
-      
-      
+         new String[]{"java.lang.String"});
+
+
       // Find and set config file on the context
       // If WAR is packed, expand config file to temp folder
       String ctxConfig = null;
@@ -200,6 +193,11 @@
          log.debug("No " + CONTEXT_CONFIG_FILE + " in " + url, e);
       }
 
+      if (injectionContainer != null)
+      {
+        server.setAttribute(objectName, new Attribute("annotationProcessor", injectionContainer));
+      }
+
       server.setAttribute(objectName, new Attribute("docBase", url.getFile()));
 
       server.setAttribute(objectName, new Attribute("configFile", ctxConfig));
@@ -255,7 +253,7 @@
                // avoid opening .xml files
                if (fp.getName().toLowerCase().endsWith(".xml"))
                   continue;
-               
+
                ZipFile zip = new ZipFile(fp);
                zip.close();
             }
@@ -310,7 +308,7 @@
       {
          RunAsListener.metaDataLocal.set(null);
       }
-      
+
       // make the context class loader known to the WebMetaData, ws4ee needs it
       // to instanciate service endpoint pojos that live in this webapp
       Loader ctxLoader = (Loader)server.getAttribute(objectName, "loader");
@@ -330,14 +328,14 @@
             manager.init(name, metaData, config.isUseJK(), config.isUseLocalCache());
 
             if (manager instanceof JBossCacheManager)
-            {              
+            {
                String snapshotMode = config.getSnapshotMode();
                int snapshotInterval = config.getSnapshotInterval();
                JBossCacheManager jbcm = (JBossCacheManager) manager;
                jbcm.setSnapshotMode(snapshotMode);
                jbcm.setSnapshotInterval(snapshotInterval);
             }
-            
+
             server.setAttribute(objectName, new Attribute("manager", manager));
 
             log.debug("Enabled clustering support for ctxPath=" + ctxPath);
@@ -382,15 +380,15 @@
       while (iterator.hasNext())
       {
          di.mbeans.add(((ObjectInstance)iterator.next()).getObjectName());
-      }  
-      
+      }
+
       if(metaData.getSecurityDomain() != null)
       {
          String secDomain = Util.unprefixSecurityDomain(metaData.getSecurityDomain());
          //Associate the Context Id with the Security Domain
          String contextID = metaData.getJaccContextID();
-         mapSecurityDomain(secDomain, contextID); 
-         
+         mapSecurityDomain(secDomain, contextID);
+
          //Check if xacml policy is available 
          URL xacmlPolicyFile = null;
          try
@@ -406,54 +404,85 @@
                {
                   PolicyRegistration xam = (PolicyRegistration)authzmgr;
                   xam.registerPolicy(contextID,xacmlPolicyFile);
-               } 
-            } 
+               }
+            }
          }
          catch(IOException ioe)
          {
             //Ignore
-         }  
+         }
       }
-      
+
       log.debug("Initialized: " + appInfo + " " + objectName);
    }
 
-
-    /**
-    * Called as part of the undeploy() method template to ask the
-    * subclass for perform the web container specific undeployment steps.
-    */
-   protected void performUndeploy(String warUrl, WebApplication appInfo)
-      throws Exception
+   public Loader getWebLoader(ClassLoader loader, URL url)
+           throws MalformedURLException
    {
-      if (appInfo == null)
-      {
-         log.debug("performUndeploy, no WebApplication found for URL "
-            + warUrl);
-         return;
-      }
+      Loader webLoader = null;
+      /* If we are using the jboss class loader we need to augment its path
+      to include the WEB-INF/{lib,classes} dirs or else scoped class loading
+      does not see the war level overrides. The call to setWarURL adds these
+      paths to the deployment UCL.
+      */
 
-      log.info("undeploy, ctxPath=" + appInfo.getMetaData().getContextRoot()
-         + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
-
-      WebMetaData metaData = appInfo.getMetaData();
-      String hostName = null;
-      Iterator hostNames = metaData.getVirtualHosts();
-      if (hostNames.hasNext())
+      if (config.isUseJBossWebLoader())
       {
-         hostName = hostNames.next().toString();
+         WebCtxLoader jbossLoader = new WebCtxLoader(loader);
+         jbossLoader.setWarURL(url);
+         webLoader = jbossLoader;
       }
-      performUndeployInternal(hostName, warUrl, appInfo);
-      while (hostNames.hasNext())
+      else
       {
-         String additionalHostName = hostNames.next().toString();
-         performUndeployInternal(additionalHostName, warUrl, appInfo);
+         String[] pkgs = config.getFilteredPackages();
+         WebAppLoader jbossLoader = new WebAppLoader(loader, pkgs, injectionContainer);
+         jbossLoader.setDelegate(getJava2ClassLoadingCompliance());
+         webLoader = jbossLoader;
       }
+      return webLoader;
+   }
 
+   public void setInjectionContainer(TomcatInjectionContainer container)
+   {
+      this.injectionContainer = container;
    }
 
+
+   /**
+   * Called as part of the undeploy() method template to ask the
+   * subclass for perform the web container specific undeployment steps.
+   */
+  protected void performUndeploy(String warUrl, WebApplication appInfo)
+     throws Exception
+  {
+     if (appInfo == null)
+     {
+        log.debug("performUndeploy, no WebApplication found for URL "
+           + warUrl);
+        return;
+     }
+
+     log.info("undeploy, ctxPath=" + appInfo.getMetaData().getContextRoot()
+        + ", warUrl=" + shortWarUrlFromServerHome(warUrl));
+
+     WebMetaData metaData = appInfo.getMetaData();
+     String hostName = null;
+     Iterator hostNames = metaData.getVirtualHosts();
+     if (hostNames.hasNext())
+     {
+        hostName = hostNames.next().toString();
+     }
+     performUndeployInternal(hostName, warUrl, appInfo);
+     while (hostNames.hasNext())
+     {
+        String additionalHostName = hostNames.next().toString();
+        performUndeployInternal(additionalHostName, warUrl, appInfo);
+     }
+
+  }
+
    protected void performUndeployInternal(String hostName, String warUrl,
-      WebApplication appInfo)
+                                          WebApplication appInfo)
       throws Exception
    {
 
@@ -561,7 +590,7 @@
       }
       return result;
    }
-   
+
    /**
     * Locate a XACMl Policy file packaged in the war
     * @param warURL
@@ -576,9 +605,9 @@
       if (warURL.getProtocol().equals("file") && warFile.isDirectory() == true)
       {
          File webDD = new File(warFile, XACML_POLICY_FILE);
-         if (webDD.exists() == true) 
+         if (webDD.exists() == true)
             result = webDD.toURL();
-      } 
+      }
       return result;
    }
 
@@ -593,8 +622,8 @@
           return ".../" + warUrl.substring(serverHomeUrl.length());
         else
           return warUrl;
-    } 
-    
+    }
+
     protected void mapSecurityDomain(String securityDomain, String contextId)
     {
        //Register the context id with the authentication service 
@@ -607,6 +636,6 @@
        }catch(JMException me)
        {
           log.error("mapSecurityDomain::" + me.getLocalizedMessage());
-       } 
-    } 
+       }
+    }
 }

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/WebAppLoader.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/WebAppLoader.java	2006-08-10 19:09:37 UTC (rev 55496)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/WebAppLoader.java	2006-08-10 19:11:32 UTC (rev 55497)
@@ -21,48 +21,58 @@
 */
 package org.jboss.web.tomcat.tc6;
 
+import org.apache.catalina.LifecycleException;
 import org.apache.catalina.loader.WebappLoader;
-import org.apache.catalina.LifecycleException;
 
 /**
  * Override the tomcat WebappLoader to set the default class loader to the
  * WebAppClassLoader and pass the filtered packages to the WebAppClassLoader.
- * 
+ *
  * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
 public class WebAppLoader extends WebappLoader
 {
    private String[] filteredPackages = {
-      "org.apache.commons.logging"
+           "org.apache.commons.logging"
    };
 
+   private TomcatInjectionContainer injectionContainer;
+
    public WebAppLoader()
    {
       super();
       setLoaderClass(WebAppClassLoader.class.getName());
    }
 
-   public WebAppLoader(ClassLoader parent, String[] filteredPackages)
+   public WebAppLoader(ClassLoader parent, String[] filteredPackages, TomcatInjectionContainer container)
    {
       super(parent);
       setLoaderClass(WebAppClassLoader.class.getName());
       this.filteredPackages = filteredPackages;
+      injectionContainer = container;
    }
 
    /**
     * Override to apply the filteredPackages to the jboss WebAppClassLoader
-    * 
+    *
     * @throws LifecycleException
-    */ 
+    */
    public void start() throws LifecycleException
    {
       super.start();
       ClassLoader loader = getClassLoader();
-      if( loader instanceof WebAppClassLoader )
+      if (loader instanceof WebAppClassLoader)
       {
          WebAppClassLoader webLoader = (WebAppClassLoader) loader;
          webLoader.setFilteredPackages(filteredPackages);
       }
+      if (injectionContainer != null)
+      {
+         // we need to do this because the classloader is initialize by the web container and
+         // the injection container needs the classloader so that it can build up Injectors and ENC populators
+         injectionContainer.setClassLoader(getClassLoader());
+         injectionContainer.processMetadata();
+      }
    }
 }




More information about the jboss-cvs-commits mailing list