Updated Branches: refs/heads/master 6f7450080 -> 0b2c650fd
Updates to get everything building and testing with both 2.7.8 and 3.0.0-SNAPSHOT Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fc8604cb Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fc8604cb Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fc8604cb Branch: refs/heads/master Commit: fc8604cb32f4e228da47d3aebe877ff82af29a2d Parents: aaee670 Author: Daniel Kulp <[email protected]> Authored: Fri Jan 3 21:18:50 2014 -0500 Committer: Daniel Kulp <[email protected]> Committed: Mon Jan 6 10:14:15 2014 -0500 ---------------------------------------------------------------------- components/camel-cxf/pom.xml | 5 + .../apache/camel/component/cxf/CxfConsumer.java | 16 ++- .../apache/camel/component/cxf/CxfEndpoint.java | 83 ++++++++++----- .../camel/component/cxf/CxfSpringEndpoint.java | 9 +- .../camel/component/cxf/DefaultCxfBinding.java | 36 ++++++- .../component/cxf/WSDLServiceConfiguration.java | 106 ------------------- .../component/cxf/WSDLServiceFactoryBean.java | 82 ++++++++++++-- .../component/cxf/cxfbean/CxfBeanEndpoint.java | 4 +- .../cxf/wsrm/MessageLossSimulator.java | 21 ++-- .../wssecurity/client/UTPasswordCallback.java | 18 ++-- .../wssecurity/server/UTPasswordCallback.java | 17 +-- .../cxf/spring/SpringBusFactoryBeans.xml | 4 +- 12 files changed, 229 insertions(+), 172 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-cxf/pom.xml b/components/camel-cxf/pom.xml index a05a5b9..96d68b2 100644 --- a/components/camel-cxf/pom.xml +++ b/components/camel-cxf/pom.xml @@ -105,6 +105,11 @@ <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf-version}</version> </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-rs-security-oauth</artifactId> + <version>${cxf-version}</version> + </dependency> <dependency> <groupId>org.springframework</groupId> http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java index 478a8d1..cd68921 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java @@ -21,7 +21,9 @@ import java.util.HashMap; import java.util.Map; import javax.xml.ws.WebFault; + import org.w3c.dom.Element; + import org.apache.camel.AsyncCallback; import org.apache.camel.ExchangePattern; import org.apache.camel.Processor; @@ -38,8 +40,8 @@ import org.apache.cxf.message.FaultMode; import org.apache.cxf.message.Message; import org.apache.cxf.service.invoker.Invoker; import org.apache.cxf.service.model.BindingOperationInfo; -import org.apache.cxf.ws.addressing.AddressingProperties; import org.apache.cxf.ws.addressing.ContextUtils; +import org.apache.cxf.ws.addressing.EndpointReferenceType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -273,12 +275,18 @@ public class CxfConsumer extends DefaultConsumer { server.stop(); super.doStop(); } - + private EndpointReferenceType getReplyTo(Object o) { + try { + return (EndpointReferenceType)o.getClass().getMethod("getReplyTo").invoke(o); + } catch (Throwable t) { + throw new Fault(t); + } + } protected boolean isAsyncInvocationSupported(Exchange cxfExchange) { Message cxfMessage = cxfExchange.getInMessage(); - AddressingProperties addressingProperties = (AddressingProperties) cxfMessage.get(CxfConstants.WSA_HEADERS_INBOUND); + Object addressingProperties = cxfMessage.get(CxfConstants.WSA_HEADERS_INBOUND); if (addressingProperties != null - && !ContextUtils.isGenericAddress(addressingProperties.getReplyTo())) { + && !ContextUtils.isGenericAddress(getReplyTo(addressingProperties))) { //it's decoupled endpoint, so already switch thread and //use executors, which means underlying transport won't //be block, so we shouldn't rely on continuation in http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java index c46352b..4a07943 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java @@ -16,7 +16,9 @@ */ package org.apache.camel.component.cxf; +import java.lang.reflect.Method; import java.lang.reflect.Proxy; +import java.security.Provider; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -59,7 +61,6 @@ import org.apache.camel.spi.HeaderFilterStrategyAware; import org.apache.camel.util.EndpointHelper; import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.UnsafeUriCharactersEncoder; - import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.apache.cxf.binding.BindingConfiguration; @@ -67,6 +68,7 @@ import org.apache.cxf.common.classloader.ClassLoaderUtils; import org.apache.cxf.common.injection.ResourceInjector; import org.apache.cxf.common.util.ClassHelper; import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList; +import org.apache.cxf.common.util.ReflectionUtil; import org.apache.cxf.databinding.DataBinding; import org.apache.cxf.databinding.source.SourceDataBinding; import org.apache.cxf.endpoint.Client; @@ -91,8 +93,6 @@ import org.apache.cxf.message.MessageContentsList; import org.apache.cxf.resource.DefaultResourceManager; import org.apache.cxf.resource.ResourceManager; import org.apache.cxf.resource.ResourceResolver; -import org.apache.cxf.service.factory.FactoryBeanListener; -import org.apache.cxf.service.factory.ReflectionServiceFactoryBean; import org.apache.cxf.service.model.BindingOperationInfo; import org.apache.cxf.service.model.MessagePartInfo; import org.apache.cxf.staxutils.StaxSource; @@ -155,7 +155,7 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy private BindingConfiguration bindingConfig; private DataBinding dataBinding; - private ReflectionServiceFactoryBean serviceFactoryBean; + private Object serviceFactoryBean; private CxfEndpointConfigurer configurer; @@ -238,7 +238,7 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy } if (serviceFactoryBean != null) { - sfb.setServiceFactory(serviceFactoryBean); + setServiceFactory(sfb, serviceFactoryBean); } if (sfb instanceof JaxWsServerFactoryBean && handlers != null) { @@ -297,7 +297,7 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy // set the document-literal wrapped style if (getWrappedStyle() != null && getDataFormat().dealias() != DataFormat.CXF_MESSAGE) { - sfb.getServiceFactory().setWrapped(getWrappedStyle()); + setWrapped(sfb, getWrappedStyle()); } // any optional properties @@ -340,18 +340,14 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy return new JaxWsClientFactoryBean() { @Override protected Client createClient(Endpoint ep) { - Client client = new CamelCxfClientImpl(getBus(), ep); - this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, client, ep); - return client; + return new CamelCxfClientImpl(getBus(), ep); } }; } else { return new ClientFactoryBean() { @Override protected Client createClient(Endpoint ep) { - Client client = new CamelCxfClientImpl(getBus(), ep); - this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, client, ep); - return client; + return new CamelCxfClientImpl(getBus(), ep); } }; } @@ -361,13 +357,10 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy * Create a client factory bean object without serviceClass interface. */ protected ClientFactoryBean createClientFactoryBean() { - return new ClientFactoryBean(new WSDLServiceFactoryBean()) { - + ClientFactoryBean cf = new ClientFactoryBean() { @Override protected Client createClient(Endpoint ep) { - Client client = new CamelCxfClientImpl(getBus(), ep); - this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, client, ep); - return client; + return new CamelCxfClientImpl(getBus(), ep); } @Override @@ -375,13 +368,26 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy // Do nothing here } }; + for (Method m : cf.getClass().getMethods()) { + if ("setServiceFactory".equals(m.getName())) { + try { + ReflectionUtil.setAccessible(m).invoke(cf, new WSDLServiceFactoryBean()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + return cf; } - protected void setupHandlers(ClientFactoryBean factoryBean, Client client) { + protected void setupHandlers(ClientFactoryBean factoryBean, Client client) + throws Exception { if (factoryBean instanceof JaxWsClientFactoryBean && handlers != null) { - AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder(); - JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean)factoryBean.getServiceFactory(); + AnnotationHandlerChainBuilder + builder = new AnnotationHandlerChainBuilder(); + Method m = factoryBean.getClass().getMethod("getServiceFactory"); + JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean)m.invoke(factoryBean); @SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<Handler>(handlers); @@ -432,7 +438,7 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy } if (serviceFactoryBean != null) { - factoryBean.setServiceFactory(serviceFactoryBean); + setServiceFactory(factoryBean, serviceFactoryBean); } // address @@ -477,7 +483,7 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy // set the document-literal wrapped style if (getWrappedStyle() != null) { - factoryBean.getServiceFactory().setWrapped(getWrappedStyle()); + setWrapped(factoryBean, getWrappedStyle()); } // any optional properties @@ -514,6 +520,28 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy // Package private methods // ------------------------------------------------------------------------- + private void setWrapped(Object factoryBean, boolean wrapped) { + try { + Object sf = factoryBean.getClass().getMethod("getServiceFactory").invoke(factoryBean); + sf.getClass().getMethod("setWrapped", Boolean.TYPE).invoke(sf, wrapped); + } catch (Throwable t) { + throw new RuntimeException(t); + } + } + + private void setServiceFactory(Object factoryBean, Object serviceFactoryBean2) { + for (Method m : factoryBean.getClass().getMethods()) { + if ("setServiceFactory".equals(m.getName()) + && m.getParameterTypes()[0].isInstance(serviceFactoryBean2)) { + try { + ReflectionUtil.setAccessible(m).invoke(factoryBean, serviceFactoryBean2); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + } + /** * Create a CXF client object */ @@ -593,7 +621,12 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy if (cls == null) { checkName(portName, " endpoint/port name"); checkName(serviceName, " service name"); - answer = new ServerFactoryBean(new WSDLServiceFactoryBean()); + answer = new JaxWsServerFactoryBean(new WSDLServiceFactoryBean()) { + { + doInit = false; + } + }; + cls = Provider.class; } else if (CxfEndpointUtils.hasWebServiceAnnotation(cls)) { answer = new JaxWsServerFactoryBean(); } else { @@ -1105,11 +1138,11 @@ public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategy this.dataBinding = dataBinding; } - public ReflectionServiceFactoryBean getServiceFactoryBean() { + public Object getServiceFactoryBean() { return serviceFactoryBean; } - public void setServiceFactoryBean(ReflectionServiceFactoryBean serviceFactoryBean) { + public void setServiceFactoryBean(Object serviceFactoryBean) { this.serviceFactoryBean = serviceFactoryBean; } http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java index 01d1a55..39558b1 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.cxf; +import java.security.Provider; + import javax.xml.namespace.QName; import org.apache.camel.component.cxf.common.message.CxfConstants; @@ -172,7 +174,12 @@ public class CxfSpringEndpoint extends CxfEndpoint implements ApplicationContext if (cls == null) { if (!getDataFormat().equals(DataFormat.POJO)) { - answer = new ServerFactoryBean(new WSDLServiceFactoryBean()); + answer = new JaxWsServerFactoryBean(new WSDLServiceFactoryBean()) { + { + doInit = false; + } + }; + cls = Provider.class; } else { ObjectHelper.notNull(cls, CxfConstants.SERVICE_CLASS); } http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java index 2657508..f0dcc6d 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java @@ -18,6 +18,7 @@ package org.apache.camel.component.cxf; import java.io.InputStream; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.HashMap; @@ -53,7 +54,6 @@ import org.apache.cxf.binding.soap.Soap11; import org.apache.cxf.binding.soap.Soap12; import org.apache.cxf.binding.soap.SoapBindingConstants; import org.apache.cxf.binding.soap.SoapHeader; -import org.apache.cxf.common.util.ReflectionUtil; import org.apache.cxf.endpoint.Client; import org.apache.cxf.endpoint.Endpoint; import org.apache.cxf.headers.Header; @@ -869,7 +869,7 @@ public class DefaultCxfBinding implements CxfBinding, HeaderFilterStrategyAware Object httpresp = cxfExchange.getInMessage().get("HTTP.RESPONSE"); if (httpresp != null) { try { - Method m = ReflectionUtil.findMethod(httpresp.getClass(), "setStatus", int.class); + Method m = findMethod(httpresp.getClass(), "setStatus", int.class); if (m != null) { m.invoke(httpresp, 202); } @@ -878,4 +878,36 @@ public class DefaultCxfBinding implements CxfBinding, HeaderFilterStrategyAware } } } + public static Method findMethod(Class<?> cls, + String name, + Class<?> ... params) { + if (cls == null) { + return null; + } + for (Class<?> cs : cls.getInterfaces()) { + if (Modifier.isPublic(cs.getModifiers())) { + Method m = findMethod(cs, name, params); + if (m != null && Modifier.isPublic(m.getModifiers())) { + return m; + } + } + } + try { + Method m = cls.getDeclaredMethod(name, params); + if (m != null && Modifier.isPublic(m.getModifiers())) { + return m; + } + } catch (Exception e) { + //ignore + } + Method m = findMethod(cls.getSuperclass(), name, params); + if (m == null) { + try { + m = cls.getMethod(name, params); + } catch (Exception e) { + //ignore + } + } + return m; + } } http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceConfiguration.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceConfiguration.java deleted file mode 100644 index c928a51..0000000 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceConfiguration.java +++ /dev/null @@ -1,106 +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.camel.component.cxf; - -import java.util.Map; - -import javax.wsdl.Definition; -import javax.wsdl.Service; -import javax.xml.namespace.QName; - -import org.apache.camel.RuntimeCamelException; -import org.apache.cxf.helpers.CastUtils; -import org.apache.cxf.service.factory.AbstractServiceConfiguration; -import org.apache.cxf.wsdl.WSDLManager; - -/** - * This class will help the WSDLServiceFactoryBean to look up the ServiceName and PortName from WSDL - */ -public class WSDLServiceConfiguration extends AbstractServiceConfiguration { - - private WSDLServiceFactoryBean serviceFactoryBean; - private Definition definition; - private QName serviceQName; - private QName endpointQName; - - public WSDLServiceConfiguration(WSDLServiceFactoryBean factoryBean) { - this.serviceFactoryBean = factoryBean; - } - - protected Definition getDefinition() { - if (definition == null) { - try { - definition = serviceFactoryBean.getBus().getExtension(WSDLManager.class).getDefinition(serviceFactoryBean.getWsdlURL()); - } catch (Exception ex) { - throw new RuntimeCamelException(ex); - } - } - return definition; - } - - protected QName getServiceQName() { - if (serviceQName == null) { - Map<QName, ?> services = CastUtils.cast(getDefinition().getServices()); - if (services.size() == 0) { - throw new IllegalArgumentException("There is no service in the WSDL" + serviceFactoryBean.getWsdlURL()); - } - if (services.size() > 1) { - throw new IllegalArgumentException("service name must be specified, there is more than one service in the WSDL" + serviceFactoryBean.getWsdlURL()); - } - serviceQName = services.keySet().iterator().next(); - } - return serviceQName; - } - - protected QName getEndpointQName() { - if (endpointQName == null) { - Service service = getDefinition().getService(serviceFactoryBean.getServiceQName()); - if (service == null) { - throw new IllegalArgumentException("There is no service " + serviceFactoryBean.getServiceQName() - + " in WSDL " + serviceFactoryBean.getWsdlURL()); - } - Map<String, ?> ports = CastUtils.cast(service.getPorts()); - if (ports.size() == 0) { - throw new IllegalArgumentException("There is no port/endpoint in the service " - + serviceFactoryBean.getServiceQName() + "of WSDL" - + serviceFactoryBean.getWsdlURL()); - } - if (ports.size() > 1) { - throw new IllegalArgumentException("Port/endpoint name must be specified, There is more than one port in the service" - + serviceFactoryBean.getServiceQName() - + " of the WSDL" + serviceFactoryBean.getWsdlURL()); - } - endpointQName = new QName(service.getQName().getNamespaceURI(), ports.keySet().iterator().next()); - - } - return endpointQName; - } - - public String getServiceName() { - return getServiceQName().getLocalPart(); - } - - public String getServiceNamespace() { - return getServiceQName().getNamespaceURI(); - } - - public QName getEndpointName() { - return getEndpointQName(); - } - - -} http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceFactoryBean.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceFactoryBean.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceFactoryBean.java index 45e9e20..f7a9ef2 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceFactoryBean.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/WSDLServiceFactoryBean.java @@ -16,12 +16,23 @@ */ package org.apache.camel.component.cxf; -import java.util.ArrayList; -import java.util.List; +import java.util.Map; -import org.apache.cxf.service.factory.AbstractServiceConfiguration; -import org.apache.cxf.service.factory.ReflectionServiceFactoryBean; +import javax.wsdl.Definition; +import javax.wsdl.Service; +import javax.xml.namespace.QName; +import javax.xml.ws.Provider; + +import org.apache.camel.RuntimeCamelException; +import org.apache.cxf.endpoint.Endpoint; +import org.apache.cxf.endpoint.EndpointException; +import org.apache.cxf.endpoint.EndpointImpl; +import org.apache.cxf.helpers.CastUtils; +import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean; +import org.apache.cxf.service.factory.FactoryBeanListener.Event; import org.apache.cxf.service.invoker.Invoker; +import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.wsdl.WSDLManager; /** * A service factory bean class that create a service factory without requiring a service class @@ -30,14 +41,65 @@ import org.apache.cxf.service.invoker.Invoker; * there is service name or port/endpoint name setted. * @version */ -public class WSDLServiceFactoryBean extends ReflectionServiceFactoryBean { +public class WSDLServiceFactoryBean extends JaxWsServiceFactoryBean { + private Definition definition; + public WSDLServiceFactoryBean() { - // set up the service configure to help us find the service name and endpoint name from WSDL - WSDLServiceConfiguration configuration = new WSDLServiceConfiguration(this); - List<AbstractServiceConfiguration> list = new ArrayList<AbstractServiceConfiguration>(); - list.add(configuration); - this.setServiceConfigurations(list); + setServiceClass(Provider.class); + } + public void setServiceClass(Class<?> serviceClass) { + if (serviceClass != null) { + super.setServiceClass(serviceClass); + } + } + protected Definition getDefinition(String url) { + if (definition == null) { + try { + definition = getBus().getExtension(WSDLManager.class).getDefinition(url); + } catch (Exception ex) { + throw new RuntimeCamelException(ex); + } + } + + if (this.getServiceQName(false) == null) { + Map<QName, ?> services = CastUtils.cast(definition.getServices()); + if (services.size() == 0) { + throw new IllegalArgumentException("There is no service in the WSDL" + url); + } + if (services.size() > 1) { + throw new IllegalArgumentException("service name must be specified, there is more than one service in the WSDL" + url); + } + QName serviceQName = services.keySet().iterator().next(); + this.setServiceName(serviceQName); + } + + if (this.getEndpointName(false) == null) { + Service service = definition.getService(getServiceQName(false)); + Map<String, ?> ports = CastUtils.cast(service.getPorts()); + if (ports.size() == 0) { + throw new IllegalArgumentException("There is no port/endpoint in the service " + + getServiceQName() + "of WSDL" + + url); + } + if (ports.size() > 1) { + throw new IllegalArgumentException("Port/endpoint name must be specified, There is more than one port in the service" + + service.getQName() + + " of the WSDL" + url); + } + QName endpointQName = new QName(service.getQName().getNamespaceURI(), ports.keySet().iterator().next()); + setEndpointName(endpointQName); + } + return definition; + } + protected void buildServiceFromWSDL(String url) { + getDefinition(url); + super.buildServiceFromWSDL(url); + } + public Endpoint createEndpoint(EndpointInfo ei) throws EndpointException { + Endpoint ep = new EndpointImpl(getBus(), getService(), ei); + sendEvent(Event.ENDPOINT_CREATED, ei, ep, getServiceClass()); + return ep; } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/CxfBeanEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/CxfBeanEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/CxfBeanEndpoint.java index d2e6ad9..b4af010 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/CxfBeanEndpoint.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/CxfBeanEndpoint.java @@ -115,8 +115,8 @@ public class CxfBeanEndpoint extends ProcessorEndpoint implements HeaderFilterSt bean.setServiceClass(serviceBeans.get(0).getClass()); // set the bean instance as well, otherwise CXF will re-create a new instance of the class bean.setServiceBean(serviceBeans.get(0)); - if (bean.getServiceFactory() != null) { - bean.getServiceFactory().setPopulateFromClass(isPopulateFromClass()); + if (bean.getJaxWsServiceFactory() != null) { + bean.getJaxWsServiceFactory().setPopulateFromClass(isPopulateFromClass()); } bean.setBus(bus); bean.setStart(true); http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsrm/MessageLossSimulator.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsrm/MessageLossSimulator.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsrm/MessageLossSimulator.java index 751f310..76ded1b 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsrm/MessageLossSimulator.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsrm/MessageLossSimulator.java @@ -30,7 +30,6 @@ import org.apache.cxf.message.Message; import org.apache.cxf.phase.AbstractPhaseInterceptor; import org.apache.cxf.phase.Phase; import org.apache.cxf.phase.PhaseInterceptor; -import org.apache.cxf.ws.addressing.AddressingProperties; import org.apache.cxf.ws.rm.RMContextUtils; import org.slf4j.Logger; @@ -46,15 +45,23 @@ public class MessageLossSimulator extends AbstractPhaseInterceptor<Message> { addBefore(MessageSenderInterceptor.class.getName()); } - + private static String getAction(Object map) { + if (map == null) { + return null; + } + try { + Object o = map.getClass().getMethod("getAction").invoke(map); + return (String)o.getClass().getMethod("getValue").invoke(o); + } catch (Throwable t) { + throw new Fault(t); + } + } public void handleMessage(Message message) throws Fault { - AddressingProperties maps = + Object maps = RMContextUtils.retrieveMAPs(message, false, true); // RMContextUtils.ensureExposedVersion(maps); - String action = null; - if (maps != null && null != maps.getAction()) { - action = maps.getAction().getValue(); - } + String action = getAction(maps); + if (RMContextUtils.isRMProtocolMessage(action)) { return; } http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/client/UTPasswordCallback.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/client/UTPasswordCallback.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/client/UTPasswordCallback.java index ab45026..cf97dde 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/client/UTPasswordCallback.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/client/UTPasswordCallback.java @@ -24,7 +24,6 @@ import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; -import org.apache.ws.security.WSPasswordCallback; /** */ @@ -47,12 +46,17 @@ public class UTPasswordCallback implements CallbackHandler { */ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { - WSPasswordCallback pc = (WSPasswordCallback)callback; - - String pass = passwords.get(pc.getIdentifier()); - if (pass != null) { - pc.setPassword(pass); - return; + try { + String id = (String)callback.getClass().getMethod("getIdentifier").invoke(callback); + String pass = passwords.get(id); + if (pass != null) { + callback.getClass().getMethod("setPassword", String.class).invoke(callback, pass); + return; + } + } catch (Exception ex) { + UnsupportedCallbackException e = new UnsupportedCallbackException(callback); + e.initCause(ex); + throw e; } } } http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/server/UTPasswordCallback.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/server/UTPasswordCallback.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/server/UTPasswordCallback.java index 9fe1a6b..91764d6 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/server/UTPasswordCallback.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wssecurity/server/UTPasswordCallback.java @@ -24,7 +24,6 @@ import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; -import org.apache.ws.security.WSPasswordCallback; /** */ @@ -47,12 +46,18 @@ public class UTPasswordCallback implements CallbackHandler { */ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { - WSPasswordCallback pc = (WSPasswordCallback)callback; + try { + String id = (String)callback.getClass().getMethod("getIdentifier").invoke(callback); - String pass = passwords.get(pc.getIdentifier()); - if (pass != null) { - pc.setPassword(pass); - return; + String pass = passwords.get(id); + if (pass != null) { + callback.getClass().getMethod("setPassword", String.class).invoke(callback, pass); + return; + } + } catch (Exception ex) { + UnsupportedCallbackException e = new UnsupportedCallbackException(callback); + e.initCause(ex); + throw e; } } } http://git-wip-us.apache.org/repos/asf/camel/blob/fc8604cb/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/SpringBusFactoryBeans.xml ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/SpringBusFactoryBeans.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/SpringBusFactoryBeans.xml index 1eaa572..c60bb7f 100644 --- a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/SpringBusFactoryBeans.xml +++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/spring/SpringBusFactoryBeans.xml @@ -24,12 +24,12 @@ "> <bean id="cxfBus" class="org.apache.camel.component.cxf.spring.SpringBusFactoryBean"> - <property name="cfgFiles" value="META-INF/cxf/cxf.xml;META-INF/cxf/cxf-extension-soap.xml" /> + <property name="cfgFiles" value="META-INF/cxf/cxf.xml;META-INF/cxf/cxf.xml" /> <property name="includeDefaultBus" value="false" /> </bean> <bean id="myBus" class="org.apache.camel.component.cxf.spring.SpringBusFactoryBean"> - <property name="cfgFiles" value="META-INF/cxf/cxf-extension-soap.xml" /> + <property name="cfgFiles" value="META-INF/cxf/cxf.xml" /> <property name="includeDefaultBus" value="true" /> </bean>
