From jbossws-commits at lists.jboss.org Mon Oct 3 10:22:36 2011 Content-Type: multipart/mixed; boundary="===============6448406997254090530==" MIME-Version: 1.0 From: jbossws-commits at lists.jboss.org To: jbossws-commits at lists.jboss.org Subject: [jbossws-commits] JBossWS SVN: r15032 - in stack/cxf/trunk/modules/server/src/main: java/org/jboss/wsf/stack/cxf/deployment/aspect and 2 other directories. Date: Mon, 03 Oct 2011 10:22:36 -0400 Message-ID: <201110031422.p93EMa00024022@svn01.web.mwc.hst.phx2.redhat.com> --===============6448406997254090530== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/CXF= InstanceProvider.java stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/dep= loyment/aspect/CXFInstanceProviderDeploymentAspect.java Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/Mes= sage.properties stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/tra= nsport/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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CX= FInstanceProvider.java (rev 0) +++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CX= FInstanceProvider.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 Richard Opalka + */ +public final class CXFInstanceProvider implements InstanceProvider { + + private static final ResourceBundle bundle =3D BundleUtils.getBundle(C= XFInstanceProvider.class); + private final ServerFactoryBean factory; + private final Map cache =3D new HashMap(); + + public CXFInstanceProvider(final ServerFactoryBean factory) { + this.factory =3D factory; + } + + public synchronized Object getInstance(final String className) { + Object instance =3D cache.get(className); + if (instance =3D=3D null) { + final Object serviceBean =3D factory.getServiceBean(); + if (className.equals(factory.getServiceBean().getClass().getNa= me())) { + cache.put(className, instance =3D serviceBean); + } + if (instance =3D=3D null) + { + List chain =3D ((JaxWsEndpointImpl) factory.getSe= rver().getEndpoint()).getJaxwsBinding().getHandlerChain(); + if (chain !=3D null) { + for (Handler handler : chain) { + if (className.equals(handler.getClass().getName())= ) { + cache.put(className, instance =3D handler); + } + } + } + } + } + if (instance =3D=3D 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/Me= ssage.properties 2011-10-03 13:47:54 UTC (rev 15031) +++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/Me= ssage.properties 2011-10-03 14:22:36 UTC (rev 15032) @@ -1,3 +1,4 @@ CANNOT_OBTAIN_REGISTRY=3DCannot obtain DestinationRegistry! CANNOT_OBTAIN_DESTINATION=3DCannot obtain destination for: {0} CANNOT_GET_DESTINATIONFACTORY=3DCannot get DestinationFactory for http tra= nsport! +CANNOT_LOAD_CLASS=3DCannot load class: {0} Added: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf= /deployment/aspect/CXFInstanceProviderDeploymentAspect.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/de= ployment/aspect/CXFInstanceProviderDeploymentAspect.java = (rev 0) +++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/de= ployment/aspect/CXFInstanceProviderDeploymentAspect.java 2011-10-03 14:22:3= 6 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 Richard Opalka + */ +public final class CXFInstanceProviderDeploymentAspect extends AbstractDep= loymentAspect +{ + + @Override + public void start(final Deployment dep) + { + for (final Endpoint ep : dep.getService().getEndpoints()) + { + final ServerFactoryBean factory =3D ep.getAttachment(ServerFacto= ryBean.class); + ep.setInstanceProvider(new CXFInstanceProvider(factory)); + } + } + +} Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/= cxf/transport/ServletHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/tr= ansport/ServletHelper.java 2011-10-03 13:47:54 UTC (rev 15031) +++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/tr= ansport/ServletHelper.java 2011-10-03 14:22:36 UTC (rev 15032) @@ -119,6 +119,7 @@ private static void injectServiceAndHandlerResources(Endpoint endpoint) { ServerFactoryBean factory =3D endpoint.getAttachment(ServerFactoryBe= an.class); + if (factory =3D=3D null) throw new UnsupportedOperationException(); = // TODO: move injection to ASIL if (factory !=3D null) { InjectionsMetaData metadata =3D endpoint.getAttachment(Injections= MetaData.class); @@ -129,8 +130,9 @@ { for (Handler handler : chain) { - InjectionHelper.injectResources(handler, metadata, jndiCont= ext); - InjectionHelper.callPostConstructMethod(handler); + final Object handlerInstance =3D endpoint.getInstanceProvid= er().getInstance(handler.getClass().getName()); + InjectionHelper.injectResources(handlerInstance, metadata, = jndiContext); + InjectionHelper.callPostConstructMethod(handlerInstance); } } } @@ -143,7 +145,8 @@ { if (isJaxwsJseEndpoint(endpoint) && factory.getServiceBean() !=3D= null) { - InjectionHelper.callPreDestroyMethod(factory.getServiceBean()); + final Object epInstance =3D endpoint.getInstanceProvider().get= Instance(factory.getServiceBean().getClass().getName()); + InjectionHelper.callPreDestroyMethod(epInstance); } } } Modified: stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-con= fig-as6.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as= 6.xml 2011-10-03 13:47:54 UTC (rev 15031) +++ stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as= 6.xml 2011-10-03 14:22:36 UTC (rev 15032) @@ -64,6 +64,12 @@ false = + + ContainerMetaData,BusHolder + StackInstanceProvider + false + + RegisteredEndpoint Modified: stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-con= fig-as7.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as= 7.xml 2011-10-03 13:47:54 UTC (rev 15031) +++ stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as= 7.xml 2011-10-03 14:22:36 UTC (rev 15032) @@ -55,6 +55,12 @@ false = + + ContainerMetaDa= ta,BusHolder + StackInstancePr= ovider + false + + JAXBIntros false Modified: stack/cxf/trunk/modules/server/src/main/resources/jbossws-jaxrpc-= config-as6.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 @@ false = + + ContainerMetaData + StackInstanceProvider + false + + UnifiedMetaDataModel, JAXBIntros PublishedContract --===============6448406997254090530==--