[jbossws-commits] JBossWS SVN: r9708 - in container/jboss50/branches/jboss501/src/main: java/org/jboss/wsf/container/jboss50/invocation and 1 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Apr 2 10:17:53 EDT 2009


Author: richard.opalka at jboss.com
Date: 2009-04-02 10:17:53 -0400 (Thu, 02 Apr 2009)
New Revision: 9708

Added:
   container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java
Modified:
   container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java
   container/jboss50/branches/jboss501/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml
Log:
[JBWS-2074] fixing AS 501 integration layer

Added: container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java
===================================================================
--- container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java	                        (rev 0)
+++ container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/deployment/metadata/InjectionMetaDataDeploymentAspect.java	2009-04-02 14:17:53 UTC (rev 9708)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.wsf.container.jboss50.deployment.metadata;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceProvider;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspect;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.spi.deployment.integration.WebServiceDeclaration;
+import org.jboss.wsf.spi.metadata.injection.InjectionMetaData;
+import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
+
+/**
+ * Deployment aspect that builds injection meta data.
+ *
+ * @author ropalka at redhat.com
+ */
+public final class InjectionMetaDataDeploymentAspect extends DeploymentAspect
+{
+
+   @Override
+   public void create(Deployment dep)
+   {
+      super.create(dep);
+
+      DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
+      if (unit == null)
+         throw new IllegalStateException();
+      
+      List<InjectionMetaData> injectionMD = new LinkedList<InjectionMetaData>();
+      DeploymentType deploymentType = dep.getType();
+
+      if (deploymentType == DeploymentType.JAXWS_JSE)
+      {
+         JBossWebMetaData webMD = unit.getAttachment(JBossWebMetaData.class);
+         injectionMD.addAll(buildInjectionMetaData(webMD.getEnvironmentEntries()));
+      }
+      else if (deploymentType == DeploymentType.JAXWS_EJB3)
+      {
+         // [JBWS-2074] see comment in JIRA
+         log.warn("Both @Resource annotated methods/fields and descriptor specified injections don't work in handlers associated with EJB3 endpoints");
+         /*
+         JBossMetaData jbossMD = unit.getAttachment(JBossMetaData.class);
+         JBossEnterpriseBeansMetaData jebMDs = jbossMD.getEnterpriseBeans();
+         
+         WebServiceDeployment webServiceDeployment = unit.getAttachment(WebServiceDeployment.class);
+         EnvironmentEntriesMetaData attachment = new EnvironmentEntriesMetaData();
+         
+         Iterator<WebServiceDeclaration> it = webServiceDeployment.getServiceEndpoints().iterator();
+         while (it.hasNext())
+         {
+            WebServiceDeclaration container = it.next();
+            if (isWebServiceBean(container))
+            {
+               String ejbName = container.getComponentName();
+               EnvironmentEntriesMetaData ejbEnvEntries = jebMDs.get(ejbName).getEnvironmentEntries(); 
+               attachment.addAll(ejbEnvEntries);
+               injectionMD.addAll(buildInjectionMetaData(ejbEnvEntries));
+            }
+         }
+         */
+      }
+
+      dep.getService().addAttachment(InjectionsMetaData.class, new InjectionsMetaData(injectionMD));
+   }
+
+   @Override
+   public void destroy(Deployment dep)
+   {
+      dep.getService().removeAttachment(InjectionMetaData.class);
+
+      super.destroy(dep);
+   }
+   
+   private List<InjectionMetaData> buildInjectionMetaData(EnvironmentEntriesMetaData envEntries)
+   {
+      if ((envEntries == null) || (envEntries.size() == 0))
+      {
+         return Collections.emptyList();
+      }
+      
+      EnvironmentEntryMetaData eeMD = null;
+      LinkedList<InjectionMetaData> retVal = new LinkedList<InjectionMetaData>();
+      String envEntryName = null;
+      String envEntryValue = null;
+      String targetClass = null;
+      String targetName = null;
+      String valueClass = null;
+      
+      for (Iterator<EnvironmentEntryMetaData> i = envEntries.iterator(); i.hasNext();)
+      {
+         eeMD = i.next();
+         envEntryName = eeMD.getEnvEntryName();
+         envEntryValue = eeMD.getValue();
+         valueClass = eeMD.getType();
+
+         Set<ResourceInjectionTargetMetaData> injectionTargets = eeMD.getInjectionTargets();
+         if ((injectionTargets != null) && (injectionTargets.size() > 0))
+         {
+            for (Iterator<ResourceInjectionTargetMetaData> j = injectionTargets.iterator(); j.hasNext(); )
+            {
+               ResourceInjectionTargetMetaData ritMD = j.next();
+               targetClass = ritMD.getInjectionTargetClass();
+               targetName = ritMD.getInjectionTargetName();
+               InjectionMetaData injectionMD = new InjectionMetaData(targetClass, targetName, valueClass, envEntryName, envEntryValue != null);
+               
+               retVal.add(injectionMD);
+               log.debug(injectionMD);
+            }
+         }
+      }
+      
+      return retVal;
+   }
+
+   private boolean isWebServiceBean(WebServiceDeclaration container)
+   {
+      boolean isWebService = container.getAnnotation(WebService.class) != null;
+      boolean isWebServiceProvider = container.getAnnotation(WebServiceProvider.class) != null;
+      
+      return isWebService || isWebServiceProvider;
+   }
+
+}

Modified: container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java
===================================================================
--- container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java	2009-04-02 14:10:28 UTC (rev 9707)
+++ container/jboss50/branches/jboss501/src/main/java/org/jboss/wsf/container/jboss50/invocation/InvocationHandlerJSE.java	2009-04-02 14:17:53 UTC (rev 9708)
@@ -36,6 +36,7 @@
 import org.jboss.wsf.spi.invocation.InvocationHandler;
 import org.jboss.wsf.spi.invocation.ResourceInjector;
 import org.jboss.wsf.spi.invocation.ResourceInjectorFactory;
+import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
 
 /**
  * Handles invocations on JSE endpoints.
@@ -80,14 +81,15 @@
          {
             throw new IllegalStateException("Cannot get target bean instance", ex);
          }
-         
-         JavaxAnnotationHelper.callPostConstructMethod(targetBean, targetBean.getClass().getClassLoader());
+
+         JavaxAnnotationHelper.injectResources(targetBean, ep.getService().getAttachment(InjectionsMetaData.class));
+         JavaxAnnotationHelper.callPostConstructMethod(targetBean);
          ep.addAttachment(PreDestroyHolder.class, new PreDestroyHolder(targetBean));
       }
-      
+
       return targetBean;
    }
-   
+
    public void invoke(Endpoint ep, Invocation epInv) throws Exception
    {
       try

Modified: container/jboss50/branches/jboss501/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml
===================================================================
--- container/jboss50/branches/jboss501/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml	2009-04-02 14:10:28 UTC (rev 9707)
+++ container/jboss50/branches/jboss501/src/main/resources/jbossws-jboss50.deployer/META-INF/jbossws-deployer-jboss-beans.xml	2009-04-02 14:17:53 UTC (rev 9708)
@@ -197,6 +197,11 @@
     <property name="provides">ContainerMetaData, VFSRoot</property>
   </bean>
   
+  <bean name="WSInjectionMetaDataDeploymentAspect" class="org.jboss.wsf.container.jboss50.deployment.metadata.InjectionMetaDataDeploymentAspect">
+    <property name="requires">ContainerMetaData</property>
+    <property name="provides">InjectionMetaData</property>
+  </bean>  
+
   <bean name="WSContextRootDeploymentAspect" class="org.jboss.wsf.framework.deployment.BackwardCompatibleContextRootDeploymentAspect">
     <property name="requires">ContainerMetaData</property>
     <property name="provides">ContextRoot</property>
@@ -286,6 +291,7 @@
     <property name="aspects">
       <set class="java.util.HashSet" elementClass="org.jboss.wsf.spi.deployment.DeploymentAspect">
         <inject bean="WSContainerMetaDataDeploymentAspect"/>
+        <inject bean="WSInjectionMetaDataDeploymentAspect"/>
         <inject bean="WSContextRootDeploymentAspect"/>
         <inject bean="WSEndpointAddressDeploymentAspect"/>
         <inject bean="WSEndpointHandlerDeploymentAspect"/>
@@ -316,6 +322,7 @@
     <property name="aspects">
       <set class="java.util.HashSet" elementClass="org.jboss.wsf.spi.deployment.DeploymentAspect">
         <inject bean="WSContainerMetaDataDeploymentAspect"/>
+        <inject bean="WSInjectionMetaDataDeploymentAspect"/>
         <inject bean="WSContextRootDeploymentAspect"/>
         <inject bean="WSVirtualHostDeploymentAspect"/>
         <inject bean="WSEndpointAddressDeploymentAspect"/>




More information about the jbossws-commits mailing list