[jboss-cvs] JBossAS SVN: r109739 - in trunk/webservices: src/main/java/org/jboss/webservices/integration/weld and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Dec 7 01:04:19 EST 2010


Author: marius.bogoevici
Date: 2010-12-07 01:04:19 -0500 (Tue, 07 Dec 2010)
New Revision: 109739

Modified:
   trunk/webservices/pom.xml
   trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldInvocationHandler.java
Log:
JBAS-7046: fix injection into JAX-WS web services

Modified: trunk/webservices/pom.xml
===================================================================
--- trunk/webservices/pom.xml	2010-12-07 04:44:08 UTC (rev 109738)
+++ trunk/webservices/pom.xml	2010-12-07 06:04:19 UTC (rev 109739)
@@ -431,6 +431,10 @@
       <groupId>org.picketbox</groupId>
       <artifactId>jboss-security-spi</artifactId>
     </dependency>
+   <dependency>
+       <groupId>org.jboss.weld</groupId>
+       <artifactId>weld-spi</artifactId>
+   </dependency>
   </dependencies>
   
 </project>

Modified: trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldInvocationHandler.java
===================================================================
--- trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldInvocationHandler.java	2010-12-07 04:44:08 UTC (rev 109738)
+++ trunk/webservices/src/main/java/org/jboss/webservices/integration/weld/WeldInvocationHandler.java	2010-12-07 06:04:19 UTC (rev 109739)
@@ -21,7 +21,12 @@
  */
 package org.jboss.webservices.integration.weld;
 
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
 import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.weld.integration.injection.NonContextualObjectInjectionHelper;
+import org.jboss.weld.manager.api.WeldManager;
 import org.jboss.wsf.common.invocation.AbstractInvocationHandlerJSE;
 import org.jboss.wsf.spi.deployment.Endpoint;
 import org.jboss.wsf.spi.invocation.Invocation;
@@ -31,10 +36,13 @@
  * Weld invocation handler.
  *
  * @author <a href="maito:ropalka at redhat.com">Richard Opalka</a>
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
  */
 public final class WeldInvocationHandler extends AbstractInvocationHandlerJSE
 {
 
+   private static final String BEAN_MANAGER_JNDI_NAME = "java:comp/BeanManager";
+
    private final DeploymentUnit deploymentUnit;
 
    private final InvocationHandler delegate;
@@ -73,8 +81,12 @@
     */
    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.
+       try {
+           WeldManager beanManager = (WeldManager) new InitialContext().lookup(BEAN_MANAGER_JNDI_NAME);
+           NonContextualObjectInjectionHelper.injectNonContextualInstance(instance, beanManager);
+       } catch (NamingException e) {
+           throw new IllegalStateException("Unable to locate BeanManager");
+       }
    }
 
 }



More information about the jboss-cvs-commits mailing list