Author: asoldano
Date: 2014-04-07 10:55:13 -0400 (Mon, 07 Apr 2014)
New Revision: 18566
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/injection/
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/injection/JBossWSResourceInjectionResolver.java
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSNonSpringBusFactory.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java
Log:
[JBWS-3786] @Resource injection not working on handlers attached to JAX-WS clients running
in-container
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSNonSpringBusFactory.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSNonSpringBusFactory.java 2014-04-03
10:32:26 UTC (rev 18565)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSNonSpringBusFactory.java 2014-04-07
14:55:13 UTC (rev 18566)
@@ -28,7 +28,9 @@
import org.apache.cxf.bus.CXFBusFactory;
import org.apache.cxf.bus.extension.ExtensionManagerBus;
import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.resource.ResourceManager;
import org.jboss.wsf.stack.cxf.client.ProviderImpl;
+import org.jboss.wsf.stack.cxf.client.injection.JBossWSResourceInjectionResolver;
/**
*
@@ -59,4 +61,10 @@
bus.initialize();
return bus;
}
+
+ protected void initializeBus(Bus bus) {
+ super.initializeBus(bus);
+ final ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
+
resourceManager.addResourceResolver(JBossWSResourceInjectionResolver.getInstance());
+ }
}
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java 2014-04-03
10:32:26 UTC (rev 18565)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java 2014-04-07
14:55:13 UTC (rev 18566)
@@ -29,7 +29,9 @@
import org.apache.cxf.buslifecycle.BusLifeCycleListener;
import org.apache.cxf.buslifecycle.BusLifeCycleManager;
import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.resource.ResourceManager;
import org.jboss.wsf.stack.cxf.Loggers;
+import org.jboss.wsf.stack.cxf.client.injection.JBossWSResourceInjectionResolver;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.Resource;
@@ -147,6 +149,12 @@
configurer.setCustomizer(new BeanCustomizer());
bus.setExtension(configurer, Configurer.class);
}
+
+ protected void initializeBus(Bus bus) {
+ super.initializeBus(bus);
+ final ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
+
resourceManager.addResourceResolver(JBossWSResourceInjectionResolver.getInstance());
+ }
void registerAppContextLifeCycleListener(final Bus bus, final BusApplicationContext
bac)
{
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/injection/JBossWSResourceInjectionResolver.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/injection/JBossWSResourceInjectionResolver.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/injection/JBossWSResourceInjectionResolver.java 2014-04-07
14:55:13 UTC (rev 18566)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.stack.cxf.client.injection;
+
+import java.io.InputStream;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.cxf.resource.ResourceResolver;
+
+/**
+ * A CXF ResourceResolver that tries looking up the specified resources in the JNDI
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 07-Apr-2014
+ */
+public class JBossWSResourceInjectionResolver implements ResourceResolver
+{
+ private static final JBossWSResourceInjectionResolver me = new
JBossWSResourceInjectionResolver();
+
+ private JBossWSResourceInjectionResolver() {
+ //NOOP
+ }
+
+ public static JBossWSResourceInjectionResolver getInstance() {
+ return me;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T resolve(String resourceName, Class<T> resourceType)
+ {
+ try {
+ return (T)new InitialContext().lookup("java:comp/env/" +
resourceName);
+ } catch (NamingException ne) {
+ return null;
+ }
+ }
+
+ @Override
+ public InputStream getAsStream(String name)
+ {
+ return null;
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/injection/JBossWSResourceInjectionResolver.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native