[jboss-cvs] JBossAS SVN: r77950 - trunk/tomcat/src/main/org/jboss/web/tomcat/service.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 4 05:16:09 EDT 2008


Author: emuckenhuber
Date: 2008-09-04 05:16:08 -0400 (Thu, 04 Sep 2008)
New Revision: 77950

Modified:
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
Log:
[JBAS-5673] use the WebEjbHandler to resolve jndiNames for dynamic beans

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java	2008-09-04 08:49:28 UTC (rev 77949)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java	2008-09-04 09:16:08 UTC (rev 77950)
@@ -21,8 +21,6 @@
  */
 package org.jboss.web.tomcat.service;
 
-// $Id: $
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
@@ -48,6 +46,9 @@
 
 import org.apache.InstanceManager;
 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;
 import org.jboss.ejb3.DependencyPolicy;
 import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
@@ -69,7 +70,7 @@
 import org.jboss.virtual.VirtualFile;
 import org.jboss.web.WebApplication;
 import org.jboss.web.tomcat.service.injection.TomcatInjectionUtils;
-import org.jboss.web.tomcat.service.injection.WebEJBInjectionHandler;
+import org.jboss.web.tomcat.service.injection.WebEJBHandler;
 import org.jboss.web.tomcat.service.injection.WebResourceHandler;
 import org.jboss.web.tomcat.service.injection.WebServiceRefInjectionHandler;
 
@@ -133,6 +134,8 @@
    protected JBossWebMetaData webDD;
    protected org.apache.catalina.Context catalinaContext;
    private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+   private DeploymentEndpointResolver deploymentEndpointResolver;
+   private Map<String, ContainerDependencyMetaData> endpointMap;
    private static final Set<String> dynamicClassLoaders = new HashSet<String>();
    private static final Properties restrictedFilters = new Properties();
    private static final Properties restrictedListeners = new Properties();
@@ -189,6 +192,8 @@
       this.appInfo = appInfo;
       this.catalinaContext = catalinaContext;
       this.persistenceUnitDependencyResolver = resolver;
+      this.deploymentEndpointResolver = unit.getAttachment(DeploymentEndpointResolver.class);
+      this.endpointMap = unit.getTopLevel().getAttachment(MappedReferenceMetaDataResolverDeployer.ENDPOINT_MAP_KEY, Map.class);
       
       this.webDD = unit.getAttachment(JBossWebMetaData.class);
       assert this.webDD != null : "webDD is null (no JBossWebMetaData attachment in VFSDeploymentUnit)";
@@ -372,7 +377,7 @@
       if(! isDynamicBean(object))
          return;
       
-      Map<AccessibleObject, Injector> injectors = getEncInjectionsForObject(object);
+      Map<AccessibleObject, Injector> injectors = getEncInjectionsForClass(object.getClass(), true);
       if (injectors == null)
       {
          if (trace)
@@ -409,12 +414,18 @@
       if(object == null || object.getClass() == Object.class)
          return null;
       
-      // TODO - make this recursive ?
-      Map<AccessibleObject, Injector> injectors = encInjections.get(object.getClass().getName());
+      return getEncInjectionsForClass(object.getClass(), isDynamicBean(object));
+   }
+   
+   private Map<AccessibleObject, Injector> getEncInjectionsForClass(Class<?> clazz, boolean isDynamic)
+   {
+      if(clazz == null || clazz == Object.class) return null;      
+      
+      Map<AccessibleObject, Injector> injectors = encInjections.get(clazz.getName());
       Map<AccessibleObject, Injector> additionalInjectors = null;
-      if(object.getClass().getSuperclass() != null)
-         additionalInjectors = encInjections.get(object.getClass().getSuperclass().getName());
-      
+      if(clazz.getSuperclass() != null && ! isDynamic)
+         additionalInjectors = getEncInjectionsForClass(clazz.getSuperclass(), isDynamic);
+
       if(injectors == null)
          return additionalInjectors;
       else if(additionalInjectors != null)
@@ -495,11 +506,12 @@
     */
    public void processMetadata()
    {
-      // XML must be done first so that any annotation overrides are initialized
-
+      // 
+      InjectionHandler<Environment> webEjbHandler = new WebEJBHandler<Environment>(webDD, deploymentEndpointResolver, endpointMap, unit.getRelativePath());
+      
       // todo injection handlers should be pluggable from XML
       handlers = new ArrayList<InjectionHandler<Environment>>();
-      handlers.add(new WebEJBInjectionHandler<Environment>());
+      handlers.add(webEjbHandler);
       handlers.add(new DependsHandler<Environment>());
       handlers.add(new PersistenceContextHandler<Environment>());
       handlers.add(new PersistenceUnitHandler<Environment>());




More information about the jboss-cvs-commits mailing list