Author: richard.opalka(a)jboss.com
Date: 2011-10-03 10:22:36 -0400 (Mon, 03 Oct 2011)
New Revision: 15032
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFInstanceProvider.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/CXFInstanceProviderDeploymentAspect.java
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/Message.properties
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as6.xml
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as7.xml
stack/cxf/trunk/modules/server/src/main/resources/jbossws-jaxrpc-config-as6.xml
Log:
[JBWS-3363] extending SPI - providing hook for instances retrieval
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFInstanceProvider.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFInstanceProvider.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFInstanceProvider.java 2011-10-03
14:22:36 UTC (rev 15032)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., 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;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import javax.xml.ws.handler.Handler;
+
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
+import org.jboss.ws.api.util.BundleUtils;
+import org.jboss.wsf.spi.deployment.InstanceProvider;
+
+/**
+ * CXF instance provider.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class CXFInstanceProvider implements InstanceProvider {
+
+ private static final ResourceBundle bundle =
BundleUtils.getBundle(CXFInstanceProvider.class);
+ private final ServerFactoryBean factory;
+ private final Map<String, Object> cache = new HashMap<String, Object>();
+
+ public CXFInstanceProvider(final ServerFactoryBean factory) {
+ this.factory = factory;
+ }
+
+ public synchronized Object getInstance(final String className) {
+ Object instance = cache.get(className);
+ if (instance == null) {
+ final Object serviceBean = factory.getServiceBean();
+ if (className.equals(factory.getServiceBean().getClass().getName())) {
+ cache.put(className, instance = serviceBean);
+ }
+ if (instance == null)
+ {
+ List<Handler> chain = ((JaxWsEndpointImpl)
factory.getServer().getEndpoint()).getJaxwsBinding().getHandlerChain();
+ if (chain != null) {
+ for (Handler handler : chain) {
+ if (className.equals(handler.getClass().getName())) {
+ cache.put(className, instance = handler);
+ }
+ }
+ }
+ }
+ }
+ if (instance == null)
+ throw new IllegalStateException(BundleUtils.getMessage(bundle,
"CANNOT_LOAD_CLASS", className));
+ return instance;
+ }
+
+}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/Message.properties
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/Message.properties 2011-10-03
13:47:54 UTC (rev 15031)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/Message.properties 2011-10-03
14:22:36 UTC (rev 15032)
@@ -1,3 +1,4 @@
CANNOT_OBTAIN_REGISTRY=Cannot obtain DestinationRegistry!
CANNOT_OBTAIN_DESTINATION=Cannot obtain destination for: {0}
CANNOT_GET_DESTINATIONFACTORY=Cannot get DestinationFactory for http transport!
+CANNOT_LOAD_CLASS=Cannot load class: {0}
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/CXFInstanceProviderDeploymentAspect.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/CXFInstanceProviderDeploymentAspect.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/CXFInstanceProviderDeploymentAspect.java 2011-10-03
14:22:36 UTC (rev 15032)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., 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.deployment.aspect;
+
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.jboss.ws.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.stack.cxf.CXFInstanceProvider;
+
+/**
+ * Instance provider DA.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class CXFInstanceProviderDeploymentAspect extends AbstractDeploymentAspect
+{
+
+ @Override
+ public void start(final Deployment dep)
+ {
+ for (final Endpoint ep : dep.getService().getEndpoints())
+ {
+ final ServerFactoryBean factory = ep.getAttachment(ServerFactoryBean.class);
+ ep.setInstanceProvider(new CXFInstanceProvider(factory));
+ }
+ }
+
+}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java 2011-10-03
13:47:54 UTC (rev 15031)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java 2011-10-03
14:22:36 UTC (rev 15032)
@@ -119,6 +119,7 @@
private static void injectServiceAndHandlerResources(Endpoint endpoint)
{
ServerFactoryBean factory = endpoint.getAttachment(ServerFactoryBean.class);
+ if (factory == null) throw new UnsupportedOperationException(); // TODO: move
injection to ASIL
if (factory != null)
{
InjectionsMetaData metadata = endpoint.getAttachment(InjectionsMetaData.class);
@@ -129,8 +130,9 @@
{
for (Handler handler : chain)
{
- InjectionHelper.injectResources(handler, metadata, jndiContext);
- InjectionHelper.callPostConstructMethod(handler);
+ final Object handlerInstance =
endpoint.getInstanceProvider().getInstance(handler.getClass().getName());
+ InjectionHelper.injectResources(handlerInstance, metadata, jndiContext);
+ InjectionHelper.callPostConstructMethod(handlerInstance);
}
}
}
@@ -143,7 +145,8 @@
{
if (isJaxwsJseEndpoint(endpoint) && factory.getServiceBean() != null)
{
- InjectionHelper.callPreDestroyMethod(factory.getServiceBean());
+ final Object epInstance =
endpoint.getInstanceProvider().getInstance(factory.getServiceBean().getClass().getName());
+ InjectionHelper.callPreDestroyMethod(epInstance);
}
}
}
Modified: stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as6.xml
===================================================================
---
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as6.xml 2011-10-03
13:47:54 UTC (rev 15031)
+++
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as6.xml 2011-10-03
14:22:36 UTC (rev 15032)
@@ -64,6 +64,12 @@
<property name="forJaxRpc">false</property>
</bean>
+ <bean name="WSCXFInstanceProviderDeploymentAspect"
class="org.jboss.wsf.stack.cxf.deployment.aspect.CXFInstanceProviderDeploymentAspect">
+ <property
name="requires">ContainerMetaData,BusHolder</property>
+ <property name="provides">StackInstanceProvider</property>
+ <property name="forJaxRpc">false</property>
+ </bean>
+
<bean name="WSCXFEndpointRecordProcessorDeploymentAspect"
class="org.jboss.ws.common.deployment.EndpointRecordProcessorDeploymentAspect">
<property name="mbeanServer"><inject
bean="WSMBeanServerLocator"
property="mbeanServer"/></property>
<property name="requires">RegisteredEndpoint</property>
Modified: stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as7.xml
===================================================================
---
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as7.xml 2011-10-03
13:47:54 UTC (rev 15031)
+++
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as7.xml 2011-10-03
14:22:36 UTC (rev 15032)
@@ -55,6 +55,12 @@
<property name="forJaxRpc"
class="boolean">false</property>
</deploymentAspect>
+ <deploymentAspect
class="org.jboss.wsf.stack.cxf.deployment.aspect.CXFInstanceProviderDeploymentAspect">
+ <property name="requires"
class="java.lang.String">ContainerMetaData,BusHolder</property>
+ <property name="provides"
class="java.lang.String">StackInstanceProvider</property>
+ <property name="forJaxRpc"
class="boolean">false</property>
+ </deploymentAspect>
+
<deploymentAspect
class="org.jboss.ws.common.deployment.JAXBIntroDeploymentAspect">
<property name="provides"
class="java.lang.String">JAXBIntros</property>
<property name="forJaxRpc"
class="boolean">false</property>
Modified: stack/cxf/trunk/modules/server/src/main/resources/jbossws-jaxrpc-config-as6.xml
===================================================================
---
stack/cxf/trunk/modules/server/src/main/resources/jbossws-jaxrpc-config-as6.xml 2011-10-03
13:47:54 UTC (rev 15031)
+++
stack/cxf/trunk/modules/server/src/main/resources/jbossws-jaxrpc-config-as6.xml 2011-10-03
14:22:36 UTC (rev 15032)
@@ -28,6 +28,12 @@
<property name="forJaxWs">false</property>
</bean>
+ <bean name="WSNativeInstanceProviderDeploymentAspect"
class="org.jboss.wsf.stack.jbws.NativeInstanceProviderDeploymentAspect">
+ <property name="requires">ContainerMetaData</property>
+ <property name="provides">StackInstanceProvider</property>
+ <property name="forJaxWs">false</property>
+ </bean>
+
<bean name="WSNativePublishContractDeploymentAspect"
class="org.jboss.wsf.stack.jbws.PublishContractDeploymentAspect">
<property name="requires">UnifiedMetaDataModel,
JAXBIntros</property>
<property name="provides">PublishedContract</property>