Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D6B8E9C19 for ; Tue, 6 Dec 2011 23:42:45 +0000 (UTC) Received: (qmail 57738 invoked by uid 500); 6 Dec 2011 23:42:45 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 57693 invoked by uid 500); 6 Dec 2011 23:42:45 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 57686 invoked by uid 99); 6 Dec 2011 23:42:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2011 23:42:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2011 23:42:42 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BDDDF2388A67 for ; Tue, 6 Dec 2011 23:42:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1211229 - in /cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws: JaxWsServerFactoryBean.java spring/EndpointDefinitionParser.java Date: Tue, 06 Dec 2011 23:42:20 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111206234220.BDDDF2388A67@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Tue Dec 6 23:42:20 2011 New Revision: 1211229 URL: http://svn.apache.org/viewvc?rev=1211229&view=rev Log: [CXF-3959] Fix issues of double injection with Spring Part 1 Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?rev=1211229&r1=1211228&r2=1211229&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java (original) +++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java Tue Dec 6 23:42:20 2011 @@ -65,6 +65,7 @@ public class JaxWsServerFactoryBean exte protected List handlers = new ArrayList(); private boolean blockPostConstruct; + private boolean blockInjection; public JaxWsServerFactoryBean() { this(new JaxWsServiceFactoryBean()); @@ -255,7 +256,7 @@ public class JaxWsServerFactoryBean exte * @param instance */ protected void injectResources(Object instance) { - if (instance != null) { + if (instance != null && !blockInjection) { ResourceManager resourceManager = getBus().getExtension(ResourceManager.class); List resolvers = resourceManager.getResourceResolvers(); resourceManager = new DefaultResourceManager(resolvers); @@ -276,7 +277,6 @@ public class JaxWsServerFactoryBean exte } /** - * * @param blockPostConstruct @PostConstruct method will not be called * if this property is set to true - this may be necessary in cases * when the @PostConstruct method needs to be called at a later stage, @@ -285,5 +285,14 @@ public class JaxWsServerFactoryBean exte public void setBlockPostConstruct(boolean blockPostConstruct) { this.blockPostConstruct = blockPostConstruct; } + /** + * No injection or PostContstuct will be called if this is set to true. + * If the container has already handled the injection, this should + * be set to true. + * @param b + */ + public void setBlockInjection(boolean b) { + this.blockInjection = b; + } } Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java?rev=1211229&r1=1211228&r2=1211229&view=diff ============================================================================== --- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java (original) +++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java Tue Dec 6 23:42:20 2011 @@ -152,6 +152,7 @@ public class EndpointDefinitionParser ex if (!StringUtils.isEmpty(val)) { if (val.startsWith("#")) { bean.addConstructorArgReference(val.substring(1)); + bean.addPropertyValue("checkBlockConstuct", Boolean.TRUE); } else { try { Object obj = ClassLoaderUtils.loadClass(val, getClass()).newInstance(); @@ -179,6 +180,8 @@ public class EndpointDefinitionParser ex public static class SpringEndpointImpl extends EndpointImpl implements ApplicationContextAware { + boolean checkBlockConstruct; + public SpringEndpointImpl(Object o) { super(o instanceof Bus ? (Bus)o : null, o instanceof Bus ? null : o); @@ -188,8 +191,26 @@ public class EndpointDefinitionParser ex super(bus, implementor); } + public void setCheckBlockConstuct(Boolean b) { + checkBlockConstruct = b; + } public void setApplicationContext(ApplicationContext ctx) throws BeansException { + if (checkBlockConstruct) { + try { + Class cls = Class + .forName("org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"); + if (ctx.getBeanNamesForType(cls, true, false).length != 0) { + //Spring will handle the postconstruct, but won't inject the + // WebServiceContext so we do need to do that. + super.getServerFactory().setBlockPostConstruct(true); + } else { + super.getServerFactory().setBlockInjection(true); + } + } catch (ClassNotFoundException e) { + //ignore + } + } if (getBus() == null) { setBus(BusWiringBeanFactoryPostProcessor.addDefaultBus(ctx)); }