[jboss-cvs] JBossAS SVN: r109711 - in trunk/webservices: src/main/java/org/jboss/webservices/integration and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Dec 3 15:20:15 EST 2010


Author: richard.opalka at jboss.com
Date: 2010-12-03 15:20:15 -0500 (Fri, 03 Dec 2010)
New Revision: 109711

Added:
   trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/
   trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldDeploymentAspect.java
   trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldInvocationHandler.java
Modified:
   trunk/webservices/pom.xml
   trunk/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml
Log:
[JBWS-3177] CDI integration - round2

Modified: trunk/webservices/pom.xml
===================================================================
--- trunk/webservices/pom.xml	2010-12-03 19:50:27 UTC (rev 109710)
+++ trunk/webservices/pom.xml	2010-12-03 20:20:15 UTC (rev 109711)
@@ -116,6 +116,12 @@
     </dependency>
     <!-- jboss provided dependencies -->
     <dependency>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>weld-int-deployer</artifactId>
+      <version>${version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
       <groupId>org.jboss.switchboard</groupId>
       <artifactId>jboss-switchboard-spi</artifactId>
     </dependency>

Added: trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldDeploymentAspect.java
===================================================================
--- trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldDeploymentAspect.java	                        (rev 0)
+++ trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldDeploymentAspect.java	2010-12-03 20:20:15 UTC (rev 109711)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.webservices.integration.weld;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.weld.integration.deployer.DeployersUtils;
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.common.integration.WSHelper;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+/**
+ * Weld deployment aspect that associates Weld Invocation handler
+ * if WS CDI integration is detected.
+ *
+ * @author <a href="mailto:ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WeldDeploymentAspect extends AbstractDeploymentAspect
+{
+
+   public WeldDeploymentAspect()
+   {
+      // does nothing
+   }
+
+   @Override
+   public void start(final Deployment dep)
+   {
+      if (!WSHelper.isJaxwsJseDeployment(dep))
+      {
+         // we support weld integration for JAXWS JSE endpoints only
+         return;
+      }
+
+      final DeploymentUnit deploymentUnit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
+      if (this.isWeldDeployment(deploymentUnit))
+      {
+         for (final Endpoint endpoint : dep.getService().getEndpoints())
+         {
+            endpoint.setInvocationHandler(new WeldInvocationHandler(deploymentUnit, endpoint.getInvocationHandler()));
+         }
+      }
+   }
+
+   private boolean isWeldDeployment(final DeploymentUnit unit)
+   {
+      return unit.getAttachment(DeployersUtils.WELD_FILES) != null;
+   }
+
+}

Added: trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldInvocationHandler.java
===================================================================
--- trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldInvocationHandler.java	                        (rev 0)
+++ trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldInvocationHandler.java	2010-12-03 20:20:15 UTC (rev 109711)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.webservices.integration.weld;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+
+/**
+ * Weld invocation handler.
+ *
+ * @author <a href="maito:ropalka at redhat.com">Richard Opalka</a>
+ */
+public final class WeldInvocationHandler extends AbstractInvocationHandlerJSE
+{
+
+   private final DeploymentUnit deploymentUnit;
+
+   private final InvocationHandler delegate;
+
+   public WeldInvocationHandler(final DeploymentUnit unit, final InvocationHandler delegate)
+   {
+      this.deploymentUnit = unit;
+      this.delegate = delegate;
+   }
+
+   @Override
+   public void onEndpointInstantiated(final Endpoint endpoint, final Invocation invocation) throws Exception
+   {
+      // handle Weld injections first
+      this.handleWeldInjection(invocation.getInvocationContext().getTargetBean());
+      // handle JBossWS injections last and call @PostConstruct & @PreDestroy annotated lifecycle methods
+      this.delegate.onEndpointInstantiated(endpoint, invocation);
+   }
+
+   @Override
+   public void onBeforeInvocation(final Invocation invocation) throws Exception
+   {
+      this.delegate.onBeforeInvocation(invocation);
+   }
+
+   @Override
+   public void onAfterInvocation(final Invocation invocation) throws Exception
+   {
+      this.delegate.onAfterInvocation(invocation);
+   }
+
+   /**
+    * Handles weld injection.
+    *
+    * @param instance to operate upon
+    */
+   private void handleWeldInjection(final Object instance)
+   {
+      // TODO: implement Marius ;)
+      // Just FYI calling 'new InitialContext()' in this method will return proper JNDI ctx because this method is executed in servlet environment.
+   }
+
+}

Modified: trunk/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml
===================================================================
--- trunk/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml	2010-12-03 19:50:27 UTC (rev 109710)
+++ trunk/webservices/src/resources/jbossws-jboss.deployer/META-INF/stack-agnostic-jboss-beans.xml	2010-12-03 20:20:15 UTC (rev 109711)
@@ -153,4 +153,9 @@
     <property name="provides">WebMetaData</property>
   </bean>
 
+  <bean name="WSWeldDeploymentAspect" class="org.jboss.webservices.integration.weld.WeldDeploymentAspect">
+    <property name="requires">StackEndpointHandler</property>
+    <property name="provides">CDIInjection</property>
+  </bean>
+
 </deployment>



More information about the jboss-cvs-commits mailing list