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 EE41811B60 for ; Thu, 24 Jul 2014 17:40:53 +0000 (UTC) Received: (qmail 99642 invoked by uid 500); 24 Jul 2014 17:40:53 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 99458 invoked by uid 500); 24 Jul 2014 17:40:53 -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 99443 invoked by uid 99); 24 Jul 2014 17:40:53 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jul 2014 17:40:53 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 901C69B3210; Thu, 24 Jul 2014 17:40:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dkulp@apache.org To: commits@cxf.apache.org Date: Thu, 24 Jul 2014 17:40:54 -0000 Message-Id: <481cc6dba5ad4e67ab4ad3a45893e94a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/3] git commit: Move some of the jaxws22 functionality up into the base classes. Deprecate the 2.2 specific versions Move some of the jaxws22 functionality up into the base classes. Deprecate the 2.2 specific versions Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b4536602 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b4536602 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b4536602 Branch: refs/heads/master Commit: b4536602d376a36bcbd02d21d5ab42f19d4e5b22 Parents: 6e4f0f6 Author: Daniel Kulp Authored: Thu Jul 24 13:19:37 2014 -0400 Committer: Daniel Kulp Committed: Thu Jul 24 13:19:37 2014 -0400 ---------------------------------------------------------------------- .../java/org/apache/cxf/jaxws/EndpointImpl.java | 18 ++++++ .../apache/cxf/jaxws/JAXWSMethodInvoker.java | 16 ++++++ .../org/apache/cxf/jaxws/spi/ProviderImpl.java | 33 +++++++++++ .../jaxws/spring/EndpointDefinitionParser.java | 18 +----- .../org/apache/cxf/jaxws22/EndpointImpl.java | 25 +-------- .../org/apache/cxf/jaxws22/JAXWS22Invoker.java | 15 +---- .../apache/cxf/jaxws22/spi/ProviderImpl.java | 58 ++------------------ .../spring/JAXWS22SpringEndpointImpl.java | 56 ------------------- .../META-INF/services/javax.xml.ws.spi.Provider | 2 +- 9 files changed, 80 insertions(+), 161 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/b4536602/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java index ca220be..9807cae 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java @@ -35,6 +35,7 @@ import javax.wsdl.Definition; import javax.xml.namespace.QName; import javax.xml.transform.Source; import javax.xml.ws.Binding; +import javax.xml.ws.EndpointContext; import javax.xml.ws.EndpointReference; import javax.xml.ws.WebServiceException; import javax.xml.ws.WebServiceFeature; @@ -61,6 +62,7 @@ import org.apache.cxf.databinding.DataBinding; import org.apache.cxf.endpoint.Server; import org.apache.cxf.endpoint.ServerImpl; import org.apache.cxf.feature.Feature; +import org.apache.cxf.frontend.ServerFactoryBean; import org.apache.cxf.frontend.WSDLGetUtils; import org.apache.cxf.helpers.CastUtils; import org.apache.cxf.interceptor.Interceptor; @@ -72,6 +74,7 @@ import org.apache.cxf.message.Message; import org.apache.cxf.service.Service; import org.apache.cxf.service.invoker.Invoker; import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.transport.http_jaxws_spi.JAXWSHttpSpiTransportFactory; import org.apache.cxf.wsdl.WSDLManager; import org.apache.cxf.wsdl11.WSDLServiceBuilder; @@ -122,6 +125,7 @@ public class EndpointImpl extends javax.xml.ws.Endpoint = new ModCountCopyOnWriteArrayList>(); @SuppressWarnings("rawtypes") private List handlers = new ModCountCopyOnWriteArrayList(); + private EndpointContext endpointContext; /** * Flag indicating internal state of this instance. If true, @@ -838,5 +842,19 @@ public class EndpointImpl extends javax.xml.ws.Endpoint .getName()).toString()); } } + + public void setEndpointContext(EndpointContext ctxt) { + endpointContext = ctxt; + } + public EndpointContext getEndpointContext() { + return endpointContext; + } + public void publish(javax.xml.ws.spi.http.HttpContext context) { + ServerFactoryBean sf = getServerFactory(); + if (sf.getDestinationFactory() == null) { + sf.setDestinationFactory(new JAXWSHttpSpiTransportFactory(context)); + } + publish(context.getPath()); + } } http://git-wip-us.apache.org/repos/asf/cxf/blob/b4536602/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java index 4a7cddf..8c56fbc 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java @@ -42,6 +42,9 @@ public class JAXWSMethodInvoker extends AbstractJAXWSMethodInvoker { public static final String COPY_SOAP_HEADERS_BY_FAULT = "org.apache.cxf.fault.copySoapHeaders"; + javax.xml.ws.spi.Invoker invoker; + + public JAXWSMethodInvoker(final Object bean) { super(new SingletonFactory(bean)); } @@ -49,8 +52,21 @@ public class JAXWSMethodInvoker extends AbstractJAXWSMethodInvoker { public JAXWSMethodInvoker(Factory factory) { super(factory); } + public JAXWSMethodInvoker(javax.xml.ws.spi.Invoker i) { + super(null); + invoker = i; + } @Override + protected Object performInvocation(Exchange exchange, final Object serviceObject, Method m, + Object[] paramArray) throws Exception { + if (invoker != null) { + return invoker.invoke(m, paramArray); + } + return super.performInvocation(exchange, serviceObject, m, paramArray); + } + + @Override protected Object invoke(Exchange exchange, final Object serviceObject, Method m, List params) { http://git-wip-us.apache.org/repos/asf/cxf/blob/b4536602/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java index 01cdfb9..cf797aa 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java @@ -24,6 +24,7 @@ import java.net.URL; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.logging.Logger; @@ -41,11 +42,13 @@ import javax.xml.ws.Endpoint; import javax.xml.ws.EndpointReference; import javax.xml.ws.WebServiceException; import javax.xml.ws.WebServiceFeature; +import javax.xml.ws.spi.Invoker; import javax.xml.ws.spi.ServiceDelegate; import javax.xml.ws.wsaddressing.W3CEndpointReference; import org.w3c.dom.Document; import org.w3c.dom.Element; + import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.apache.cxf.common.classloader.ClassLoaderUtils; @@ -54,7 +57,10 @@ import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.helpers.DOMUtils; import org.apache.cxf.jaxws.EndpointImpl; import org.apache.cxf.jaxws.EndpointUtils; +import org.apache.cxf.jaxws.JAXWSMethodInvoker; +import org.apache.cxf.jaxws.JaxWsServerFactoryBean; import org.apache.cxf.jaxws.ServiceImpl; +import org.apache.cxf.jaxws.context.WebServiceContextImpl; import org.apache.cxf.message.MessageUtils; import org.apache.cxf.phase.PhaseInterceptorChain; import org.apache.cxf.staxutils.StaxUtils; @@ -159,6 +165,33 @@ public class ProviderImpl extends javax.xml.ws.spi.Provider { ep.publish(address); return ep; } + + //new in 2.2 + public Endpoint createEndpoint(String bindingId, Class implementorClass, + Invoker invoker, WebServiceFeature ... features) { + if (EndpointUtils.isValidImplementor(implementorClass)) { + Bus bus = BusFactory.getThreadDefaultBus(); + JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); + if (features != null) { + factory.getJaxWsServiceFactory().setWsFeatures(Arrays.asList(features)); + } + if (invoker != null) { + factory.setInvoker(new JAXWSMethodInvoker(invoker)); + try { + invoker.inject(new WebServiceContextImpl()); + } catch (Exception e) { + throw new WebServiceException(new Message("ENDPOINT_CREATION_FAILED_MSG", + LOG).toString(), e); + } + } + EndpointImpl ep = new EndpointImpl(bus, null, factory); + ep.setImplementorClass(implementorClass); + return ep; + } else { + throw new WebServiceException(new Message("INVALID_IMPLEMENTOR_EXC", LOG).toString()); + } + } + public W3CEndpointReference createW3CEndpointReference(String address, QName serviceName, http://git-wip-us.apache.org/repos/asf/cxf/blob/b4536602/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java index e930e73..210cf91 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/EndpointDefinitionParser.java @@ -30,14 +30,12 @@ import org.w3c.dom.NamedNodeMap; import org.apache.cxf.Bus; import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor; import org.apache.cxf.bus.spring.Jsr250BeanPostProcessor; -import org.apache.cxf.common.classloader.ClassLoaderUtils; import org.apache.cxf.common.injection.NoJSR250Annotations; import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser; import org.apache.cxf.configuration.spring.BusWiringType; import org.apache.cxf.helpers.DOMUtils; import org.apache.cxf.jaxws.EndpointImpl; -import org.apache.cxf.jaxws.spi.ProviderImpl; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; @@ -52,21 +50,7 @@ import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor; public class EndpointDefinitionParser extends AbstractBeanDefinitionParser { - private static final Class EP_CLASS; - static { - Class cls = SpringEndpointImpl.class; - try { - if (ProviderImpl.isJaxWs22()) { - cls = ClassLoaderUtils - .loadClass("org.apache.cxf.jaxws22.spring.JAXWS22SpringEndpointImpl", - EndpointDefinitionParser.class); - } - } catch (Throwable t) { - cls = SpringEndpointImpl.class; - } - EP_CLASS = cls; - } - + private static final Class EP_CLASS = SpringEndpointImpl.class; private static final String IMPLEMENTOR = "implementor"; http://git-wip-us.apache.org/repos/asf/cxf/blob/b4536602/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/EndpointImpl.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/EndpointImpl.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/EndpointImpl.java index 7c38466..d4e80a8 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/EndpointImpl.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/EndpointImpl.java @@ -19,21 +19,16 @@ package org.apache.cxf.jaxws22; -import javax.xml.ws.EndpointContext; import javax.xml.ws.WebServiceFeature; import org.apache.cxf.Bus; -import org.apache.cxf.frontend.ServerFactoryBean; import org.apache.cxf.jaxws.JaxWsServerFactoryBean; -import org.apache.cxf.transport.http_jaxws_spi.JAXWSHttpSpiTransportFactory; /** - * + * @deprecated - all functionality moved to superclass - create superclass instead */ +@Deprecated public class EndpointImpl extends org.apache.cxf.jaxws.EndpointImpl { - //What really is the point of the EndpointContext in JAX-WS 2.2? - //There is a setter, but no getter. - Object endpointContext; /** * @param implementor @@ -98,19 +93,5 @@ public class EndpointImpl extends org.apache.cxf.jaxws.EndpointImpl { public EndpointImpl(Bus bus, Object implementor) { super(bus, implementor); } - - //new in 2.2, but introduces a new class not found in 2.1 - public void setEndpointContext(EndpointContext ctxt) { - endpointContext = ctxt; - } - - //new in 2.2, but introduces a new class not found in 2.1 - public void publish(javax.xml.ws.spi.http.HttpContext context) { - ServerFactoryBean serverFactory = getServerFactory(); - if (serverFactory.getDestinationFactory() == null) { - serverFactory.setDestinationFactory(new JAXWSHttpSpiTransportFactory(context)); - } - super.publish(context.getPath()); - } - + } http://git-wip-us.apache.org/repos/asf/cxf/blob/b4536602/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/JAXWS22Invoker.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/JAXWS22Invoker.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/JAXWS22Invoker.java index 4432ca1..5488a63 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/JAXWS22Invoker.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/JAXWS22Invoker.java @@ -19,25 +19,16 @@ package org.apache.cxf.jaxws22; -import java.lang.reflect.Method; - import org.apache.cxf.jaxws.JAXWSMethodInvoker; -import org.apache.cxf.message.Exchange; import org.apache.cxf.service.invoker.Invoker; /** - * + * @deprecated - functionality moved into superclass */ +@Deprecated public class JAXWS22Invoker extends JAXWSMethodInvoker implements Invoker { - javax.xml.ws.spi.Invoker invoker; public JAXWS22Invoker(javax.xml.ws.spi.Invoker inv) { - super(null); - invoker = inv; - } - @Override - protected Object performInvocation(Exchange exchange, final Object serviceObject, Method m, - Object[] paramArray) throws Exception { - return invoker.invoke(m, paramArray); + super(inv); } } http://git-wip-us.apache.org/repos/asf/cxf/blob/b4536602/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/spi/ProviderImpl.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/spi/ProviderImpl.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/spi/ProviderImpl.java index 606659c..ab29c96 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/spi/ProviderImpl.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/spi/ProviderImpl.java @@ -19,58 +19,10 @@ package org.apache.cxf.jaxws22.spi; -import java.util.Arrays; - -import javax.xml.ws.Endpoint; -import javax.xml.ws.WebServiceException; -import javax.xml.ws.WebServiceFeature; -import javax.xml.ws.spi.Invoker; - -import org.apache.cxf.Bus; -import org.apache.cxf.BusFactory; -import org.apache.cxf.common.i18n.Message; -import org.apache.cxf.jaxws.EndpointUtils; -import org.apache.cxf.jaxws.JaxWsServerFactoryBean; -import org.apache.cxf.jaxws.context.WebServiceContextImpl; -import org.apache.cxf.jaxws22.EndpointImpl; -import org.apache.cxf.jaxws22.JAXWS22Invoker; - +/** + * @deprecated - functionality moved into parent class + */ +@Deprecated public class ProviderImpl extends org.apache.cxf.jaxws.spi.ProviderImpl { - @Override - protected org.apache.cxf.jaxws.EndpointImpl createEndpointImpl(Bus bus, - String bindingId, - Object implementor, - WebServiceFeature ... features) { - if (isJaxWs22()) { - return new EndpointImpl(bus, implementor, bindingId, features); - } - //couldn't find the 2.2 stuff, assume 2.1 behavior - return super.createEndpointImpl(bus, bindingId, implementor, features); - } - - //new in 2.2, but introduces a new class not found in 2.1 - public Endpoint createEndpoint(String bindingId, Class implementorClass, - Invoker invoker, WebServiceFeature ... features) { - if (EndpointUtils.isValidImplementor(implementorClass)) { - Bus bus = BusFactory.getThreadDefaultBus(); - JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); - if (features != null) { - factory.getJaxWsServiceFactory().setWsFeatures(Arrays.asList(features)); - } - if (invoker != null) { - factory.setInvoker(new JAXWS22Invoker(invoker)); - try { - invoker.inject(new WebServiceContextImpl()); - } catch (Exception e) { - throw new WebServiceException(new Message("ENDPOINT_CREATION_FAILED_MSG", - LOG).toString(), e); - } - } - EndpointImpl ep = new EndpointImpl(bus, null, factory); - ep.setImplementorClass(implementorClass); - return ep; - } else { - throw new WebServiceException(new Message("INVALID_IMPLEMENTOR_EXC", LOG).toString()); - } - } + } http://git-wip-us.apache.org/repos/asf/cxf/blob/b4536602/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/spring/JAXWS22SpringEndpointImpl.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/spring/JAXWS22SpringEndpointImpl.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/spring/JAXWS22SpringEndpointImpl.java deleted file mode 100644 index 7b2f7e8..0000000 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws22/spring/JAXWS22SpringEndpointImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cxf.jaxws22.spring; - -import org.apache.cxf.Bus; -import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor; -import org.apache.cxf.common.injection.NoJSR250Annotations; -import org.apache.cxf.jaxws.spring.EndpointDefinitionParser; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -@NoJSR250Annotations -public class JAXWS22SpringEndpointImpl extends org.apache.cxf.jaxws22.EndpointImpl - implements ApplicationContextAware { - - boolean checkBlockConstruct; - - public JAXWS22SpringEndpointImpl(Object o) { - super(o instanceof Bus ? (Bus)o : null, - o instanceof Bus ? null : o); - } - - public JAXWS22SpringEndpointImpl(Bus bus, Object implementor) { - super(bus, implementor); - } - - public void setCheckBlockConstruct(Boolean b) { - checkBlockConstruct = b; - } - - public void setApplicationContext(ApplicationContext ctx) throws BeansException { - if (checkBlockConstruct) { - EndpointDefinitionParser.setBlocking(ctx, this); - } - if (getBus() == null) { - setBus(BusWiringBeanFactoryPostProcessor.addDefaultBus(ctx)); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/b4536602/rt/frontend/jaxws/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxws/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider b/rt/frontend/jaxws/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider index b328b64..b5657df 100644 --- a/rt/frontend/jaxws/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider +++ b/rt/frontend/jaxws/src/main/resources/META-INF/services/javax.xml.ws.spi.Provider @@ -1 +1 @@ -org.apache.cxf.jaxws22.spi.ProviderImpl +org.apache.cxf.jaxws.spi.ProviderImpl