[jboss-cvs] JBossAS SVN: r66481 - trunk/ejb3/src/main/org/jboss/ejb3/clientmodule.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 26 05:57:36 EDT 2007


Author: thomas.diesler at jboss.com
Date: 2007-10-26 05:57:36 -0400 (Fri, 26 Oct 2007)
New Revision: 66481

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
Log:
Fix client service-ref handling

Modified: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java	2007-10-26 09:44:50 UTC (rev 66480)
+++ trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java	2007-10-26 09:57:36 UTC (rev 66481)
@@ -1,24 +1,24 @@
 /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
-  * 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.
-  */
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
+ * 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.ejb3.clientmodule;
 
 import java.lang.annotation.Annotation;
@@ -28,6 +28,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -50,9 +51,7 @@
 import org.jboss.ejb3.enc.MessageDestinationResolver;
 import org.jboss.ejb3.entity.PersistenceUnitDeployment;
 import org.jboss.ejb3.javaee.AbstractJavaEEComponent;
-import org.jboss.ejb3.javaee.JavaEEComponent;
 import org.jboss.ejb3.javaee.SimpleJavaEEModule;
-import org.jboss.ejb3.metamodel.ApplicationClientDD;
 import org.jboss.injection.DependsHandler;
 import org.jboss.injection.EJBHandler;
 import org.jboss.injection.EncInjector;
@@ -67,12 +66,14 @@
 import org.jboss.injection.WebServiceRefHandler;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.metadata.javaee.jboss.JBossRemoteEnvironmentRefsGroupMetaData;
+import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
+import org.jboss.metadata.serviceref.ServiceReferenceHandler;
 import org.jboss.metadata.serviceref.VirtualFileAdaptor;
 import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+import org.jboss.metamodel.descriptor.ServiceRefDelegate;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
 
 /**
  * This class builds up the java:comp namespace for JavaEE 5 application clients.
@@ -87,7 +88,7 @@
    private static final Logger log = Logger.getLogger(ClientENCInjectionContainer.class);
 
    private DeploymentUnit ejb3Unit;
-   private JBossClientMetaData xml;
+   private JBossClientMetaData clientMetaData;
    private Class<?> mainClass;
    private String applicationClientName;
    private ClassLoader classLoader;
@@ -106,18 +107,19 @@
 
    private MessageDestinationResolver messageDestinationResolver;
 
-   public ClientENCInjectionContainer(VFSDeploymentUnit unit, JBossClientMetaData xml, Class<?> mainClass, String applicationClientName, ClassLoader classLoader, Context encCtx) throws NamingException
+   public ClientENCInjectionContainer(VFSDeploymentUnit unit, JBossClientMetaData xml, Class<?> mainClass, String applicationClientName, ClassLoader classLoader,
+         Context encCtx) throws NamingException
    {
       super(new SimpleJavaEEModule((unit.getParent() != null ? unit.getParent().getSimpleName() : null), unit.getSimpleName()));
-      if(mainClass == null)
+      if (mainClass == null)
          throw new NullPointerException("mainClass is mandatory");
-      if(applicationClientName == null)
+      if (applicationClientName == null)
          throw new NullPointerException("applicationClientName is mandatory");
-      if(classLoader == null)
+      if (classLoader == null)
          throw new NullPointerException("classLoader is mandatory");
 
       this.ejb3Unit = new JBoss5DeploymentUnit(unit);
-      this.xml = xml;
+      this.clientMetaData = xml;
       this.mainClass = mainClass;
       this.applicationClientName = applicationClientName;
       this.classLoader = classLoader;
@@ -125,24 +127,24 @@
       this.enc = encCtx;
 
       /*
-      EAR ear = null;
+       EAR ear = null;
 
-      if (di.parent != null)
-      {
-         if (di.parent.shortName.endsWith(".ear") || di.parent.shortName.endsWith(".ear/"))
-         {
-            synchronized (di.parent.context)
-            {
-               ear = (EAR) di.parent.context.get("EJB3_EAR_METADATA");
-               if (ear == null)
-               {
-                  ear = new JmxEARImpl(di.parent.shortName);
-                  di.parent.context.put("EJB3_EAR_METADATA", ear);
-               }
-            }
-         }
-      }
-      */
+       if (di.parent != null)
+       {
+       if (di.parent.shortName.endsWith(".ear") || di.parent.shortName.endsWith(".ear/"))
+       {
+       synchronized (di.parent.context)
+       {
+       ear = (EAR) di.parent.context.get("EJB3_EAR_METADATA");
+       if (ear == null)
+       {
+       ear = new JmxEARImpl(di.parent.shortName);
+       di.parent.context.put("EJB3_EAR_METADATA", ear);
+       }
+       }
+       }
+       }
+       */
 
       //DeploymentScope scope = null;
       if (unit.getParent() != null)
@@ -158,7 +160,7 @@
       {
          this.objectName = new ObjectName(on);
       }
-      catch(MalformedObjectNameException e)
+      catch (MalformedObjectNameException e)
       {
          // should not happen
          throw new RuntimeException("Malformed object name " + on, e);
@@ -170,7 +172,8 @@
    private String createScopeKernelName(VFSDeploymentUnit unit, DeploymentScope ear)
    {
       String scopedKernelName = "";
-      if (ear != null) scopedKernelName += ",ear=" + ear.getShortName();
+      if (ear != null)
+         scopedKernelName += ",ear=" + ear.getShortName();
       scopedKernelName += ",jar=" + unit.getSimpleName();
       return scopedKernelName;
    }
@@ -247,7 +250,7 @@
 
    public EnvironmentRefGroup getEnvironmentRefGroup()
    {
-      return new EnvironmentRefGroupConveter(xml.getJndiEnvironmentRefsGroup());
+      return new EnvironmentRefGroupConveter(clientMetaData.getJndiEnvironmentRefsGroup());
    }
 
    public String getIdentifier()
@@ -284,7 +287,7 @@
    {
       return false;
    }
-   
+
    private void populateEnc()
    {
       for (EncInjector injector : encInjectors.values())
@@ -296,11 +299,11 @@
 
    private void processMetaData()
    {
-      if(xml.getDepends() != null)
-      for(String dependency : xml.getDepends())
-      {
-         getDependencyPolicy().addDependency(dependency);
-      }
+      if (clientMetaData.getDepends() != null)
+         for (String dependency : clientMetaData.getDepends())
+         {
+            getDependencyPolicy().addDependency(dependency);
+         }
 
       // TODO: check which handlers an application client should support
       Collection<InjectionHandler> handlers = new ArrayList<InjectionHandler>();
@@ -317,37 +320,39 @@
       try
       {
          // EJB container's XML must be processed before interceptor's as it may override interceptor's references
-         EnvironmentRefGroupConveter refs = new EnvironmentRefGroupConveter(xml.getJndiEnvironmentRefsGroup());
+         EnvironmentRefGroupConveter refs = new EnvironmentRefGroupConveter(clientMetaData.getJndiEnvironmentRefsGroup());
          for (InjectionHandler handler : handlers)
             handler.loadXml(refs, this);
 
          Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getMainClass());
          injectors.addAll(tmp.values());
 
-//         initialiseInterceptors();
-//         for (InterceptorInfo interceptorInfo : applicableInterceptors)
-//         {
-//            for (InjectionHandler handler : handlers)
-//            {
-//               handler.loadXml(interceptorInfo.getXml(), this);
-//            }
-//         }
-//         for (InterceptorInfo interceptorInfo : applicableInterceptors)
-//         {
-//            Map<AccessibleObject, Injector> tmpInterceptor = InjectionUtil.processAnnotations(this, handlers, interceptorInfo.getClazz());
-//            InterceptorInjector injector = new InterceptorInjector(this, interceptorInfo, tmpInterceptor);
-//            interceptorInjectors.put(interceptorInfo.getClazz(), injector);
-//         }
+         //         initialiseInterceptors();
+         //         for (InterceptorInfo interceptorInfo : applicableInterceptors)
+         //         {
+         //            for (InjectionHandler handler : handlers)
+         //            {
+         //               handler.loadXml(interceptorInfo.getXml(), this);
+         //            }
+         //         }
+         //         for (InterceptorInfo interceptorInfo : applicableInterceptors)
+         //         {
+         //            Map<AccessibleObject, Injector> tmpInterceptor = InjectionUtil.processAnnotations(this, handlers, interceptorInfo.getClazz());
+         //            InterceptorInjector injector = new InterceptorInjector(this, interceptorInfo, tmpInterceptor);
+         //            interceptorInjectors.put(interceptorInfo.getClazz(), injector);
+         //         }
 
          // When @WebServiceRef is not used service-ref won't be processed
          // In this case we process them late
-         /* TODO
-         if(xml!=null)
+         if (clientMetaData != null)
          {
-            for(ServiceRefMetaData sref : xml.getServiceRefs())
+            ServiceReferencesMetaData serviceRefs = clientMetaData.getServiceReferences();
+            if (serviceRefs != null)
             {
-               if(!sref.isProcessed())
+               Iterator<ServiceReferenceMetaData> itRefs = serviceRefs.iterator();
+               while (itRefs.hasNext())
                {
+                  ServiceReferenceMetaData sref = itRefs.next();
                   try
                   {
                      String name = sref.getServiceRefName();
@@ -355,7 +360,7 @@
                      Context encCtx = getEnc();
 
                      UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(getRootFile());
-                     new ServiceRefDelegate().bindServiceRef(encCtx, encName, vfsRoot, getClassloader(), sref);
+                     new ServiceReferenceHandler().bindServiceRef(encCtx, encName, vfsRoot, getClassloader(), sref);
 
                   }
                   catch (Exception e)
@@ -365,7 +370,6 @@
                }
             }
          }
-         */
       }
       finally
       {
@@ -385,36 +389,36 @@
 
    public String resolveMessageDestination(String link)
    {
-//      // FIXME: this is a copy of DeploymentEjbResolver & Ejb3Deployment.resolveMessageDestination
-//      int hashIndex = link.indexOf('#');
-//      if (hashIndex != -1)
-//      {
-//         if (deploymentScope == null)
-//         {
-//            log.warn("ejb link '" + link + "' is relative, but no deployment scope found");
-//            return null;
-//         }
-//         String relativePath = link.substring(0, hashIndex);
-//         Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
-//         if (dep == null)
-//         {
-//            log.warn("can't find a deployment for path '" + relativePath + "' of ejb link '" + link + "'");
-//            return null;
-//         }
-//         String name = link.substring(hashIndex + 1);
-//         // call resolve, because get is private (and should stay that way)
-//         return dep.resolveMessageDestination(name);
-//      }
-//      return getMessageDestination(link);
+      //      // FIXME: this is a copy of DeploymentEjbResolver & Ejb3Deployment.resolveMessageDestination
+      //      int hashIndex = link.indexOf('#');
+      //      if (hashIndex != -1)
+      //      {
+      //         if (deploymentScope == null)
+      //         {
+      //            log.warn("ejb link '" + link + "' is relative, but no deployment scope found");
+      //            return null;
+      //         }
+      //         String relativePath = link.substring(0, hashIndex);
+      //         Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
+      //         if (dep == null)
+      //         {
+      //            log.warn("can't find a deployment for path '" + relativePath + "' of ejb link '" + link + "'");
+      //            return null;
+      //         }
+      //         String name = link.substring(hashIndex + 1);
+      //         // call resolve, because get is private (and should stay that way)
+      //         return dep.resolveMessageDestination(name);
+      //      }
+      //      return getMessageDestination(link);
       return messageDestinationResolver.resolveMessageDestination(link);
    }
-   
+
    public void start()
    {
       populateEnc();
 
       // Don't run any injectors, they must be run client side
-      
+
       log.info("STARTED CLIENT ENC CONTAINER: " + applicationClientName);
    }
 




More information about the jboss-cvs-commits mailing list