[jboss-cvs] JBossAS SVN: r74123 - in trunk/tomcat/src/main/org/jboss/web/tomcat/service: deployers and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 4 22:09:53 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-06-04 22:09:53 -0400 (Wed, 04 Jun 2008)
New Revision: 74123

Modified:
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java
Log:
JBAS-3426, rely on the MappedReferenceMetaDataResolverDeployer to establish the resolved jndi name rather than implementing injection container resolution

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java	2008-06-05 02:02:35 UTC (rev 74122)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java	2008-06-05 02:09:53 UTC (rev 74123)
@@ -31,7 +31,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -42,7 +41,6 @@
 import javax.naming.NamingException;
 
 import org.apache.InstanceManager;
-import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.ejb3.Container;
 import org.jboss.ejb3.DependencyPolicy;
@@ -64,7 +62,6 @@
 import org.jboss.injection.WebServiceRefHandler;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.javaee.spec.Environment;
-import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
 import org.jboss.metadata.web.jboss.JBossServletsMetaData;
 import org.jboss.metadata.web.jboss.JBossWebMetaData;
 import org.jboss.metadata.web.spec.FilterMetaData;
@@ -80,6 +77,7 @@
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @author adrian at jboss.org
+ * @author Scott.Stark at jboss.org
  * @version $Revision: 1.17 $
  */
 public class TomcatInjectionContainer extends AbstractJavaEEComponent implements InjectionContainer, InstanceManager
@@ -127,9 +125,7 @@
    protected Map<String, Map<AccessibleObject, Injector>> resolvedClassInjections = new HashMap<String, Map<AccessibleObject, Injector>>();
 
    protected List<PersistenceUnitDeployment> persistenceUnitDeployments = new ArrayList<PersistenceUnitDeployment>();
-   protected LinkedHashMap ejbContainers = new LinkedHashMap(); // will always be empty.
    protected DeploymentPersistenceUnitResolver persistenceUnitResolver;
-   protected WarEjbResolver ejbResolver;
    protected DependencyPolicy dependencyPolicy = new JBoss5DependencyPolicy(this);
    protected Collection<InjectionHandler<Environment>> handlers;
    protected VFSDeploymentUnit unit;
@@ -138,7 +134,7 @@
    protected JBossWebMetaData webDD;
    protected org.apache.catalina.Context catalinaContext;
 
-   public TomcatInjectionContainer(WebApplication appInfo, VFSDeploymentUnit unit, org.apache.catalina.Context catalinaContext, MainDeployerStructure mainDeployer)
+   public TomcatInjectionContainer(WebApplication appInfo, VFSDeploymentUnit unit, org.apache.catalina.Context catalinaContext)
    {
       super(new SimpleJavaEEModule(appInfo.getName()));
       
@@ -146,9 +142,8 @@
       DeploymentScope deploymentScope = null;
       this.appInfo = appInfo;
       this.catalinaContext = catalinaContext;
-
-      persistenceUnitResolver = new DeploymentPersistenceUnitResolver(persistenceUnitDeployments, deploymentScope, ejbContainers);
-      ejbResolver = new WarEjbResolver(deploymentScope, unit, mainDeployer);
+      LinkedHashMap empty = new LinkedHashMap(0);
+      persistenceUnitResolver = new DeploymentPersistenceUnitResolver(persistenceUnitDeployments, deploymentScope, empty);
       
       this.webDD = unit.getAttachment(JBossWebMetaData.class);
       assert this.webDD != null : "webDD is null (no JBossWebMetaData attachment in VFSDeploymentUnit)";
@@ -448,22 +443,23 @@
    
    public Container resolveEjbContainer(String link, Class<?> businessIntf)
    {
-      return ejbResolver.getEjbContainer(link, businessIntf);
+      return null;
    }
 
    public Container resolveEjbContainer(Class<?> businessIntf) throws NameNotFoundException
    {
-      return ejbResolver.getEjbContainer(businessIntf);
+      return null;
    }
 
-   public String getEjbJndiName(Class<?> businessInterface) throws NameNotFoundException
+   public String getEjbJndiName(Class<?> businessIntf) throws NameNotFoundException
    {
-      return ejbResolver.getEjbJndiName(businessInterface);
+      throw new IllegalStateException("Resolution should not happen via injection container");
+
    }
 
-   public String getEjbJndiName(String link, Class<?> businessInterface)
+   public String getEjbJndiName(String link, Class<?> businessIntf)
    {
-      return ejbResolver.getEjbJndiName(link, businessInterface);
+      throw new IllegalStateException("Resolution should not happen via injection container");
    }
 
    public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz)
@@ -498,17 +494,6 @@
 
    public String resolveMessageDestination(String link)
    {
-      if (webDD.getMessageDestinationReferences() == null)
-         return null;
-      Iterator<MessageDestinationReferenceMetaData> iterator = webDD.getMessageDestinationReferences().iterator();
-      while (iterator.hasNext())
-      {
-         MessageDestinationReferenceMetaData current = iterator.next();
-         if (link.equals(current.getLink()))
-         {
-            return current.getMessageDestinationRefName();
-         }
-      }
-      return null;
+      throw new IllegalStateException("Resolution should not happen via injection container");
    }
 }
\ No newline at end of file

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java	2008-06-05 02:02:35 UTC (rev 74122)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java	2008-06-05 02:09:53 UTC (rev 74123)
@@ -164,7 +164,8 @@
       metaData.setContextLoader(loader);
 
       StandardContext context = (StandardContext)Class.forName(config.getContextClassName()).newInstance();
-      injectionContainer = new TomcatInjectionContainer(webApp, webApp.getDeploymentUnit(), context, mainDeployer);
+      
+      injectionContainer = new TomcatInjectionContainer(webApp, webApp.getDeploymentUnit(), context);
 
       Loader webLoader = webApp.getDeploymentUnit().getAttachment(Loader.class);
       if (webLoader == null)

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java	2008-06-05 02:02:35 UTC (rev 74122)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/injection/WebResourceHandler.java	2008-06-05 02:09:53 UTC (rev 74123)
@@ -37,7 +37,6 @@
 import javax.transaction.UserTransaction;
 
 import org.jboss.ejb3.Container;
-import org.jboss.injection.EJBContextPropertyInjector;
 import org.jboss.injection.EnvEntryEncInjector;
 import org.jboss.injection.InjectionContainer;
 import org.jboss.injection.InjectionHandler;
@@ -62,6 +61,8 @@
 import org.omg.CORBA.ORB;
 
 /**
+ * RemoteEnvironment InjectionHandler for web components
+ * 
  * @author Scott.Stark at jboss.org
  * @version $Revision:$
  */
@@ -125,7 +126,10 @@
             if (container.getEncInjectors().containsKey(encName))
                continue;
 
-            if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
+            String mappedName = envRef.getMappedName();
+            if(mappedName == null || mappedName.length() == 0)
+               mappedName = envRef.getResolvedJndiName();
+            if (mappedName == null || mappedName.length() == 0)
             {
                if (envRef.getResUrl() != null)
                {
@@ -180,7 +184,7 @@
             }
             else
             {
-               container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, envRef.getMappedName(), "<resource-ref>"));
+               container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "<resource-ref>"));
             }
             InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
          }
@@ -190,10 +194,10 @@
       {
          for (ResourceEnvironmentReferenceMetaData envRef : refs)
          {
-            // EJBTHREE-712
-            // TODO: refactor with handlePropertyAnnotation
             String resTypeName = envRef.getType();
             String mappedName = envRef.getMappedName();
+            if(mappedName == null || mappedName.length() == 0)
+               mappedName = envRef.getResolvedJndiName();
             try
             {
                if(resTypeName != null)
@@ -237,7 +241,8 @@
             }
             
             String encName = "env/" + envRef.getResourceEnvRefName();
-            if (container.getEncInjectors().containsKey(encName)) continue;
+            if (container.getEncInjectors().containsKey(encName))
+               continue;
             if (mappedName == null || mappedName.equals(""))
             {
                throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
@@ -256,17 +261,9 @@
             String jndiName = envRef.getMappedName();
             if (jndiName == null || jndiName.equals(""))
             {
-               // Look for a message-destination-link
-               String link = envRef.getLink();
-               if( link != null )
-               {
-                  jndiName = container.resolveMessageDestination(link);
-                  if (jndiName == null)
-                     throw new RuntimeException("message-destination-link not found " + link + " of deployment " + container.getIdentifier());
-                  // TODO: add dependency
-               }
-               else
-                  throw new RuntimeException("mapped-name or message-destination-link is required for " + envRef.getMessageDestinationRefName() + " of deployment " + container.getIdentifier());
+               jndiName = envRef.getResolvedJndiName();
+               if (jndiName == null || jndiName.equals(""))
+                  throw new RuntimeException("mapped-name is required for " + envRef.getMessageDestinationRefName() + " of deployment " + container.getIdentifier());
             }
             container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, jndiName, "<message-destination-ref>"));
             InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());




More information about the jboss-cvs-commits mailing list