From jbossws-commits at lists.jboss.org Thu Jan 12 10:08:12 2012 Content-Type: multipart/mixed; boundary="===============3752576161757422554==" MIME-Version: 1.0 From: jbossws-commits at lists.jboss.org To: jbossws-commits at lists.jboss.org Subject: [jbossws-commits] JBossWS SVN: r15484 - stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect. Date: Thu, 12 Jan 2012 10:08:11 -0500 Message-ID: <201201121508.q0CF8Bem029460@svn01.web.mwc.hst.phx2.redhat.com> --===============3752576161757422554== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: ropalka Date: 2012-01-12 10:08:10 -0500 (Thu, 12 Jan 2012) New Revision: 15484 Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/dep= loyment/aspect/BusDeploymentAspect.java Log: minor refactoring Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/= cxf/deployment/aspect/BusDeploymentAspect.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/BusDeploymentAspect.java 2012-01-10 15:24:08 UTC (rev 15483) +++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/de= ployment/aspect/BusDeploymentAspect.java 2012-01-12 15:08:10 UTC (rev 15484) @@ -49,24 +49,43 @@ * A deployment aspect that creates the CXF Bus early and attaches it to t= he endpoints (wrapped in a BusHolder) * * @author alessio.soldano(a)jboss.com - * @since 25-Mar-2010 + * @author Richard Opalka */ -public class BusDeploymentAspect extends AbstractDeploymentAspect +public final class BusDeploymentAspect extends AbstractDeploymentAspect { = + @Override + public void start(final Deployment dep) + { + if (BusFactory.getDefaultBus(false) =3D=3D null) + { + //Make sure the default bus is created and set for client side us= age + //(i.e. no server side integration contribution in it) + JBossWSBusFactory.getDefaultBus(Provider.provider().getClass().ge= tClassLoader()); + } + startDeploymentBus(dep); + } + = + @Override + public void stop(final Deployment dep) + { + final BusHolder holder =3D dep.removeAttachment(BusHolder.class); + if (holder !=3D null) + { + holder.close(); + } + } + @SuppressWarnings("unchecked") - protected void startDeploymentBus(Deployment dep) + private void startDeploymentBus(final Deployment dep) { + BusFactory.setThreadDefaultBus(null); ClassLoader origClassLoader =3D SecurityActions.getContextClassLoade= r(); try { - //start cleaning the BusFactory thread locals - BusFactory.setThreadDefaultBus(null); - - ArchiveDeployment aDep =3D (ArchiveDeployment) dep; - - ResourceResolver deploymentResolver =3D aDep.getResourceResolver(= ); - org.apache.cxf.resource.ResourceResolver resolver =3D new JBossWS= ResourceResolver(deploymentResolver); + final ArchiveDeployment aDep =3D (ArchiveDeployment) dep; + final ResourceResolver deploymentResolver =3D aDep.getResourceRes= olver(); + final org.apache.cxf.resource.ResourceResolver resolver =3D new J= BossWSResourceResolver(deploymentResolver); Map contextParams =3D (Map) dep.g= etProperty(WSConstants.STACK_CONTEXT_PARAMS); String jbosswsCxfXml =3D contextParams =3D=3D null ? null : conte= xtParams.get(BusHolder.PARAM_CXF_BEANS_URL); BusHolder holder =3D null; @@ -76,69 +95,40 @@ //parent to make sure user provided libs in the deployment do no = mess up the WS endpoint's deploy if they duplicates //libraries already available on the application server modules. SecurityActions.setContextClassLoader(new DelegateClassLoader(dep= .getRuntimeClassLoader(), origClassLoader)); - if (jbosswsCxfXml !=3D null) // Spring available and jbossws-cxf.= xml provided + if (jbosswsCxfXml !=3D null) { - URL cxfServletURL =3D null; - try - { - cxfServletURL =3D deploymentResolver.resolve("WEB-INF/cxf-s= ervlet.xml"); - } - catch (IOException e) - { - } //ignore, cxf-servlet.xml is optional, we might even decide = not to support this - - try - { - holder =3D new SpringBusHolder(cxfServletURL, deploymentRes= olver.resolve(jbosswsCxfXml)); - Configurer configurer =3D holder.createServerConfigurer(dep= .getAttachment(BindingCustomization.class), - new WSDLFilePublisher(aDep), dep.getService().getEndp= oints(), aDep.getRootFile()); - holder.configure(new SoapTransportFactoryExt(), resolver, c= onfigurer); - } - catch (Exception e) - { - throw new RuntimeException(e); //re-throw, jboss-cxf.xml is= required - } + // Spring available and jbossws-cxf.xml provided + final URL cxfServletUrl =3D getResourceUrl(deploymentResolver,= "WEB-INF/cxf-servlet.xml", false); // TODO: decide not to support this? + final URL jbosswsCxfUrl =3D getResourceUrl(deploymentResolver,= jbosswsCxfXml, true); + holder =3D new SpringBusHolder(cxfServletUrl, jbosswsCxfUrl); } else - //Spring not available or jbossws-cxf.xml not provided { + // Spring not available or jbossws-cxf.xml not provided DDBeans metadata =3D dep.getAttachment(DDBeans.class); holder =3D new NonSpringBusHolder(metadata); - Configurer configurer =3D holder.createServerConfigurer(dep.ge= tAttachment(BindingCustomization.class), - new WSDLFilePublisher(aDep), dep.getService().getEndpoin= ts(), aDep.getRootFile()); - holder.configure(new SoapTransportFactoryExt(), resolver, conf= igurer); } + Configurer configurer =3D holder.createServerConfigurer(dep.getAt= tachment(BindingCustomization.class), new WSDLFilePublisher(aDep), dep.getS= ervice().getEndpoints(), aDep.getRootFile()); + holder.configure(new SoapTransportFactoryExt(), resolver, configu= rer); dep.addAttachment(BusHolder.class, holder); } finally { - //clean threadlocals in BusFactory and restore the original class= loader BusFactory.setThreadDefaultBus(null); SecurityActions.setContextClassLoader(origClassLoader); } } - = - = - = - @Override - public void start(Deployment dep) - { - //Make sure the default bus is created and set for client side usage - //(i.e. no server side integration contribution in it) - if (BusFactory.getDefaultBus(false) =3D=3D null) - { - JBossWSBusFactory.getDefaultBus(Provider.provider().getClass().ge= tClassLoader()); - } - this.startDeploymentBus(dep); + + private static URL getResourceUrl(final ResourceResolver resolver, fina= l String resourcePath, final boolean fail) { + try { + return resolver.resolve(resourcePath); + } catch (final IOException e) { + if (fail) { + throw new RuntimeException(e); + } else { + return null; + } + } } = - @Override - public void stop(Deployment dep) - { - BusHolder holder =3D dep.removeAttachment(BusHolder.class); - if (holder !=3D null) - { - holder.close(); - } - } } --===============3752576161757422554==--