This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-13870 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3af0ee29825949ccb315894df22608fd0529054a Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Aug 20 17:27:17 2019 +0200 CAMEL-13870: Fast property configuration of Camel endpoints. Work in progress. --- .../camel-cxf/src/main/docs/cxf-component.adoc | 2 +- .../camel-cxf/src/main/docs/cxfrs-component.adoc | 4 +- ...ntConfigurer.java => ChainedCxfConfigurer.java} | 20 +-- ...fEndpointConfigurer.java => CxfConfigurer.java} | 7 +- .../apache/camel/component/cxf/CxfConsumer.java | 6 +- .../apache/camel/component/cxf/CxfEndpoint.java | 140 ++++++++++----------- .../camel/component/cxf/CxfEndpointUtils.java | 22 ++-- .../apache/camel/component/cxf/CxfProducer.java | 4 +- .../camel/component/cxf/CxfSpringEndpoint.java | 32 ++--- ...rer.java => HostnameVerifierCxfConfigurer.java} | 10 +- ...dpointConfigurer.java => SslCxfConfigurer.java} | 12 +- ...Configurer.java => ChainedCxfRsConfigurer.java} | 20 +-- ...ndpointConfigurer.java => CxfRsConfigurer.java} | 7 +- .../camel/component/cxf/jaxrs/CxfRsEndpoint.java | 60 ++++----- ...r.java => HostnameVerifierCxfRsConfigurer.java} | 10 +- ...ointConfigurer.java => SslCxfRsConfigurer.java} | 12 +- .../spring/CxfEndpointBeanDefinitionParser.java | 4 +- .../camel/component/cxf/CxfEndpointTest.java | 4 +- .../cxf/CxfJavaOnlyCamelContextAwareTest.java | 4 +- .../apache/camel/component/cxf/CxfTimeoutTest.java | 5 +- .../component/cxf/jaxrs/CxfRsConsumerTest.java | 4 +- .../jaxrs/CxfRsProducerEndpointConfigurerTest.java | 4 +- .../component/cxf/spring/CxfEndpointBeanTest.java | 4 +- .../cxf/spring/CxfEndpointBeansRouterTest.java | 4 +- .../component/cxf/util/CxfEndpointUtilsTest.java | 2 +- .../cxf/util/CxfEndpointUtilsWithSpringTest.java | 2 +- .../component/cxf/cxfConduitTimeOutContext.xml | 2 +- .../apache/camel/component/ipfs/IPFSEndpoint.java | 3 +- .../endpoint/dsl/CxfEndpointBuilderFactory.java | 52 ++++---- .../endpoint/dsl/CxfRsEndpointBuilderFactory.java | 76 +++++------ .../camel/support/PropertyBindingSupport.java | 16 +-- .../EndpointPropertyConfigurerSupport.java | 41 ++++++ .../tools/apt/EndpointAnnotationProcessor.java | 24 ++-- .../apt/EndpointPropertyConfigurerGenerator.java | 7 +- .../java/org/apache/camel/spi/UriEndpoint.java | 7 ++ 35 files changed, 313 insertions(+), 320 deletions(-) diff --git a/components/camel-cxf/src/main/docs/cxf-component.adoc b/components/camel-cxf/src/main/docs/cxf-component.adoc index c52becd..a90f54f 100644 --- a/components/camel-cxf/src/main/docs/cxf-component.adoc +++ b/components/camel-cxf/src/main/docs/cxf-component.adoc @@ -142,7 +142,7 @@ with the following path and query parameters: | *bus* (advanced) | To use a custom configured CXF Bus. | | Bus | *continuationTimeout* (advanced) | This option is used to set the CXF continuation timeout which could be used in CxfConsumer by default when the CXF server is using Jetty or Servlet transport. | 30000 | long | *cxfBinding* (advanced) | To use a custom CxfBinding to control the binding between Camel Message and CXF Message. | | CxfBinding -| *cxfEndpointConfigurer* (advanced) | This option could apply the implementation of org.apache.camel.component.cxf.CxfEndpointConfigurer which supports to configure the CXF endpoint in programmatic way. User can configure the CXF server and client by implementing configure\{ServerClient\} method of CxfEndpointConfigurer. | | CxfEndpointConfigurer +| *cxfConfigurer* (advanced) | This option could apply the implementation of org.apache.camel.component.cxf.CxfEndpointConfigurer which supports to configure the CXF endpoint in programmatic way. User can configure the CXF server and client by implementing configure\{ServerClient\} method of CxfEndpointConfigurer. | | CxfConfigurer | *defaultBus* (advanced) | Will set the default bus when CXF endpoint create a bus by itself | false | boolean | *headerFilterStrategy* (advanced) | To use a custom HeaderFilterStrategy to filter header to and from Camel message. | | HeaderFilterStrategy | *mergeProtocolHeaders* (advanced) | Whether to merge protocol headers. If enabled then propagating headers between Camel and CXF becomes more consistent and similar. For more details see CAMEL-6393. | false | boolean diff --git a/components/camel-cxf/src/main/docs/cxfrs-component.adoc b/components/camel-cxf/src/main/docs/cxfrs-component.adoc index a2d8379..fbacacb 100644 --- a/components/camel-cxf/src/main/docs/cxfrs-component.adoc +++ b/components/camel-cxf/src/main/docs/cxfrs-component.adoc @@ -103,7 +103,7 @@ with the following path and query parameters: | *publishedEndpointUrl* (consumer) | This option can override the endpointUrl that published from the WADL which can be accessed with resource address url plus _wadl | | String | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern -| *serviceBeans* (consumer) | The service beans which you want to export as REST service. Multiple beans can be separated by comma. | | List +| *serviceBeans* (consumer) | The service beans (the bean ids to lookup in the registry) which you want to export as REST service. Multiple beans can be separated by comma | | String | *cookieHandler* (producer) | Configure a cookie handler to maintain a HTTP session | | CookieHandler | *hostnameVerifier* (producer) | The hostname verifier to be used. Use the # notation to reference a HostnameVerifier from the registry. | | HostnameVerifier | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] @@ -116,7 +116,7 @@ with the following path and query parameters: | *binding* (advanced) | To use a custom CxfBinding to control the binding between Camel Message and CXF Message. | | CxfRsBinding | *bus* (advanced) | To use a custom configured CXF Bus. | | Bus | *continuationTimeout* (advanced) | This option is used to set the CXF continuation timeout which could be used in CxfConsumer by default when the CXF server is using Jetty or Servlet transport. | 30000 | long -| *cxfRsEndpointConfigurer* (advanced) | This option could apply the implementation of org.apache.camel.component.cxf.jaxrs.CxfRsEndpointConfigurer which supports to configure the CXF endpoint in programmatic way. User can configure the CXF server and client by implementing configure{Server/Client} method of CxfEndpointConfigurer. | | CxfRsEndpoint Configurer +| *cxfRsConfigurer* (advanced) | This option could apply the implementation of org.apache.camel.component.cxf.jaxrs.CxfRsEndpointConfigurer which supports to configure the CXF endpoint in programmatic way. User can configure the CXF server and client by implementing configure{Server/Client} method of CxfEndpointConfigurer. | | CxfRsConfigurer | *defaultBus* (advanced) | Will set the default bus when CXF endpoint create a bus by itself | false | boolean | *headerFilterStrategy* (advanced) | To use a custom HeaderFilterStrategy to filter header to and from Camel message. | | HeaderFilterStrategy | *performInvocation* (advanced) | When the option is true, Camel will perform the invocation of the resource class instance and put the response object into the exchange for further processing. | false | boolean diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ChainedCxfEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ChainedCxfConfigurer.java similarity index 72% rename from components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ChainedCxfEndpointConfigurer.java rename to components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ChainedCxfConfigurer.java index 887c995..05b4a0c 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ChainedCxfEndpointConfigurer.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ChainedCxfConfigurer.java @@ -20,24 +20,24 @@ import org.apache.cxf.endpoint.Client; import org.apache.cxf.endpoint.Server; import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory; -public final class ChainedCxfEndpointConfigurer implements CxfEndpointConfigurer { - private CxfEndpointConfigurer parent; - private CxfEndpointConfigurer child; +public final class ChainedCxfConfigurer implements CxfConfigurer { + private CxfConfigurer parent; + private CxfConfigurer child; - private ChainedCxfEndpointConfigurer() { + private ChainedCxfConfigurer() { } - public static ChainedCxfEndpointConfigurer create(CxfEndpointConfigurer parent, CxfEndpointConfigurer child) { - ChainedCxfEndpointConfigurer result = new ChainedCxfEndpointConfigurer(); + public static ChainedCxfConfigurer create(CxfConfigurer parent, CxfConfigurer child) { + ChainedCxfConfigurer result = new ChainedCxfConfigurer(); result.parent = parent; result.child = child; return result; } - public ChainedCxfEndpointConfigurer addChild(CxfEndpointConfigurer cxfEndpointConfigurer) { - ChainedCxfEndpointConfigurer result = new ChainedCxfEndpointConfigurer(); + public ChainedCxfConfigurer addChild(CxfConfigurer cxfConfigurer) { + ChainedCxfConfigurer result = new ChainedCxfConfigurer(); result.parent = this; - result.child = cxfEndpointConfigurer; + result.child = cxfConfigurer; return result; } @@ -59,7 +59,7 @@ public final class ChainedCxfEndpointConfigurer implements CxfEndpointConfigurer child.configureServer(server); } - public static class NullCxfEndpointConfigurer implements CxfEndpointConfigurer { + public static class NullCxfConfigurer implements CxfConfigurer { @Override public void configure(AbstractWSDLBasedEndpointFactory factoryBean) { diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConfigurer.java similarity index 91% rename from components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointConfigurer.java rename to components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConfigurer.java index dffeb3b..0adaf8c 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointConfigurer.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConfigurer.java @@ -21,13 +21,14 @@ import org.apache.cxf.endpoint.Server; import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory; /** - * A pluggable strategy for configuring the cxfEndpoint by using java code + * A pluggable strategy for configuring the CXF by using java code */ -public interface CxfEndpointConfigurer { +public interface CxfConfigurer { /** * Configure the CXF Server/Client factory bean - * @param factoryBean + * + * @param factoryBean the factory bean */ void configure(AbstractWSDLBasedEndpointFactory factoryBean); 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 ac16000..8b9c22e 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 @@ -70,8 +70,8 @@ public class CxfConsumer extends DefaultConsumer implements Suspendable { svrBean.setInvoker(new CxfConsumerInvoker(cxfEndpoint)); Server server = svrBean.create(); // Apply the server configurer if it is possible - if (cxfEndpoint.getCxfEndpointConfigurer() != null) { - cxfEndpoint.getCxfEndpointConfigurer().configureServer(server); + if (cxfEndpoint.getCxfConfigurer() != null) { + cxfEndpoint.getCxfConfigurer().configureServer(server); } server.getEndpoint().getEndpointInfo().setProperty("serviceClass", cxfEndpoint.getServiceClass()); if (ObjectHelper.isNotEmpty(cxfEndpoint.getPublishedEndpointUrl())) { @@ -288,7 +288,7 @@ public class CxfConsumer extends DefaultConsumer implements Suspendable { camelExchange.setProperty(Message.MTOM_ENABLED, String.valueOf(endpoint.isMtomEnabled())); - if (endpoint.getMergeProtocolHeaders()) { + if (endpoint.isMergeProtocolHeaders()) { camelExchange.setProperty(CxfConstants.CAMEL_CXF_PROTOCOL_HEADERS_MERGED, Boolean.TRUE); } // bind the CXF request into a Camel exchange 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 b37bedf..0f2986a 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 @@ -67,7 +67,6 @@ import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriPath; import org.apache.camel.support.DefaultEndpoint; -import org.apache.camel.support.EndpointHelper; import org.apache.camel.support.PropertyBindingSupport; import org.apache.camel.support.SynchronousDelegateProducer; import org.apache.camel.support.jsse.SSLContextParameters; @@ -148,12 +147,12 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade private String wsdlURL; @UriParam(label = "service") private Class<?> serviceClass; - @UriParam(label = "service", name = "portName") - private String portNameString; - private QName portName; - @UriParam(label = "service", name = "serviceName") - private String serviceNameString; - private QName serviceName; + @UriParam(label = "service") + private String portName; + private transient QName portNameQName; + @UriParam(label = "service") + private String serviceName; + private transient QName serviceNameQName; @UriParam(label = "service") private String bindingId; @UriParam(label = "service") @@ -191,7 +190,7 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade @UriParam(label = "advanced") private boolean mergeProtocolHeaders; @UriParam(label = "advanced") - private CxfEndpointConfigurer cxfEndpointConfigurer; + private CxfConfigurer cxfConfigurer; @UriParam(label = "advanced", defaultValue = "30000") private long continuationTimeout = 30000; @UriParam(label = "security", secret = true) @@ -288,14 +287,14 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade sfb.setWsdlURL(getWsdlURL()); } - // service name qname - if (getServiceName() != null) { - sfb.setServiceName(getServiceName()); + // service name qname + if (getServiceNameAsQName() != null) { + sfb.setServiceName(getServiceNameAsQName()); } // port qname - if (getPortName() != null) { - sfb.setEndpointName(getPortName()); + if (getPortNameAsQName() != null) { + sfb.setEndpointName(getPortNameAsQName()); } // apply feature here @@ -363,7 +362,7 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade sfb.setBus(getBus()); sfb.setStart(false); - getNullSafeCxfEndpointConfigurer().configure(sfb); + getNullSafeCxfConfigurer().configure(sfb); } /** @@ -486,13 +485,13 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade } // service name qname - if (getServiceName() != null) { - factoryBean.setServiceName(getServiceName()); + if (getServiceNameAsQName() != null) { + factoryBean.setServiceName(getServiceNameAsQName()); } // port name qname - if (getPortName() != null) { - factoryBean.setEndpointName(getPortName()); + if (getPortNameAsQName() != null) { + factoryBean.setEndpointName(getPortNameAsQName()); } // apply feature here @@ -561,7 +560,7 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade factoryBean.setBus(getBus()); - getNullSafeCxfEndpointConfigurer().configure(factoryBean); + getNullSafeCxfConfigurer().configure(factoryBean); } // Package private methods @@ -769,39 +768,29 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade /** * The service name this service is implementing, it maps to the wsdl:service@name. */ - public void setServiceNameString(String service) { - serviceNameString = service; - } - - /** - * The service name this service is implementing, it maps to the wsdl:service@name. - */ - public void setServiceName(QName service) { + public void setServiceName(String service) { serviceName = service; } - /** - * The service name this service is implementing, it maps to the wsdl:service@name. - */ - public void setService(String service) { - serviceNameString = service; + public String getServiceName() { + return serviceName; } - public QName getServiceName() { - if (serviceName == null && serviceNameString != null) { - serviceName = QName.valueOf(resolvePropertyPlaceholders(serviceNameString)); + public QName getServiceNameAsQName() { + if (serviceNameQName == null && serviceName != null) { + serviceNameQName = QName.valueOf(resolvePropertyPlaceholders(serviceName)); } //if not specify the service name and if the wsdlUrl is available, //parse the wsdl to see if only one service in it, if so set the only service //from wsdl to avoid ambiguity - if (serviceName == null && getWsdlURL() != null) { + if (serviceNameQName == null && getWsdlURL() != null) { // use wsdl manager to parse wsdl or get cached // definition try { Definition definition = getBus().getExtension(WSDLManager.class) .getDefinition(getWsdlURL()); if (definition.getServices().size() == 1) { - serviceName = (QName) definition.getServices().keySet() + serviceNameQName = (QName) definition.getServices().keySet() .iterator().next(); } @@ -809,46 +798,43 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade throw new RuntimeException(e); } } - return serviceName; + return serviceNameQName; } - public QName getPortName() { - if (portName == null && portNameString != null) { - portName = QName.valueOf(resolvePropertyPlaceholders(portNameString)); - } - return portName; + public void setServiceNameAsQName(QName qName) { + this.serviceNameQName = qName; } - /** - * The endpoint name this service is implementing, it maps to the wsdl:port@name. In the format of ns:PORT_NAME where ns is a namespace prefix valid at this scope. - */ - public void setPortName(QName port) { - portName = port; + public QName getPortNameAsQName() { + if (portNameQName == null && portName != null) { + portNameQName = QName.valueOf(resolvePropertyPlaceholders(portName)); + } + return portNameQName; } - /** - * The endpoint name this service is implementing, it maps to the wsdl:port@name. In the format of ns:PORT_NAME where ns is a namespace prefix valid at this scope. - */ - public void setPortNameString(String portNameString) { - this.portNameString = portNameString; + public void setPortNameAsQName(QName qName) { + this.portNameQName = qName; } - public void setPortName(String portName) { - portNameString = portName; + public String getPortName() { + return portName; } /** - * The port name this service is implementing, it maps to the wsdl:port@name. + * The endpoint name this service is implementing, it maps to the wsdl:port@name. In the format of ns:PORT_NAME where ns is a namespace prefix valid at this scope. */ - public void setEndpointNameString(String port) { - portNameString = port; + public void setPortName(String port) { + portName = port; } - /** - * The port name this service is implementing, it maps to the wsdl:port@name. - */ - public void setEndpointName(QName port) { - portName = port; + public void setEndpointName(String name) { + // this is on purpose as camel-cxf in xml-dsl uses endpoint-name as port-name + portName = name; + } + + public void setEndpointNameAsQName(QName qName) { + // this is on purpose as camel-cxf in xml-dsl uses endpoint-name as port-name + portNameQName = qName; } public String getDefaultOperationName() { @@ -1126,18 +1112,18 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade this.username = username; } - public CxfEndpointConfigurer getChainedCxfEndpointConfigurer() { - return ChainedCxfEndpointConfigurer - .create(getNullSafeCxfEndpointConfigurer(), - SslCxfEndpointConfigurer.create(sslContextParameters, getCamelContext())) - .addChild(HostnameVerifierCxfEndpointConfigurer.create(hostnameVerifier)); + public CxfConfigurer getChainedCxfConfigurer() { + return ChainedCxfConfigurer + .create(getNullSafeCxfConfigurer(), + SslCxfConfigurer.create(sslContextParameters, getCamelContext())) + .addChild(HostnameVerifierCxfConfigurer.create(hostnameVerifier)); } - private CxfEndpointConfigurer getNullSafeCxfEndpointConfigurer() { - if (cxfEndpointConfigurer == null) { - return new ChainedCxfEndpointConfigurer.NullCxfEndpointConfigurer(); + private CxfConfigurer getNullSafeCxfConfigurer() { + if (cxfConfigurer == null) { + return new ChainedCxfConfigurer.NullCxfConfigurer(); } else { - return cxfEndpointConfigurer; + return cxfConfigurer; } } @@ -1356,7 +1342,7 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade this.skipFaultLogging = skipFaultLogging; } - public Boolean getMergeProtocolHeaders() { + public boolean isMergeProtocolHeaders() { return mergeProtocolHeaders; } @@ -1392,16 +1378,16 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade this.serviceFactoryBean = serviceFactoryBean; } - public CxfEndpointConfigurer getCxfEndpointConfigurer() { - return cxfEndpointConfigurer; + public CxfConfigurer getCxfConfigurer() { + return cxfConfigurer; } /** * This option could apply the implementation of org.apache.camel.component.cxf.CxfEndpointConfigurer which supports to configure the CXF endpoint * in programmatic way. User can configure the CXF server and client by implementing configure{Server|Client} method of CxfEndpointConfigurer. */ - public void setCxfEndpointConfigurer(CxfEndpointConfigurer configurer) { - this.cxfEndpointConfigurer = configurer; + public void setCxfConfigurer(CxfConfigurer configurer) { + this.cxfConfigurer = configurer; } public long getContinuationTimeout() { diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointUtils.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointUtils.java index 0e5efd5..14246ef 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointUtils.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointUtils.java @@ -56,32 +56,28 @@ public final class CxfEndpointUtils { // only used by test currently public static QName getPortName(final CxfEndpoint endpoint) { - if (endpoint.getPortName() != null) { - return endpoint.getPortName(); - } else { + QName answer = endpoint.getPortNameAsQName(); + if (answer == null) { String portLocalName = getCxfEndpointPropertyValue((CxfSpringEndpoint)endpoint, CxfConstants.PORT_LOCALNAME); String portNamespace = getCxfEndpointPropertyValue((CxfSpringEndpoint)endpoint, CxfConstants.PORT_NAMESPACE); if (portLocalName != null) { - return new QName(portNamespace, portLocalName); - } else { - return null; - } + answer = new QName(portNamespace, portLocalName); + } } + return answer; } // only used by test currently public static QName getServiceName(final CxfEndpoint endpoint) { - if (endpoint.getServiceName() != null) { - return endpoint.getServiceName(); - } else { + QName answer = endpoint.getServiceNameAsQName(); + if (answer == null) { String serviceLocalName = getCxfEndpointPropertyValue((CxfSpringEndpoint)endpoint, CxfConstants.SERVICE_LOCALNAME); String serviceNamespace = getCxfEndpointPropertyValue((CxfSpringEndpoint)endpoint, CxfConstants.SERVICE_NAMESPACE); if (serviceLocalName != null) { - return new QName(serviceNamespace, serviceLocalName); - } else { - return null; + answer = new QName(serviceNamespace, serviceLocalName); } } + return answer; } public static boolean hasWebServiceAnnotation(Class<?> cls) { diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java index 3e0aff8..2c350a8 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java @@ -79,7 +79,7 @@ public class CxfProducer extends DefaultAsyncProducer { } - endpoint.getChainedCxfEndpointConfigurer().configureClient(client); + endpoint.getChainedCxfConfigurer().configureClient(client); } @Override @@ -190,7 +190,7 @@ public class CxfProducer extends DefaultAsyncProducer { camelExchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, dataFormat); log.trace("Set Camel Exchange property: {}={}", DataFormat.class.getName(), dataFormat); - if (endpoint.getMergeProtocolHeaders()) { + if (endpoint.isMergeProtocolHeaders()) { camelExchange.setProperty(CxfConstants.CAMEL_CXF_PROTOCOL_HEADERS_MERGED, Boolean.TRUE); } 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 90890b2..1186787 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 @@ -177,16 +177,16 @@ public class CxfSpringEndpoint extends CxfEndpoint implements ApplicationContext } public void setServiceNamespace(String serviceNamespace) { - QName qn = getServiceName(); + QName qn = getServiceNameAsQName(); if (qn == null) { - setServiceName(new QName(serviceNamespace, "local")); + setServiceNameAsQName(new QName(serviceNamespace, "local")); } else { - setServiceName(new QName(serviceNamespace, qn.getLocalPart())); + setServiceNameAsQName(new QName(serviceNamespace, qn.getLocalPart())); } } public String getServiceNamespace() { - QName qn = getServiceName(); + QName qn = getServiceNameAsQName(); if (qn == null) { return null; } @@ -194,16 +194,16 @@ public class CxfSpringEndpoint extends CxfEndpoint implements ApplicationContext } public void setServiceLocalName(String serviceLocalName) { - QName qn = getServiceName(); + QName qn = getServiceNameAsQName(); if (qn == null) { - setServiceName(new QName("", serviceLocalName)); + setServiceNameAsQName(new QName("", serviceLocalName)); } else { - setServiceName(new QName(qn.getNamespaceURI(), serviceLocalName)); + setServiceNameAsQName(new QName(qn.getNamespaceURI(), serviceLocalName)); } } public String getServiceLocalName() { - QName qn = getServiceName(); + QName qn = getServiceNameAsQName(); if (qn == null) { return null; } @@ -211,7 +211,7 @@ public class CxfSpringEndpoint extends CxfEndpoint implements ApplicationContext } public String getEndpointLocalName() { - QName qn = getPortName(); + QName qn = getPortNameAsQName(); if (qn == null) { return null; } @@ -219,25 +219,25 @@ public class CxfSpringEndpoint extends CxfEndpoint implements ApplicationContext } public void setEndpointLocalName(String endpointLocalName) { - QName qn = getPortName(); + QName qn = getPortNameAsQName(); if (qn == null) { - setPortName(new QName("", endpointLocalName)); + setPortNameAsQName(new QName("", endpointLocalName)); } else { - setPortName(new QName(qn.getNamespaceURI(), endpointLocalName)); + setPortNameAsQName(new QName(qn.getNamespaceURI(), endpointLocalName)); } } public void setEndpointNamespace(String endpointNamespace) { - QName qn = getPortName(); + QName qn = getPortNameAsQName(); if (qn == null) { - setPortName(new QName(endpointNamespace, "local")); + setPortNameAsQName(new QName(endpointNamespace, "local")); } else { - setPortName(new QName(endpointNamespace, qn.getLocalPart())); + setPortNameAsQName(new QName(endpointNamespace, qn.getLocalPart())); } } public String getEndpointNamespace() { - QName qn = getPortName(); + QName qn = getPortNameAsQName(); if (qn == null) { return null; } diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfConfigurer.java similarity index 77% rename from components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java rename to components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfConfigurer.java index 0c60d5e..849776f 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfConfigurer.java @@ -24,17 +24,17 @@ import org.apache.cxf.endpoint.Server; import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory; import org.apache.cxf.transport.http.HTTPConduit; -public final class HostnameVerifierCxfEndpointConfigurer extends AbstractHostnameVerifierEndpointConfigurer implements CxfEndpointConfigurer { +public final class HostnameVerifierCxfConfigurer extends AbstractHostnameVerifierEndpointConfigurer implements CxfConfigurer { - private HostnameVerifierCxfEndpointConfigurer(HostnameVerifier hostnameVerifier) { + private HostnameVerifierCxfConfigurer(HostnameVerifier hostnameVerifier) { super(hostnameVerifier); } - public static CxfEndpointConfigurer create(HostnameVerifier hostnameVerifier) { + public static CxfConfigurer create(HostnameVerifier hostnameVerifier) { if (hostnameVerifier == null) { - return new ChainedCxfEndpointConfigurer.NullCxfEndpointConfigurer(); + return new ChainedCxfConfigurer.NullCxfConfigurer(); } else { - return new HostnameVerifierCxfEndpointConfigurer(hostnameVerifier); + return new HostnameVerifierCxfConfigurer(hostnameVerifier); } } @Override diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfConfigurer.java similarity index 75% rename from components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java rename to components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfConfigurer.java index e13f787..c4ca41b 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfConfigurer.java @@ -24,18 +24,18 @@ import org.apache.cxf.endpoint.Server; import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory; import org.apache.cxf.transport.http.HTTPConduit; -public final class SslCxfEndpointConfigurer extends AbstractSslEndpointConfigurer implements CxfEndpointConfigurer { +public final class SslCxfConfigurer extends AbstractSslEndpointConfigurer implements CxfConfigurer { - private SslCxfEndpointConfigurer(SSLContextParameters sslContextParameters, - CamelContext camelContext) { + private SslCxfConfigurer(SSLContextParameters sslContextParameters, + CamelContext camelContext) { super(sslContextParameters, camelContext); } - public static CxfEndpointConfigurer create(SSLContextParameters sslContextParameters, CamelContext camelContext) { + public static CxfConfigurer create(SSLContextParameters sslContextParameters, CamelContext camelContext) { if (sslContextParameters == null) { - return new ChainedCxfEndpointConfigurer.NullCxfEndpointConfigurer(); + return new ChainedCxfConfigurer.NullCxfConfigurer(); } else { - return new SslCxfEndpointConfigurer(sslContextParameters, camelContext); + return new SslCxfConfigurer(sslContextParameters, camelContext); } } diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ChainedCxfRsEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ChainedCxfRsConfigurer.java similarity index 71% rename from components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ChainedCxfRsEndpointConfigurer.java rename to components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ChainedCxfRsConfigurer.java index 9ca3954..642b784 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ChainedCxfRsEndpointConfigurer.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ChainedCxfRsConfigurer.java @@ -20,23 +20,23 @@ import org.apache.cxf.endpoint.Server; import org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean; import org.apache.cxf.jaxrs.client.Client; -public final class ChainedCxfRsEndpointConfigurer implements CxfRsEndpointConfigurer { - private CxfRsEndpointConfigurer parent; - private CxfRsEndpointConfigurer child; +public final class ChainedCxfRsConfigurer implements CxfRsConfigurer { + private CxfRsConfigurer parent; + private CxfRsConfigurer child; - private ChainedCxfRsEndpointConfigurer() { + private ChainedCxfRsConfigurer() { } - public static ChainedCxfRsEndpointConfigurer create(CxfRsEndpointConfigurer parent, - CxfRsEndpointConfigurer child) { - ChainedCxfRsEndpointConfigurer result = new ChainedCxfRsEndpointConfigurer(); + public static ChainedCxfRsConfigurer create(CxfRsConfigurer parent, + CxfRsConfigurer child) { + ChainedCxfRsConfigurer result = new ChainedCxfRsConfigurer(); result.parent = parent; result.child = child; return result; } - public ChainedCxfRsEndpointConfigurer addChild(CxfRsEndpointConfigurer cxfEndpointConfigurer) { - ChainedCxfRsEndpointConfigurer result = new ChainedCxfRsEndpointConfigurer(); + public ChainedCxfRsConfigurer addChild(CxfRsConfigurer cxfEndpointConfigurer) { + ChainedCxfRsConfigurer result = new ChainedCxfRsConfigurer(); result.parent = this; result.child = cxfEndpointConfigurer; return result; @@ -60,7 +60,7 @@ public final class ChainedCxfRsEndpointConfigurer implements CxfRsEndpointConfig child.configureServer(server); } - public static class NullCxfRsEndpointConfigurer implements CxfRsEndpointConfigurer { + public static class NullCxfRsConfigurer implements CxfRsConfigurer { @Override public void configure(AbstractJAXRSFactoryBean factoryBean) { diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsConfigurer.java similarity index 90% rename from components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointConfigurer.java rename to components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsConfigurer.java index d2759ef..fe3cf7e 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointConfigurer.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsConfigurer.java @@ -21,13 +21,14 @@ import org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean; import org.apache.cxf.jaxrs.client.Client; /** - * A pluggable strategy for configuring the cxfRsEndpoint by using java code + * A pluggable strategy for configuring the Camel CXF RS by using java code */ -public interface CxfRsEndpointConfigurer { +public interface CxfRsConfigurer { /** * Configure the CXF-RS Server/Client factory bean - * @param factoryBean + * + * @param factoryBean the factory bean */ void configure(AbstractJAXRSFactoryBean factoryBean); diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java index 8fa976e..84f1331 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java @@ -84,7 +84,7 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate @UriParam private List<Class<?>> resourceClasses; @UriParam(label = "consumer,advanced") - private List<Object> serviceBeans; + private String serviceBeans; @UriParam private String modelRef; @UriParam(label = "consumer", defaultValue = "Default") @@ -129,7 +129,7 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate @UriParam(label = "advanced") private boolean propagateContexts; @UriParam(label = "advanced") - private CxfRsEndpointConfigurer cxfRsEndpointConfigurer; + private CxfRsConfigurer cxfRsConfigurer; @UriParam(label = "producer") private CookieHandler cookieHandler; @@ -219,11 +219,11 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate return skipFaultLogging; } - public CxfRsEndpointConfigurer getChainedCxfRsEndpointConfigurer() { - return ChainedCxfRsEndpointConfigurer + public CxfRsConfigurer getChainedCxfRsEndpointConfigurer() { + return ChainedCxfRsConfigurer .create(getNullSafeCxfRsEndpointConfigurer(), - SslCxfRsEndpointConfigurer.create(sslContextParameters, getCamelContext())) - .addChild(HostnameVerifierCxfRsEndpointConfigurer.create(hostnameVerifier)); + SslCxfRsConfigurer.create(sslContextParameters, getCamelContext())) + .addChild(HostnameVerifierCxfRsConfigurer.create(hostnameVerifier)); } /** * This option controls whether the PhaseInterceptorChain skips logging the Fault that it catches. @@ -247,8 +247,9 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate if (getResourceClasses() != null) { sfb.setResourceClasses(getResourceClasses()); } - if (serviceBeans != null && !serviceBeans.isEmpty()) { - sfb.setServiceBeans(serviceBeans); + if (serviceBeans != null) { + List<Object> beans = EndpointHelper.resolveReferenceListParameter(getCamelContext(), serviceBeans, Object.class); + sfb.setServiceBeans(beans); } // setup the resource providers for interfaces @@ -264,11 +265,11 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate getNullSafeCxfRsEndpointConfigurer().configure(sfb); } - protected CxfRsEndpointConfigurer getNullSafeCxfRsEndpointConfigurer() { - if (cxfRsEndpointConfigurer == null) { - return new ChainedCxfRsEndpointConfigurer.NullCxfRsEndpointConfigurer(); + protected CxfRsConfigurer getNullSafeCxfRsEndpointConfigurer() { + if (cxfRsConfigurer == null) { + return new ChainedCxfRsConfigurer.NullCxfRsConfigurer(); } - return cxfRsEndpointConfigurer; + return cxfRsConfigurer; } private void processResourceModel(JAXRSServerFactoryBean sfb) { @@ -436,33 +437,18 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate setResourceClasses(Arrays.asList(classes)); } - public List<?> getServiceBeans() { + public String getServiceBeans() { return serviceBeans; } - public void addServiceBean(Object bean) { - if (serviceBeans == null) { - serviceBeans = new ArrayList<>(); - } - serviceBeans.add(bean); - } - /** - * The service beans which you want to export as REST service. Multiple beans can be separated by comma. + * The service beans (the bean ids to lookup in the registry) which you want to export as REST service. + * Multiple beans can be separated by comma */ - public void setServiceBeans(List<?> beans) { - this.serviceBeans = new ArrayList<Object>(beans); - } - - public void setServiceBeans(Object... beans) { - setServiceBeans(Arrays.asList(beans)); - } - public void setServiceBeans(String beans) { - setServiceBeans(EndpointHelper.resolveReferenceListParameter(getCamelContext(), beans, Object.class)); + this.serviceBeans = beans; } - /** * The service publish address. */ @@ -470,6 +456,10 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate this.address = address; } + public String getModelRef() { + return modelRef; + } + /** * This option is used to specify the model file which is useful for the resource class without annotation. * When using this option, then the service class can be omitted, to emulate document-only endpoints @@ -822,16 +812,16 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate this.hostnameVerifier = hostnameVerifier; } - public CxfRsEndpointConfigurer getCxfRsEndpointConfigurer() { - return cxfRsEndpointConfigurer; + public CxfRsConfigurer getCxfRsConfigurer() { + return cxfRsConfigurer; } /** * This option could apply the implementation of org.apache.camel.component.cxf.jaxrs.CxfRsEndpointConfigurer which supports to configure the CXF endpoint * in programmatic way. User can configure the CXF server and client by implementing configure{Server/Client} method of CxfEndpointConfigurer. */ - public void setCxfRsEndpointConfigurer(CxfRsEndpointConfigurer configurer) { - this.cxfRsEndpointConfigurer = configurer; + public void setCxfRsConfigurer(CxfRsConfigurer configurer) { + this.cxfRsConfigurer = configurer; } public CookieHandler getCookieHandler() { diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/HostnameVerifierCxfRsEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/HostnameVerifierCxfRsConfigurer.java similarity index 77% rename from components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/HostnameVerifierCxfRsEndpointConfigurer.java rename to components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/HostnameVerifierCxfRsConfigurer.java index 84649ec..e6b27e6 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/HostnameVerifierCxfRsEndpointConfigurer.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/HostnameVerifierCxfRsConfigurer.java @@ -25,17 +25,17 @@ import org.apache.cxf.jaxrs.client.Client; import org.apache.cxf.jaxrs.client.WebClient; import org.apache.cxf.transport.http.HTTPConduit; -public final class HostnameVerifierCxfRsEndpointConfigurer extends AbstractHostnameVerifierEndpointConfigurer implements CxfRsEndpointConfigurer { +public final class HostnameVerifierCxfRsConfigurer extends AbstractHostnameVerifierEndpointConfigurer implements CxfRsConfigurer { - private HostnameVerifierCxfRsEndpointConfigurer(HostnameVerifier hostnameVerifier) { + private HostnameVerifierCxfRsConfigurer(HostnameVerifier hostnameVerifier) { super(hostnameVerifier); } - public static CxfRsEndpointConfigurer create(HostnameVerifier hostnameVerifier) { + public static CxfRsConfigurer create(HostnameVerifier hostnameVerifier) { if (hostnameVerifier == null) { - return new ChainedCxfRsEndpointConfigurer.NullCxfRsEndpointConfigurer(); + return new ChainedCxfRsConfigurer.NullCxfRsConfigurer(); } else { - return new HostnameVerifierCxfRsEndpointConfigurer(hostnameVerifier); + return new HostnameVerifierCxfRsConfigurer(hostnameVerifier); } } @Override diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SslCxfRsEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SslCxfRsConfigurer.java similarity index 75% rename from components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SslCxfRsEndpointConfigurer.java rename to components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SslCxfRsConfigurer.java index b3ec4e9..0f11fa6 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SslCxfRsEndpointConfigurer.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SslCxfRsConfigurer.java @@ -25,18 +25,18 @@ import org.apache.cxf.jaxrs.client.Client; import org.apache.cxf.jaxrs.client.WebClient; import org.apache.cxf.transport.http.HTTPConduit; -public final class SslCxfRsEndpointConfigurer extends AbstractSslEndpointConfigurer implements CxfRsEndpointConfigurer { +public final class SslCxfRsConfigurer extends AbstractSslEndpointConfigurer implements CxfRsConfigurer { - private SslCxfRsEndpointConfigurer(SSLContextParameters sslContextParameters, - CamelContext camelContext) { + private SslCxfRsConfigurer(SSLContextParameters sslContextParameters, + CamelContext camelContext) { super(sslContextParameters, camelContext); } - public static CxfRsEndpointConfigurer create(SSLContextParameters sslContextParameters, CamelContext camelContext) { + public static CxfRsConfigurer create(SSLContextParameters sslContextParameters, CamelContext camelContext) { if (sslContextParameters == null) { - return new ChainedCxfRsEndpointConfigurer.NullCxfRsEndpointConfigurer(); + return new ChainedCxfRsConfigurer.NullCxfRsConfigurer(); } else { - return new SslCxfRsEndpointConfigurer(sslContextParameters, camelContext); + return new SslCxfRsConfigurer(sslContextParameters, camelContext); } } diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java index 5dd3d9d..10415fd 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java @@ -61,10 +61,10 @@ public class CxfEndpointBeanDefinitionParser extends AbstractCxfBeanDefinitionPa if ("endpointName".equals(name) || "serviceName".equals(name)) { if (isSpringPlaceHolder(val)) { // set the property with the String value directly - mapToProperty(bean, name + "String", val); + mapToProperty(bean, name, val); } else { QName q = parseQName(e, val); - bean.addPropertyValue(name, q); + bean.addPropertyValue(name + "AsQName", q); } } else { mapToProperty(bean, name, val); diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java index d499155..9826f89 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java @@ -100,12 +100,12 @@ public class CxfEndpointTest extends Assert { @Test public void testCxfEndpointConfigurer() throws Exception { SimpleRegistry registry = new SimpleRegistry(); - CxfEndpointConfigurer configurer = mock(CxfEndpointConfigurer.class); + CxfConfigurer configurer = mock(CxfConfigurer.class); Processor processor = mock(Processor.class); registry.bind("myConfigurer", configurer); CamelContext camelContext = new DefaultCamelContext(registry); CxfComponent cxfComponent = new CxfComponent(camelContext); - CxfEndpoint endpoint = (CxfEndpoint)cxfComponent.createEndpoint(routerEndpointURI + "&cxfEndpointConfigurer=#myConfigurer"); + CxfEndpoint endpoint = (CxfEndpoint)cxfComponent.createEndpoint(routerEndpointURI + "&cxfConfigurer=#myConfigurer"); Consumer consumer = endpoint.createConsumer(processor); consumer.start(); diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfJavaOnlyCamelContextAwareTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfJavaOnlyCamelContextAwareTest.java index b6c248f..57b7d5c 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfJavaOnlyCamelContextAwareTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfJavaOnlyCamelContextAwareTest.java @@ -65,8 +65,8 @@ public class CxfJavaOnlyCamelContextAwareTest extends CamelTestSupport { public void configure() throws Exception { CxfEndpoint endpoint = new CxfEndpoint(); endpoint.setAddress("http://localhost:" + port1 + "/PersonService"); - endpoint.setServiceName(new QName("http://camel.apache.org/wsdl-first", "PersonService")); - endpoint.setPortName(new QName("http://camel.apache.org/wsdl-first", "soap")); + endpoint.setServiceNameAsQName(new QName("http://camel.apache.org/wsdl-first", "PersonService")); + endpoint.setPortNameAsQName(new QName("http://camel.apache.org/wsdl-first", "soap")); endpoint.setWsdlURL("classpath:person.wsdl"); endpoint.setDataFormat(DataFormat.PAYLOAD); context.addEndpoint("personService", endpoint); diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java index 31783b8..9670b36 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java @@ -24,7 +24,6 @@ import javax.xml.ws.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.component.cxf.common.message.CxfConstants; -import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.spring.CamelSpringTestSupport; import org.apache.cxf.endpoint.Client; import org.apache.cxf.endpoint.Server; @@ -72,7 +71,7 @@ public class CxfTimeoutTest extends CamelSpringTestSupport { @Test public void testInvokingJaxWsServerWithCxfEndpointWithConfigurer() throws Exception { - Exchange reply = sendJaxWsMessage("cxf://bean:springEndpoint?cxfEndpointConfigurer=#myConfigurer"); + Exchange reply = sendJaxWsMessage("cxf://bean:springEndpoint?cxfConfigurer=#myConfigurer"); // we don't expect the exception here assertFalse("We don't expect the exception here", reply.isFailed()); assertEquals("Get a wrong response", "Greet Hello World!", reply.getOut().getBody(String.class)); @@ -113,7 +112,7 @@ public class CxfTimeoutTest extends CamelSpringTestSupport { return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml"); } - public static class MyCxfEndpointConfigurer implements CxfEndpointConfigurer { + public static class MyCxfConfigurer implements CxfConfigurer { @Override public void configure(AbstractWSDLBasedEndpointFactory factoryBean) { diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java index a60b9f8..9d876c3 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java @@ -75,11 +75,11 @@ public class CxfRsConsumerTest extends CamelTestSupport { + "modelRef=classpath:/org/apache/camel/component/cxf/jaxrs/CustomerServiceDefaultHandlerModel.xml"; private static final String CXF_RS_ENDPOINT_URI6 = "cxfrs://http://localhost:" + CXT + "/rest6?" - + "performInvocation=true&serviceBeans=#serviceBean"; + + "performInvocation=true&serviceBeans=#myServiceBean"; @Override protected void bindToRegistry(Registry registry) throws Exception { - registry.bind("serviceBean", new CustomerService()); + registry.bind("myServiceBean", new CustomerService()); } @Override diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerEndpointConfigurerTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerEndpointConfigurerTest.java index 511e9be..08ceeb8 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerEndpointConfigurerTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerEndpointConfigurerTest.java @@ -43,7 +43,7 @@ public class CxfRsProducerEndpointConfigurerTest extends CamelTestSupport { endpoint.setCamelContext(context); endpoint.setResourceClasses(CustomerService.class); endpoint.setEndpointUriIfNotSpecified("cxfrs:simple"); - endpoint.setCxfRsEndpointConfigurer(new MyCxfRsEndpointConfigurer()); + endpoint.setCxfRsConfigurer(new MyCxfRsConfigurer()); from("direct:start") .to(endpoint) @@ -87,7 +87,7 @@ public class CxfRsProducerEndpointConfigurerTest extends CamelTestSupport { assertMockEndpointsSatisfied(); } - public static class MyCxfRsEndpointConfigurer implements CxfRsEndpointConfigurer { + public static class MyCxfRsConfigurer implements CxfRsConfigurer { @Override public void configure(AbstractJAXRSFactoryBean factoryBean) { diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java index db00c5a..1b71547 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java @@ -60,8 +60,8 @@ public class CxfEndpointBeanTest extends AbstractSpringBeanTestSupport { assertEquals("Got the wrong continuationTimeout", 60000, routerEndpoint.getContinuationTimeout()); CxfEndpoint myEndpoint = ctx.getBean("myEndpoint", CxfEndpoint.class); - assertEquals("Got the wrong endpointName", endpointName, myEndpoint.getPortName()); - assertEquals("Got the wrong serviceName", serviceName, myEndpoint.getServiceName()); + assertEquals("Got the wrong endpointName", endpointName, myEndpoint.getPortNameAsQName()); + assertEquals("Got the wrong serviceName", serviceName, myEndpoint.getServiceNameAsQName()); assertEquals("loggingFeatureEnabled should be true", true, myEndpoint.isLoggingFeatureEnabled()); assertEquals("loggingSizeLimit should be set", 200, myEndpoint.getLoggingSizeLimit()); assertTrue("We should get a soap binding", myEndpoint.getBindingConfig() instanceof SoapBindingConfiguration); diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeansRouterTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeansRouterTest.java index 4a56804..256e16b 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeansRouterTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeansRouterTest.java @@ -98,9 +98,9 @@ public class CxfEndpointBeansRouterTest extends AbstractSpringBeanTestSupport { assertEquals("Got a wrong address", "http://localhost:9000/testEndpoint", testEndpoint.getAddress()); assertEquals("Got a wrong bindingId", "http://schemas.xmlsoap.org/wsdl/soap12/", testEndpoint.getBindingId()); assertEquals("Got a wrong transportId", "http://cxf.apache.org/transports/http", testEndpoint.getTransportId()); - assertEquals("Got a wrong endpointName", endpointName, testEndpoint.getPortName()); + assertEquals("Got a wrong endpointName", endpointName, testEndpoint.getPortNameAsQName()); assertEquals("Got a wrong WsdlURL", "wsdl/test.wsdl", testEndpoint.getWsdlURL()); - assertEquals("Got a wrong serviceName", serviceName, testEndpoint.getServiceName()); + assertEquals("Got a wrong serviceName", serviceName, testEndpoint.getServiceNameAsQName()); } } diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java index f5a7291..16ab35b 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java @@ -66,7 +66,7 @@ public class CxfEndpointUtilsTest extends Assert { @Test public void testGetProperties() throws Exception { CxfEndpoint endpoint = createEndpoint(getEndpointURI()); - QName service = endpoint.getServiceName(); + QName service = endpoint.getServiceNameAsQName(); assertEquals("We should get the right service name", service, SERVICE_NAME); } diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java index 015f6e3..9294fe2 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java @@ -82,7 +82,7 @@ public class CxfEndpointUtilsWithSpringTest extends CxfEndpointUtilsTest { @Test public void testGetProperties() throws Exception { CxfSpringEndpoint endpoint = (CxfSpringEndpoint)createEndpoint(getEndpointURI()); - QName service = endpoint.getServiceName(); + QName service = endpoint.getServiceNameAsQName(); assertEquals("We should get the right service name", SERVICE_NAME, service); assertEquals("The cxf endpoint's DataFromat should be RAW", DataFormat.RAW, endpoint.getDataFormat().dealias()); diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml index d41ae82..324f65d 100644 --- a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml +++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml @@ -47,7 +47,7 @@ </http-conf:conduit> <!-- setup the CxfEndpointConfigurer bean here --> - <bean id="myConfigurer" class="org.apache.camel.component.cxf.CxfTimeoutTest$MyCxfEndpointConfigurer"/> + <bean id="myConfigurer" class="org.apache.camel.component.cxf.CxfTimeoutTest$MyCxfConfigurer"/> <bean id="defaultHostnameVerifier" class="org.apache.cxf.transport.https.httpclient.DefaultHostnameVerifier"/> diff --git a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java index 1be9dec..e08f02d 100644 --- a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java +++ b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java @@ -46,7 +46,8 @@ import org.slf4j.LoggerFactory; * The camel-ipfs component provides access to the Interplanetary File System * (IPFS). */ -@UriEndpoint(firstVersion = "2.23.0", scheme = "ipfs", title = "IPFS", syntax = "ipfs:ipfsHost:ipfsPort/ipfsCmd", producerOnly = true, label = "file,ipfs") +@UriEndpoint(firstVersion = "2.23.0", scheme = "ipfs", title = "IPFS", + syntax = "ipfs:ipfsHost:ipfsPort/ipfsCmd", producerOnly = true, label = "file,ipfs", generateConfigurer = false) public class IPFSEndpoint extends DefaultEndpoint { public static final long DEFAULT_TIMEOUT = 10000L; diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java index 74367ff..20fb3b3 100644 --- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/CxfEndpointBuilderFactory.java @@ -531,14 +531,13 @@ public interface CxfEndpointBuilderFactory { * method of CxfEndpointConfigurer. * * The option is a: - * <code>org.apache.camel.component.cxf.CxfEndpointConfigurer</code> - * type. + * <code>org.apache.camel.component.cxf.CxfConfigurer</code> type. * * Group: advanced */ - default AdvancedCxfEndpointConsumerBuilder cxfEndpointConfigurer( - Object cxfEndpointConfigurer) { - setProperty("cxfEndpointConfigurer", cxfEndpointConfigurer); + default AdvancedCxfEndpointConsumerBuilder cxfConfigurer( + Object cxfConfigurer) { + setProperty("cxfConfigurer", cxfConfigurer); return this; } /** @@ -549,14 +548,13 @@ public interface CxfEndpointBuilderFactory { * method of CxfEndpointConfigurer. * * The option will be converted to a - * <code>org.apache.camel.component.cxf.CxfEndpointConfigurer</code> - * type. + * <code>org.apache.camel.component.cxf.CxfConfigurer</code> type. * * Group: advanced */ - default AdvancedCxfEndpointConsumerBuilder cxfEndpointConfigurer( - String cxfEndpointConfigurer) { - setProperty("cxfEndpointConfigurer", cxfEndpointConfigurer); + default AdvancedCxfEndpointConsumerBuilder cxfConfigurer( + String cxfConfigurer) { + setProperty("cxfConfigurer", cxfConfigurer); return this; } /** @@ -1316,14 +1314,13 @@ public interface CxfEndpointBuilderFactory { * method of CxfEndpointConfigurer. * * The option is a: - * <code>org.apache.camel.component.cxf.CxfEndpointConfigurer</code> - * type. + * <code>org.apache.camel.component.cxf.CxfConfigurer</code> type. * * Group: advanced */ - default AdvancedCxfEndpointProducerBuilder cxfEndpointConfigurer( - Object cxfEndpointConfigurer) { - setProperty("cxfEndpointConfigurer", cxfEndpointConfigurer); + default AdvancedCxfEndpointProducerBuilder cxfConfigurer( + Object cxfConfigurer) { + setProperty("cxfConfigurer", cxfConfigurer); return this; } /** @@ -1334,14 +1331,13 @@ public interface CxfEndpointBuilderFactory { * method of CxfEndpointConfigurer. * * The option will be converted to a - * <code>org.apache.camel.component.cxf.CxfEndpointConfigurer</code> - * type. + * <code>org.apache.camel.component.cxf.CxfConfigurer</code> type. * * Group: advanced */ - default AdvancedCxfEndpointProducerBuilder cxfEndpointConfigurer( - String cxfEndpointConfigurer) { - setProperty("cxfEndpointConfigurer", cxfEndpointConfigurer); + default AdvancedCxfEndpointProducerBuilder cxfConfigurer( + String cxfConfigurer) { + setProperty("cxfConfigurer", cxfConfigurer); return this; } /** @@ -1928,14 +1924,12 @@ public interface CxfEndpointBuilderFactory { * method of CxfEndpointConfigurer. * * The option is a: - * <code>org.apache.camel.component.cxf.CxfEndpointConfigurer</code> - * type. + * <code>org.apache.camel.component.cxf.CxfConfigurer</code> type. * * Group: advanced */ - default AdvancedCxfEndpointBuilder cxfEndpointConfigurer( - Object cxfEndpointConfigurer) { - setProperty("cxfEndpointConfigurer", cxfEndpointConfigurer); + default AdvancedCxfEndpointBuilder cxfConfigurer(Object cxfConfigurer) { + setProperty("cxfConfigurer", cxfConfigurer); return this; } /** @@ -1946,14 +1940,12 @@ public interface CxfEndpointBuilderFactory { * method of CxfEndpointConfigurer. * * The option will be converted to a - * <code>org.apache.camel.component.cxf.CxfEndpointConfigurer</code> - * type. + * <code>org.apache.camel.component.cxf.CxfConfigurer</code> type. * * Group: advanced */ - default AdvancedCxfEndpointBuilder cxfEndpointConfigurer( - String cxfEndpointConfigurer) { - setProperty("cxfEndpointConfigurer", cxfEndpointConfigurer); + default AdvancedCxfEndpointBuilder cxfConfigurer(String cxfConfigurer) { + setProperty("cxfConfigurer", cxfConfigurer); return this; } /** diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java index 52844df..29deac8 100644 --- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/CxfRsEndpointBuilderFactory.java @@ -415,25 +415,11 @@ public interface CxfRsEndpointBuilderFactory { return this; } /** - * The service beans which you want to export as REST service. Multiple - * beans can be separated by comma. + * The service beans (the bean ids to lookup in the registry) which you + * want to export as REST service. Multiple beans can be separated by + * comma. * - * The option is a: <code>java.util.List<java.lang.Object></code> - * type. - * - * Group: consumer (advanced) - */ - default AdvancedCxfRsEndpointConsumerBuilder serviceBeans( - List<Object> serviceBeans) { - setProperty("serviceBeans", serviceBeans); - return this; - } - /** - * The service beans which you want to export as REST service. Multiple - * beans can be separated by comma. - * - * The option will be converted to a - * <code>java.util.List<java.lang.Object></code> type. + * The option is a: <code>java.lang.String</code> type. * * Group: consumer (advanced) */ @@ -553,13 +539,14 @@ public interface CxfRsEndpointBuilderFactory { * configure{Server/Client} method of CxfEndpointConfigurer. * * The option is a: - * <code>org.apache.camel.component.cxf.jaxrs.CxfRsEndpointConfigurer</code> type. + * <code>org.apache.camel.component.cxf.jaxrs.CxfRsConfigurer</code> + * type. * * Group: advanced */ - default AdvancedCxfRsEndpointConsumerBuilder cxfRsEndpointConfigurer( - Object cxfRsEndpointConfigurer) { - setProperty("cxfRsEndpointConfigurer", cxfRsEndpointConfigurer); + default AdvancedCxfRsEndpointConsumerBuilder cxfRsConfigurer( + Object cxfRsConfigurer) { + setProperty("cxfRsConfigurer", cxfRsConfigurer); return this; } /** @@ -570,13 +557,14 @@ public interface CxfRsEndpointBuilderFactory { * configure{Server/Client} method of CxfEndpointConfigurer. * * The option will be converted to a - * <code>org.apache.camel.component.cxf.jaxrs.CxfRsEndpointConfigurer</code> type. + * <code>org.apache.camel.component.cxf.jaxrs.CxfRsConfigurer</code> + * type. * * Group: advanced */ - default AdvancedCxfRsEndpointConsumerBuilder cxfRsEndpointConfigurer( - String cxfRsEndpointConfigurer) { - setProperty("cxfRsEndpointConfigurer", cxfRsEndpointConfigurer); + default AdvancedCxfRsEndpointConsumerBuilder cxfRsConfigurer( + String cxfRsConfigurer) { + setProperty("cxfRsConfigurer", cxfRsConfigurer); return this; } /** @@ -1276,13 +1264,14 @@ public interface CxfRsEndpointBuilderFactory { * configure{Server/Client} method of CxfEndpointConfigurer. * * The option is a: - * <code>org.apache.camel.component.cxf.jaxrs.CxfRsEndpointConfigurer</code> type. + * <code>org.apache.camel.component.cxf.jaxrs.CxfRsConfigurer</code> + * type. * * Group: advanced */ - default AdvancedCxfRsEndpointProducerBuilder cxfRsEndpointConfigurer( - Object cxfRsEndpointConfigurer) { - setProperty("cxfRsEndpointConfigurer", cxfRsEndpointConfigurer); + default AdvancedCxfRsEndpointProducerBuilder cxfRsConfigurer( + Object cxfRsConfigurer) { + setProperty("cxfRsConfigurer", cxfRsConfigurer); return this; } /** @@ -1293,13 +1282,14 @@ public interface CxfRsEndpointBuilderFactory { * configure{Server/Client} method of CxfEndpointConfigurer. * * The option will be converted to a - * <code>org.apache.camel.component.cxf.jaxrs.CxfRsEndpointConfigurer</code> type. + * <code>org.apache.camel.component.cxf.jaxrs.CxfRsConfigurer</code> + * type. * * Group: advanced */ - default AdvancedCxfRsEndpointProducerBuilder cxfRsEndpointConfigurer( - String cxfRsEndpointConfigurer) { - setProperty("cxfRsEndpointConfigurer", cxfRsEndpointConfigurer); + default AdvancedCxfRsEndpointProducerBuilder cxfRsConfigurer( + String cxfRsConfigurer) { + setProperty("cxfRsConfigurer", cxfRsConfigurer); return this; } /** @@ -1766,13 +1756,14 @@ public interface CxfRsEndpointBuilderFactory { * configure{Server/Client} method of CxfEndpointConfigurer. * * The option is a: - * <code>org.apache.camel.component.cxf.jaxrs.CxfRsEndpointConfigurer</code> type. + * <code>org.apache.camel.component.cxf.jaxrs.CxfRsConfigurer</code> + * type. * * Group: advanced */ - default AdvancedCxfRsEndpointBuilder cxfRsEndpointConfigurer( - Object cxfRsEndpointConfigurer) { - setProperty("cxfRsEndpointConfigurer", cxfRsEndpointConfigurer); + default AdvancedCxfRsEndpointBuilder cxfRsConfigurer( + Object cxfRsConfigurer) { + setProperty("cxfRsConfigurer", cxfRsConfigurer); return this; } /** @@ -1783,13 +1774,14 @@ public interface CxfRsEndpointBuilderFactory { * configure{Server/Client} method of CxfEndpointConfigurer. * * The option will be converted to a - * <code>org.apache.camel.component.cxf.jaxrs.CxfRsEndpointConfigurer</code> type. + * <code>org.apache.camel.component.cxf.jaxrs.CxfRsConfigurer</code> + * type. * * Group: advanced */ - default AdvancedCxfRsEndpointBuilder cxfRsEndpointConfigurer( - String cxfRsEndpointConfigurer) { - setProperty("cxfRsEndpointConfigurer", cxfRsEndpointConfigurer); + default AdvancedCxfRsEndpointBuilder cxfRsConfigurer( + String cxfRsConfigurer) { + setProperty("cxfRsConfigurer", cxfRsConfigurer); return this; } /** diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java index 4a43e24..a7a8c79 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java @@ -466,21 +466,7 @@ public final class PropertyBindingSupport { String key = entry.getKey(); Object value = entry.getValue(); if (writeProperties.containsKey(key)) { - - // support reference parameters - if (value instanceof String) { - String text = (String) value; - if (isReferenceParameter(text)) { - if (text.startsWith("#bean:")) { - text = text.substring(6); - } else { - text = text.substring(1); - } - value = CamelContextHelper.mandatoryLookup(camelContext, text); - } - } - // TODO: that thing with boolean and from string value true|false - + // TODO: that thing with boolean and from string value true|false (should be in EndpointPropertyConfigurerSupport) writeProperties.get(key).accept(value); if (removeParameter) { iter.remove(); diff --git a/core/camel-support/src/main/java/org/apache/camel/support/component/EndpointPropertyConfigurerSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/component/EndpointPropertyConfigurerSupport.java new file mode 100644 index 0000000..e9e9f6e --- /dev/null +++ b/core/camel-support/src/main/java/org/apache/camel/support/component/EndpointPropertyConfigurerSupport.java @@ -0,0 +1,41 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.support.component; + +import org.apache.camel.CamelContext; +import org.apache.camel.spi.EndpointPropertyConfigurer; + +public abstract class EndpointPropertyConfigurerSupport implements EndpointPropertyConfigurer { + + public static <T> T property(CamelContext camelContext, Class<T> type, Object value) { + // if the type is not string based and the value is a bean reference, then we need to lookup + // the bean from the registry + if (value instanceof String && String.class != type) { + // is it a reference parameter + String text = value.toString(); + if (text.startsWith("#")) { + String ref = text.startsWith("#bean:") ? text.substring(6) : text.substring(1); + Object obj = camelContext.getRegistry().lookupByName(ref); + if (obj != null) { + value = obj; + } + } + } + return camelContext.getTypeConverter().convertTo(type, value); + } + +} diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java index ba3c1ff..0e9bccb 100644 --- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java +++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java @@ -173,17 +173,19 @@ public class EndpointAnnotationProcessor extends AbstractCamelAnnotationProcesso String json = createParameterJsonSchema(componentModel, componentOptions, endpointPaths, endpointOptions, schemes, parentData); writer.println(json); - TypeElement parent = findTypeElement(processingEnv, roundEnv, "org.apache.camel.spi.EndpointPropertyConfigurer"); - String fqen = classElement.getQualifiedName().toString(); - String pn = fqen.substring(0, fqen.lastIndexOf('.')); - String en = classElement.getSimpleName().toString(); - String cn = en + "Configurer"; - String fqn = pn + "." + cn; - - // only generate this once for the first scheme - if (schemes == null || schemes[0].equals(scheme)) { - EndpointPropertyConfigurerGenerator.generatePropertyConfigurer(processingEnv, parent, pn, cn, fqn, en, fqen, endpointOptions); - EndpointPropertyConfigurerGenerator.generateMetaInfConfigurer(processingEnv, componentModel.getScheme() + "-endpoint", fqn); + if (uriEndpoint.generateConfigurer()) { + TypeElement parent = findTypeElement(processingEnv, roundEnv, "org.apache.camel.support.component.EndpointPropertyConfigurerSupport"); + String fqen = classElement.getQualifiedName().toString(); + String pn = fqen.substring(0, fqen.lastIndexOf('.')); + String en = classElement.getSimpleName().toString(); + String cn = en + "Configurer"; + String fqn = pn + "." + cn; + + // only generate this once for the first scheme + if (schemes == null || schemes[0].equals(scheme)) { + EndpointPropertyConfigurerGenerator.generatePropertyConfigurer(processingEnv, parent, pn, cn, fqn, en, fqen, endpointOptions); + EndpointPropertyConfigurerGenerator.generateMetaInfConfigurer(processingEnv, componentModel.getScheme() + "-endpoint", fqn); + } } } diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java index 620e5c0..0d969d5 100644 --- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java +++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointPropertyConfigurerGenerator.java @@ -59,12 +59,12 @@ public final class EndpointPropertyConfigurerGenerator { w.write("\n"); w.write("import org.apache.camel.CamelContext;\n"); w.write("import " + fqen + ";\n"); - w.write("import org.apache.camel.spi.EndpointPropertyConfigurer;\n"); + w.write("import org.apache.camel.support.component.EndpointPropertyConfigurerSupport;\n"); w.write("\n"); w.write("/**\n"); w.write(" * Source code generated by org.apache.camel:apt\n"); w.write(" */\n"); - w.write("public class " + cn + " implements EndpointPropertyConfigurer {\n"); + w.write("public class " + cn + " extends EndpointPropertyConfigurerSupport {\n"); w.write("\n"); w.write(" private final Map<String, Supplier<Object>> readPlaceholders = new HashMap<>(" + size + ");\n"); w.write(" private final Map<String, Consumer<Object>> writePlaceholders = new HashMap<>(" + size + ");\n"); @@ -117,9 +117,8 @@ public final class EndpointPropertyConfigurerGenerator { type = type.substring(0, type.indexOf('<')); } - // writePlaceholders.put("groupSize", o -> endpoint.setGroupSize(camelContext.getTypeConverter().convertTo(Integer.class, o))); StringBuilder sb = new StringBuilder(); - sb.append("o -> endpoint.set").append(getOrSet).append("(camelContext.getTypeConverter().convertTo(").append(type).append(".class, o))"); + sb.append("o -> endpoint.set").append(getOrSet).append("(property(camelContext, ").append(type).append(".class, o))"); return sb.toString(); } diff --git a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriEndpoint.java b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriEndpoint.java index 0ebd509..703c80d 100644 --- a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriEndpoint.java +++ b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriEndpoint.java @@ -154,4 +154,11 @@ public @interface UriEndpoint { */ String excludeProperties() default ""; + /** + * Generates source code for fast configuring of the endpoint properties which + * uses direct method invocation of getter/setters. + * Setting this to false will fallback to use reflection based introspection as Camel does in Camel 2.x. + */ + boolean generateConfigurer() default true; + } \ No newline at end of file