CAMEL-9683: Moved model into remote sub package for remote service call EIPs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c97e816f Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c97e816f Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c97e816f Branch: refs/heads/remoteServiceCall Commit: c97e816f118aa189e6a85dfb9e71f043a7827e91 Parents: f0d811e Author: Claus Ibsen <davscl...@apache.org> Authored: Tue May 17 15:49:05 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon May 23 09:27:27 2016 +0200 ---------------------------------------------------------------------- .../java/org/apache/camel/model/Constants.java | 1 + .../model/HystrixConfigurationDefinition.java | 3 + .../apache/camel/model/HystrixDefinition.java | 3 + .../apache/camel/model/ProcessorDefinition.java | 1 + .../ServiceCallConfigurationDefinition.java | 449 ------------------ .../camel/model/ServiceCallDefinition.java | 268 ----------- .../ServiceCallConfigurationDefinition.java | 455 +++++++++++++++++++ .../model/remote/ServiceCallDefinition.java | 272 +++++++++++ .../apache/camel/model/remote/package-info.java | 23 + .../support/ServiceCallExpressionSupport.java | 3 +- .../resources/org/apache/camel/model/jaxb.index | 2 - .../org/apache/camel/model/remote/jaxb.index | 18 + .../blueprint/CamelContextFactoryBean.java | 2 +- components/camel-kubernetes/pom.xml | 2 +- .../processor/KubernetesProcessorFactory.java | 4 +- .../processor/ServiceCallRouteTest.java | 2 +- .../processor/SpringServiceCallRouteTest.java | 41 ++ .../processor/SpringServiceCallRouteTest.xml | 39 ++ .../processor/RibbonProcessorFactory.java | 6 +- .../RibbonServiceCallKubernetesRouteTest.java | 2 +- .../RibbonServiceCallRegistryRouteTest.java | 2 +- .../camel/spring/CamelContextFactoryBean.java | 2 +- .../spring/handler/CamelNamespaceHandler.java | 4 +- 23 files changed, 871 insertions(+), 733 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/java/org/apache/camel/model/Constants.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/Constants.java b/camel-core/src/main/java/org/apache/camel/model/Constants.java index b33eef7..9c72ac1 100644 --- a/camel-core/src/main/java/org/apache/camel/model/Constants.java +++ b/camel-core/src/main/java/org/apache/camel/model/Constants.java @@ -30,6 +30,7 @@ public final class Constants { + "org.apache.camel.model.dataformat:" + "org.apache.camel.model.language:" + "org.apache.camel.model.loadbalancer:" + + "org.apache.camel.model.remote:" + "org.apache.camel.model.rest"; public static final String PLACEHOLDER_QNAME = "http://camel.apache.org/schema/placeholder"; http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/java/org/apache/camel/model/HystrixConfigurationDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/HystrixConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/HystrixConfigurationDefinition.java index 3993f47..9a02058 100644 --- a/camel-core/src/main/java/org/apache/camel/model/HystrixConfigurationDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/HystrixConfigurationDefinition.java @@ -28,6 +28,9 @@ import javax.xml.bind.annotation.XmlTransient; import org.apache.camel.spi.Metadata; +/** + * Hystrix Circuit Breaker EIP configuration + */ @Metadata(label = "eip,routing,circuitbreaker") @XmlRootElement(name = "hystrixConfiguration") @XmlAccessorType(XmlAccessType.FIELD) http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java b/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java index 6251759..7ef7302 100644 --- a/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/HystrixDefinition.java @@ -31,6 +31,9 @@ import org.apache.camel.Processor; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.RouteContext; +/** + * Hystrix Circuit Breaker EIP + */ @Metadata(label = "eip,routing,circuitbreaker") @XmlRootElement(name = "hystrix") @XmlAccessorType(XmlAccessType.FIELD) http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java index 469bbe1..c178af5 100644 --- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java @@ -53,6 +53,7 @@ import org.apache.camel.model.language.ConstantExpression; import org.apache.camel.model.language.ExpressionDefinition; import org.apache.camel.model.language.LanguageExpression; import org.apache.camel.model.language.SimpleExpression; +import org.apache.camel.model.remote.ServiceCallDefinition; import org.apache.camel.model.rest.RestDefinition; import org.apache.camel.processor.InterceptEndpointProcessor; import org.apache.camel.processor.Pipeline; http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/java/org/apache/camel/model/ServiceCallConfigurationDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/ServiceCallConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ServiceCallConfigurationDefinition.java deleted file mode 100644 index 4be884d..0000000 --- a/camel-core/src/main/java/org/apache/camel/model/ServiceCallConfigurationDefinition.java +++ /dev/null @@ -1,449 +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.model; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.ServiceCallLoadBalancer; -import org.apache.camel.spi.ServiceCallServerListStrategy; - -@Metadata(label = "eip,routing") -@XmlRootElement(name = "serviceCallConfiguration") -@XmlAccessorType(XmlAccessType.FIELD) -public class ServiceCallConfigurationDefinition extends IdentifiedType { - - @XmlTransient - private ServiceCallDefinition parent; - @XmlAttribute - private String component; - @XmlAttribute @Metadata(required = "true") - private String masterUrl; - @XmlAttribute - private String namespace; - @XmlAttribute - private String apiVersion; - @XmlAttribute @Metadata(label = "security") - private String username; - @XmlAttribute @Metadata(label = "security") - private String password; - @XmlAttribute @Metadata(label = "security") - private String oauthToken; - @XmlAttribute @Metadata(label = "security") - private String caCertData; - @XmlAttribute @Metadata(label = "security") - private String caCertFile; - @XmlAttribute @Metadata(label = "security") - private String clientCertData; - @XmlAttribute @Metadata(label = "security") - private String clientCertFile; - @XmlAttribute @Metadata(label = "security") - private String clientKeyAlgo; - @XmlAttribute @Metadata(label = "security") - private String clientKeyData; - @XmlAttribute @Metadata(label = "security") - private String clientKeyFile; - @XmlAttribute @Metadata(label = "security") - private String clientKeyPassphrase; - @XmlAttribute @Metadata(label = "security") - private Boolean trustCerts; - @XmlAttribute - private String loadBalancerRef; - @XmlTransient - private ServiceCallLoadBalancer loadBalancer; - @XmlAttribute - private String serverListStrategyRef; - @XmlTransient - private ServiceCallServerListStrategy serverListStrategy; - @XmlElement(name = "clientProperty") @Metadata(label = "advanced") - private List<PropertyDefinition> properties; - - public ServiceCallConfigurationDefinition() { - } - - public ServiceCallConfigurationDefinition(ServiceCallDefinition parent) { - this.parent = parent; - } - - // Getter/Setter - // ------------------------------------------------------------------------- - - - public String getComponent() { - return component; - } - - public void setComponent(String component) { - this.component = component; - } - - public String getMasterUrl() { - return masterUrl; - } - - public void setMasterUrl(String masterUrl) { - this.masterUrl = masterUrl; - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - public String getApiVersion() { - return apiVersion; - } - - public void setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getCaCertData() { - return caCertData; - } - - public void setCaCertData(String caCertData) { - this.caCertData = caCertData; - } - - public String getCaCertFile() { - return caCertFile; - } - - public void setCaCertFile(String caCertFile) { - this.caCertFile = caCertFile; - } - - public String getClientCertData() { - return clientCertData; - } - - public void setClientCertData(String clientCertData) { - this.clientCertData = clientCertData; - } - - public String getClientCertFile() { - return clientCertFile; - } - - public void setClientCertFile(String clientCertFile) { - this.clientCertFile = clientCertFile; - } - - public String getClientKeyAlgo() { - return clientKeyAlgo; - } - - public void setClientKeyAlgo(String clientKeyAlgo) { - this.clientKeyAlgo = clientKeyAlgo; - } - - public String getClientKeyData() { - return clientKeyData; - } - - public void setClientKeyData(String clientKeyData) { - this.clientKeyData = clientKeyData; - } - - public String getClientKeyFile() { - return clientKeyFile; - } - - public void setClientKeyFile(String clientKeyFile) { - this.clientKeyFile = clientKeyFile; - } - - public String getClientKeyPassphrase() { - return clientKeyPassphrase; - } - - public void setClientKeyPassphrase(String clientKeyPassphrase) { - this.clientKeyPassphrase = clientKeyPassphrase; - } - - public String getOauthToken() { - return oauthToken; - } - - public void setOauthToken(String oauthToken) { - this.oauthToken = oauthToken; - } - - public Boolean getTrustCerts() { - return trustCerts; - } - - public void setTrustCerts(Boolean trustCerts) { - this.trustCerts = trustCerts; - } - - public String getLoadBalancerRef() { - return loadBalancerRef; - } - - public void setLoadBalancerRef(String loadBalancerRef) { - this.loadBalancerRef = loadBalancerRef; - } - - public ServiceCallLoadBalancer getLoadBalancer() { - return loadBalancer; - } - - public void setLoadBalancer(ServiceCallLoadBalancer loadBalancer) { - this.loadBalancer = loadBalancer; - } - - public String getServerListStrategyRef() { - return serverListStrategyRef; - } - - public void setServerListStrategyRef(String serverListStrategyRef) { - this.serverListStrategyRef = serverListStrategyRef; - } - - public ServiceCallServerListStrategy getServerListStrategy() { - return serverListStrategy; - } - - public void setServerListStrategy(ServiceCallServerListStrategy serverListStrategy) { - this.serverListStrategy = serverListStrategy; - } - - public List<PropertyDefinition> getProperties() { - return properties; - } - - public void setProperties(List<PropertyDefinition> properties) { - this.properties = properties; - } - - // Fluent API - // ------------------------------------------------------------------------- - - /** - * Sets the name of the Camel component to use such as ribbon or kubernetes - */ - public ServiceCallConfigurationDefinition component(String component) { - setComponent(component); - return this; - } - - /** - * Sets the URL to the master - */ - public ServiceCallConfigurationDefinition masterUrl(String masterUrl) { - setMasterUrl(masterUrl); - return this; - } - - /** - * Sets the namespace to use - */ - public ServiceCallConfigurationDefinition namespace(String namespace) { - setNamespace(namespace); - return this; - } - - /** - * Sets the API version - */ - public ServiceCallConfigurationDefinition apiVersion(String apiVersion) { - setApiVersion(apiVersion); - return this; - } - - /** - * Sets the username for authentication - */ - public ServiceCallConfigurationDefinition username(String username) { - setUsername(username); - return this; - } - - /** - * Sets the password for authentication - */ - public ServiceCallConfigurationDefinition password(String password) { - setPassword(password); - return this; - } - - /** - * Sets the OAUTH token for authentication (instead of username/password) - */ - public ServiceCallConfigurationDefinition oauthToken(String oauthToken) { - setOauthToken(oauthToken); - return this; - } - - /** - * Sets the Certificate Authority data - */ - public ServiceCallConfigurationDefinition caCertData(String caCertData) { - setCaCertData(caCertData); - return this; - } - - /** - * Sets the Certificate Authority data that are loaded from the file - */ - public ServiceCallConfigurationDefinition caCertFile(String caCertFile) { - setCaCertFile(caCertFile); - return this; - } - - /** - * Sets the Client Certificate data - */ - public ServiceCallConfigurationDefinition clientCertData(String clientCertData) { - setClientCertData(clientCertData); - return this; - } - - /** - * Sets the Client Certificate data that are loaded from the file - */ - public ServiceCallConfigurationDefinition clientCertFile(String clientCertFile) { - setClientCertFile(clientCertFile); - return this; - } - - /** - * Sets the Client Keystore algorithm, such as RSA. - */ - public ServiceCallConfigurationDefinition clientKeyAlgo(String clientKeyAlgo) { - setClientKeyAlgo(clientKeyAlgo); - return this; - } - - /** - * Sets the Client Keystore data - */ - public ServiceCallConfigurationDefinition clientKeyData(String clientKeyData) { - setClientKeyData(clientKeyData); - return this; - } - - /** - * Sets the Client Keystore data that are loaded from the file - */ - public ServiceCallConfigurationDefinition clientKeyFile(String clientKeyFile) { - setClientKeyFile(clientKeyFile); - return this; - } - - /** - * Sets the Client Keystore passphrase - */ - public ServiceCallConfigurationDefinition clientKeyPassphrase(String clientKeyPassphrase) { - setClientKeyPassphrase(clientKeyPassphrase); - return this; - } - - /** - * Sets whether to turn on trust certificate check - */ - public ServiceCallConfigurationDefinition trustCerts(boolean trustCerts) { - setTrustCerts(trustCerts); - return this; - } - - /** - * Sets a reference to a custom {@link org.apache.camel.spi.ServiceCallLoadBalancer} to use. - */ - public ServiceCallConfigurationDefinition loadBalancer(String loadBalancerRef) { - setLoadBalancerRef(loadBalancerRef); - return this; - } - - /** - * Sets a custom {@link org.apache.camel.spi.ServiceCallLoadBalancer} to use. - */ - public ServiceCallConfigurationDefinition loadBalancer(ServiceCallLoadBalancer loadBalancer) { - setLoadBalancer(loadBalancer); - return this; - } - - /** - * Sets a reference to a custom {@link org.apache.camel.spi.ServiceCallServerListStrategy} to use. - */ - public ServiceCallConfigurationDefinition serverListStrategy(String serverListStrategyRef) { - setServerListStrategyRef(serverListStrategyRef); - return this; - } - - /** - * Sets a custom {@link org.apache.camel.spi.ServiceCallServerListStrategy} to use. - */ - public ServiceCallConfigurationDefinition serverListStrategy(ServiceCallServerListStrategy serverListStrategy) { - setServerListStrategy(serverListStrategy); - return this; - } - - /** - * Adds a custom client property to use. - * <p/> - * These properties are specific to what service call implementation are in use. For example if using ribbon, then - * the client properties are define in com.netflix.client.config.CommonClientConfigKey. - */ - public ServiceCallConfigurationDefinition clientProperty(String key, String value) { - if (properties == null) { - properties = new ArrayList<>(); - } - PropertyDefinition prop = new PropertyDefinition(); - prop.setKey(key); - prop.setValue(value); - properties.add(prop); - return this; - } - - /** - * End of configuration - */ - public ProcessorDefinition end() { - // end parent as well so we do not have to use 2x end - return parent.end(); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/java/org/apache/camel/model/ServiceCallDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/ServiceCallDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ServiceCallDefinition.java deleted file mode 100644 index 4cc8cb6..0000000 --- a/camel-core/src/main/java/org/apache/camel/model/ServiceCallDefinition.java +++ /dev/null @@ -1,268 +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.model; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import org.apache.camel.ExchangePattern; -import org.apache.camel.Processor; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.RouteContext; -import org.apache.camel.spi.ServiceCallLoadBalancer; -import org.apache.camel.spi.ServiceCallServerListStrategy; -import org.apache.camel.util.CamelContextHelper; - -@Metadata(label = "eip,routing") -@XmlRootElement(name = "serviceCall") -@XmlAccessorType(XmlAccessType.FIELD) -public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinition> { - - @XmlElement - private ServiceCallConfigurationDefinition serviceCallConfiguration; - @XmlAttribute @Metadata(required = "true") - private String uri; - @XmlAttribute - private ExchangePattern pattern; - @XmlAttribute @Metadata(defaultValue = "default") - private String namespace; - @XmlAttribute @Metadata(required = "true") - private String name; - @XmlAttribute - private String serviceCallConfigurationRef; - @XmlAttribute - private String loadBalancerRef; - // TODO: allow to use custom type as load balancer - @XmlTransient - private ServiceCallLoadBalancer loadBalancer; - @XmlAttribute - private String serverListStrategyRef; - @XmlTransient - private ServiceCallServerListStrategy serverListStrategy; - - public ServiceCallDefinition() { - } - - @Override - public String toString() { - return "ServiceCall[" + name + "]"; - } - - @Override - public String getLabel() { - return "serviceCall"; - } - - @Override - public Processor createProcessor(RouteContext routeContext) throws Exception { - String component = serviceCallConfiguration != null ? serviceCallConfiguration.getComponent() : null; - if (component == null && serviceCallConfigurationRef != null) { - ServiceCallConfigurationDefinition config = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), serviceCallConfigurationRef, ServiceCallConfigurationDefinition.class); - component = config.getComponent(); - } - - if (component != null) { - throw new IllegalStateException("Cannot find Camel component on the classpath implementing the discovery provider: " + component); - } else { - throw new IllegalStateException("Cannot find Camel component supporting the ServiceCall EIP such as camel-kubernetes or camel-ribbon."); - } - } - - // Fluent API - // ------------------------------------------------------------------------- - - /** - * Sets the optional {@link ExchangePattern} used to invoke this endpoint - */ - public ServiceCallDefinition pattern(ExchangePattern pattern) { - setPattern(pattern); - return this; - } - - /** - * Sets the namespace of the service to use - */ - public ServiceCallDefinition namespace(String namespace) { - setNamespace(namespace); - return this; - } - - /** - * Sets the name of the service to use - */ - public ServiceCallDefinition name(String name) { - setName(name); - return this; - } - - /** - * Sets the uri of the service to use - */ - public ServiceCallDefinition uri(String uri) { - setUri(uri); - return this; - } - - /** - * Configures the Service Call EIP - * <p/> - * Use <tt>end</tt> when configuration is complete, to return back to the Service Call EIP. - */ - public ServiceCallConfigurationDefinition serviceCallConfiguration() { - serviceCallConfiguration = new ServiceCallConfigurationDefinition(this); - return serviceCallConfiguration; - } - - /** - * Configures the ServiceCall using the given configuration - */ - public ServiceCallDefinition serviceCallConfiguration(ServiceCallConfigurationDefinition configuration) { - serviceCallConfiguration = configuration; - return this; - } - - /** - * Refers to a ServiceCall configuration to use - */ - public ServiceCallDefinition serviceCallConfiguration(String ref) { - serviceCallConfigurationRef = ref; - return this; - } - - /** - * Sets a reference to a custom {@link org.apache.camel.spi.ServiceCallLoadBalancer} to use. - */ - public ServiceCallDefinition loadBalancer(String loadBalancerRef) { - setLoadBalancerRef(loadBalancerRef); - return this; - } - - /** - * Sets a custom {@link org.apache.camel.spi.ServiceCallLoadBalancer} to use. - */ - public ServiceCallDefinition loadBalancer(ServiceCallLoadBalancer loadBalancer) { - setLoadBalancer(loadBalancer); - return this; - } - - /** - * Sets a reference to a custom {@link org.apache.camel.spi.ServiceCallServerListStrategy} to use. - */ - public ServiceCallDefinition serverListStrategy(String serverListStrategyRef) { - setServerListStrategyRef(serverListStrategyRef); - return this; - } - - /** - * Sets a custom {@link org.apache.camel.spi.ServiceCallServerListStrategy} to use. - */ - public ServiceCallDefinition serverListStrategy(ServiceCallServerListStrategy serverListStrategy) { - setServerListStrategy(serverListStrategy); - return this; - } - - // Properties - // ------------------------------------------------------------------------- - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - public ExchangePattern getPattern() { - return pattern; - } - - public void setPattern(ExchangePattern pattern) { - this.pattern = pattern; - } - - public ServiceCallConfigurationDefinition getServiceCallConfiguration() { - return serviceCallConfiguration; - } - - public void setServiceCallConfiguration(ServiceCallConfigurationDefinition serviceCallConfiguration) { - this.serviceCallConfiguration = serviceCallConfiguration; - } - - public String getServiceCallConfigurationRef() { - return serviceCallConfigurationRef; - } - - public void setServiceCallConfigurationRef(String serviceCallConfigurationRef) { - this.serviceCallConfigurationRef = serviceCallConfigurationRef; - } - - public String getUri() { - return uri; - } - - /** - * The uri of the endpoint to send to. - * The uri can be dynamic computed using the {@link org.apache.camel.language.simple.SimpleLanguage} expression. - */ - public void setUri(String uri) { - this.uri = uri; - } - - public String getLoadBalancerRef() { - return loadBalancerRef; - } - - public void setLoadBalancerRef(String loadBalancerRef) { - this.loadBalancerRef = loadBalancerRef; - } - - public ServiceCallLoadBalancer getLoadBalancer() { - return loadBalancer; - } - - public void setLoadBalancer(ServiceCallLoadBalancer loadBalancer) { - this.loadBalancer = loadBalancer; - } - - public String getServerListStrategyRef() { - return serverListStrategyRef; - } - - public void setServerListStrategyRef(String serverListStrategyRef) { - this.serverListStrategyRef = serverListStrategyRef; - } - - public ServiceCallServerListStrategy getServerListStrategy() { - return serverListStrategy; - } - - public void setServerListStrategy(ServiceCallServerListStrategy serverListStrategy) { - this.serverListStrategy = serverListStrategy; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallConfigurationDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallConfigurationDefinition.java new file mode 100644 index 0000000..6fb0363 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallConfigurationDefinition.java @@ -0,0 +1,455 @@ +/** + * 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.model.remote; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.apache.camel.model.IdentifiedType; +import org.apache.camel.model.ProcessorDefinition; +import org.apache.camel.model.PropertyDefinition; +import org.apache.camel.spi.Metadata; +import org.apache.camel.spi.ServiceCallLoadBalancer; +import org.apache.camel.spi.ServiceCallServerListStrategy; + +/** + * Remote service call configuration + */ +@Metadata(label = "eip,routing") +@XmlRootElement(name = "serviceCallConfiguration") +@XmlAccessorType(XmlAccessType.FIELD) +public class ServiceCallConfigurationDefinition extends IdentifiedType { + + @XmlTransient + private ServiceCallDefinition parent; + @XmlAttribute + private String component; + @XmlAttribute @Metadata(required = "true") + private String masterUrl; + @XmlAttribute + private String namespace; + @XmlAttribute + private String apiVersion; + @XmlAttribute @Metadata(label = "security") + private String username; + @XmlAttribute @Metadata(label = "security") + private String password; + @XmlAttribute @Metadata(label = "security") + private String oauthToken; + @XmlAttribute @Metadata(label = "security") + private String caCertData; + @XmlAttribute @Metadata(label = "security") + private String caCertFile; + @XmlAttribute @Metadata(label = "security") + private String clientCertData; + @XmlAttribute @Metadata(label = "security") + private String clientCertFile; + @XmlAttribute @Metadata(label = "security") + private String clientKeyAlgo; + @XmlAttribute @Metadata(label = "security") + private String clientKeyData; + @XmlAttribute @Metadata(label = "security") + private String clientKeyFile; + @XmlAttribute @Metadata(label = "security") + private String clientKeyPassphrase; + @XmlAttribute @Metadata(label = "security") + private Boolean trustCerts; + @XmlAttribute + private String loadBalancerRef; + @XmlTransient + private ServiceCallLoadBalancer loadBalancer; + @XmlAttribute + private String serverListStrategyRef; + @XmlTransient + private ServiceCallServerListStrategy serverListStrategy; + @XmlElement(name = "clientProperty") @Metadata(label = "advanced") + private List<PropertyDefinition> properties; + + public ServiceCallConfigurationDefinition() { + } + + public ServiceCallConfigurationDefinition(ServiceCallDefinition parent) { + this.parent = parent; + } + + // Getter/Setter + // ------------------------------------------------------------------------- + + + public String getComponent() { + return component; + } + + public void setComponent(String component) { + this.component = component; + } + + public String getMasterUrl() { + return masterUrl; + } + + public void setMasterUrl(String masterUrl) { + this.masterUrl = masterUrl; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + public String getApiVersion() { + return apiVersion; + } + + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getCaCertData() { + return caCertData; + } + + public void setCaCertData(String caCertData) { + this.caCertData = caCertData; + } + + public String getCaCertFile() { + return caCertFile; + } + + public void setCaCertFile(String caCertFile) { + this.caCertFile = caCertFile; + } + + public String getClientCertData() { + return clientCertData; + } + + public void setClientCertData(String clientCertData) { + this.clientCertData = clientCertData; + } + + public String getClientCertFile() { + return clientCertFile; + } + + public void setClientCertFile(String clientCertFile) { + this.clientCertFile = clientCertFile; + } + + public String getClientKeyAlgo() { + return clientKeyAlgo; + } + + public void setClientKeyAlgo(String clientKeyAlgo) { + this.clientKeyAlgo = clientKeyAlgo; + } + + public String getClientKeyData() { + return clientKeyData; + } + + public void setClientKeyData(String clientKeyData) { + this.clientKeyData = clientKeyData; + } + + public String getClientKeyFile() { + return clientKeyFile; + } + + public void setClientKeyFile(String clientKeyFile) { + this.clientKeyFile = clientKeyFile; + } + + public String getClientKeyPassphrase() { + return clientKeyPassphrase; + } + + public void setClientKeyPassphrase(String clientKeyPassphrase) { + this.clientKeyPassphrase = clientKeyPassphrase; + } + + public String getOauthToken() { + return oauthToken; + } + + public void setOauthToken(String oauthToken) { + this.oauthToken = oauthToken; + } + + public Boolean getTrustCerts() { + return trustCerts; + } + + public void setTrustCerts(Boolean trustCerts) { + this.trustCerts = trustCerts; + } + + public String getLoadBalancerRef() { + return loadBalancerRef; + } + + public void setLoadBalancerRef(String loadBalancerRef) { + this.loadBalancerRef = loadBalancerRef; + } + + public ServiceCallLoadBalancer getLoadBalancer() { + return loadBalancer; + } + + public void setLoadBalancer(ServiceCallLoadBalancer loadBalancer) { + this.loadBalancer = loadBalancer; + } + + public String getServerListStrategyRef() { + return serverListStrategyRef; + } + + public void setServerListStrategyRef(String serverListStrategyRef) { + this.serverListStrategyRef = serverListStrategyRef; + } + + public ServiceCallServerListStrategy getServerListStrategy() { + return serverListStrategy; + } + + public void setServerListStrategy(ServiceCallServerListStrategy serverListStrategy) { + this.serverListStrategy = serverListStrategy; + } + + public List<PropertyDefinition> getProperties() { + return properties; + } + + public void setProperties(List<PropertyDefinition> properties) { + this.properties = properties; + } + + // Fluent API + // ------------------------------------------------------------------------- + + /** + * Sets the name of the Camel component to use such as ribbon or kubernetes + */ + public ServiceCallConfigurationDefinition component(String component) { + setComponent(component); + return this; + } + + /** + * Sets the URL to the master + */ + public ServiceCallConfigurationDefinition masterUrl(String masterUrl) { + setMasterUrl(masterUrl); + return this; + } + + /** + * Sets the namespace to use + */ + public ServiceCallConfigurationDefinition namespace(String namespace) { + setNamespace(namespace); + return this; + } + + /** + * Sets the API version + */ + public ServiceCallConfigurationDefinition apiVersion(String apiVersion) { + setApiVersion(apiVersion); + return this; + } + + /** + * Sets the username for authentication + */ + public ServiceCallConfigurationDefinition username(String username) { + setUsername(username); + return this; + } + + /** + * Sets the password for authentication + */ + public ServiceCallConfigurationDefinition password(String password) { + setPassword(password); + return this; + } + + /** + * Sets the OAUTH token for authentication (instead of username/password) + */ + public ServiceCallConfigurationDefinition oauthToken(String oauthToken) { + setOauthToken(oauthToken); + return this; + } + + /** + * Sets the Certificate Authority data + */ + public ServiceCallConfigurationDefinition caCertData(String caCertData) { + setCaCertData(caCertData); + return this; + } + + /** + * Sets the Certificate Authority data that are loaded from the file + */ + public ServiceCallConfigurationDefinition caCertFile(String caCertFile) { + setCaCertFile(caCertFile); + return this; + } + + /** + * Sets the Client Certificate data + */ + public ServiceCallConfigurationDefinition clientCertData(String clientCertData) { + setClientCertData(clientCertData); + return this; + } + + /** + * Sets the Client Certificate data that are loaded from the file + */ + public ServiceCallConfigurationDefinition clientCertFile(String clientCertFile) { + setClientCertFile(clientCertFile); + return this; + } + + /** + * Sets the Client Keystore algorithm, such as RSA. + */ + public ServiceCallConfigurationDefinition clientKeyAlgo(String clientKeyAlgo) { + setClientKeyAlgo(clientKeyAlgo); + return this; + } + + /** + * Sets the Client Keystore data + */ + public ServiceCallConfigurationDefinition clientKeyData(String clientKeyData) { + setClientKeyData(clientKeyData); + return this; + } + + /** + * Sets the Client Keystore data that are loaded from the file + */ + public ServiceCallConfigurationDefinition clientKeyFile(String clientKeyFile) { + setClientKeyFile(clientKeyFile); + return this; + } + + /** + * Sets the Client Keystore passphrase + */ + public ServiceCallConfigurationDefinition clientKeyPassphrase(String clientKeyPassphrase) { + setClientKeyPassphrase(clientKeyPassphrase); + return this; + } + + /** + * Sets whether to turn on trust certificate check + */ + public ServiceCallConfigurationDefinition trustCerts(boolean trustCerts) { + setTrustCerts(trustCerts); + return this; + } + + /** + * Sets a reference to a custom {@link org.apache.camel.spi.ServiceCallLoadBalancer} to use. + */ + public ServiceCallConfigurationDefinition loadBalancer(String loadBalancerRef) { + setLoadBalancerRef(loadBalancerRef); + return this; + } + + /** + * Sets a custom {@link org.apache.camel.spi.ServiceCallLoadBalancer} to use. + */ + public ServiceCallConfigurationDefinition loadBalancer(ServiceCallLoadBalancer loadBalancer) { + setLoadBalancer(loadBalancer); + return this; + } + + /** + * Sets a reference to a custom {@link org.apache.camel.spi.ServiceCallServerListStrategy} to use. + */ + public ServiceCallConfigurationDefinition serverListStrategy(String serverListStrategyRef) { + setServerListStrategyRef(serverListStrategyRef); + return this; + } + + /** + * Sets a custom {@link org.apache.camel.spi.ServiceCallServerListStrategy} to use. + */ + public ServiceCallConfigurationDefinition serverListStrategy(ServiceCallServerListStrategy serverListStrategy) { + setServerListStrategy(serverListStrategy); + return this; + } + + /** + * Adds a custom client property to use. + * <p/> + * These properties are specific to what service call implementation are in use. For example if using ribbon, then + * the client properties are define in com.netflix.client.config.CommonClientConfigKey. + */ + public ServiceCallConfigurationDefinition clientProperty(String key, String value) { + if (properties == null) { + properties = new ArrayList<>(); + } + PropertyDefinition prop = new PropertyDefinition(); + prop.setKey(key); + prop.setValue(value); + properties.add(prop); + return this; + } + + /** + * End of configuration + */ + public ProcessorDefinition end() { + // end parent as well so we do not have to use 2x end + return parent.end(); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallDefinition.java b/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallDefinition.java new file mode 100644 index 0000000..c923128 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/remote/ServiceCallDefinition.java @@ -0,0 +1,272 @@ +/** + * 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.model.remote; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.apache.camel.ExchangePattern; +import org.apache.camel.Processor; +import org.apache.camel.model.NoOutputDefinition; +import org.apache.camel.spi.Metadata; +import org.apache.camel.spi.RouteContext; +import org.apache.camel.spi.ServiceCallLoadBalancer; +import org.apache.camel.spi.ServiceCallServerListStrategy; +import org.apache.camel.util.CamelContextHelper; + +/** + * Remote service call + */ +@Metadata(label = "eip,routing") +@XmlRootElement(name = "serviceCall") +@XmlAccessorType(XmlAccessType.FIELD) +public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinition> { + + @XmlElement + private ServiceCallConfigurationDefinition serviceCallConfiguration; + @XmlAttribute @Metadata(required = "true") + private String uri; + @XmlAttribute + private ExchangePattern pattern; + @XmlAttribute @Metadata(defaultValue = "default") + private String namespace; + @XmlAttribute @Metadata(required = "true") + private String name; + @XmlAttribute + private String serviceCallConfigurationRef; + @XmlAttribute + private String loadBalancerRef; + // TODO: allow to use custom type as load balancer + @XmlTransient + private ServiceCallLoadBalancer loadBalancer; + @XmlAttribute + private String serverListStrategyRef; + @XmlTransient + private ServiceCallServerListStrategy serverListStrategy; + + public ServiceCallDefinition() { + } + + @Override + public String toString() { + return "ServiceCall[" + name + "]"; + } + + @Override + public String getLabel() { + return "serviceCall"; + } + + @Override + public Processor createProcessor(RouteContext routeContext) throws Exception { + String component = serviceCallConfiguration != null ? serviceCallConfiguration.getComponent() : null; + if (component == null && serviceCallConfigurationRef != null) { + ServiceCallConfigurationDefinition config = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), serviceCallConfigurationRef, ServiceCallConfigurationDefinition.class); + component = config.getComponent(); + } + + if (component != null) { + throw new IllegalStateException("Cannot find Camel component on the classpath implementing the discovery provider: " + component); + } else { + throw new IllegalStateException("Cannot find Camel component supporting the ServiceCall EIP such as camel-kubernetes or camel-ribbon."); + } + } + + // Fluent API + // ------------------------------------------------------------------------- + + /** + * Sets the optional {@link ExchangePattern} used to invoke this endpoint + */ + public ServiceCallDefinition pattern(ExchangePattern pattern) { + setPattern(pattern); + return this; + } + + /** + * Sets the namespace of the service to use + */ + public ServiceCallDefinition namespace(String namespace) { + setNamespace(namespace); + return this; + } + + /** + * Sets the name of the service to use + */ + public ServiceCallDefinition name(String name) { + setName(name); + return this; + } + + /** + * Sets the uri of the service to use + */ + public ServiceCallDefinition uri(String uri) { + setUri(uri); + return this; + } + + /** + * Configures the Service Call EIP + * <p/> + * Use <tt>end</tt> when configuration is complete, to return back to the Service Call EIP. + */ + public ServiceCallConfigurationDefinition serviceCallConfiguration() { + serviceCallConfiguration = new ServiceCallConfigurationDefinition(this); + return serviceCallConfiguration; + } + + /** + * Configures the ServiceCall using the given configuration + */ + public ServiceCallDefinition serviceCallConfiguration(ServiceCallConfigurationDefinition configuration) { + serviceCallConfiguration = configuration; + return this; + } + + /** + * Refers to a ServiceCall configuration to use + */ + public ServiceCallDefinition serviceCallConfiguration(String ref) { + serviceCallConfigurationRef = ref; + return this; + } + + /** + * Sets a reference to a custom {@link org.apache.camel.spi.ServiceCallLoadBalancer} to use. + */ + public ServiceCallDefinition loadBalancer(String loadBalancerRef) { + setLoadBalancerRef(loadBalancerRef); + return this; + } + + /** + * Sets a custom {@link org.apache.camel.spi.ServiceCallLoadBalancer} to use. + */ + public ServiceCallDefinition loadBalancer(ServiceCallLoadBalancer loadBalancer) { + setLoadBalancer(loadBalancer); + return this; + } + + /** + * Sets a reference to a custom {@link org.apache.camel.spi.ServiceCallServerListStrategy} to use. + */ + public ServiceCallDefinition serverListStrategy(String serverListStrategyRef) { + setServerListStrategyRef(serverListStrategyRef); + return this; + } + + /** + * Sets a custom {@link org.apache.camel.spi.ServiceCallServerListStrategy} to use. + */ + public ServiceCallDefinition serverListStrategy(ServiceCallServerListStrategy serverListStrategy) { + setServerListStrategy(serverListStrategy); + return this; + } + + // Properties + // ------------------------------------------------------------------------- + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + public ExchangePattern getPattern() { + return pattern; + } + + public void setPattern(ExchangePattern pattern) { + this.pattern = pattern; + } + + public ServiceCallConfigurationDefinition getServiceCallConfiguration() { + return serviceCallConfiguration; + } + + public void setServiceCallConfiguration(ServiceCallConfigurationDefinition serviceCallConfiguration) { + this.serviceCallConfiguration = serviceCallConfiguration; + } + + public String getServiceCallConfigurationRef() { + return serviceCallConfigurationRef; + } + + public void setServiceCallConfigurationRef(String serviceCallConfigurationRef) { + this.serviceCallConfigurationRef = serviceCallConfigurationRef; + } + + public String getUri() { + return uri; + } + + /** + * The uri of the endpoint to send to. + * The uri can be dynamic computed using the {@link org.apache.camel.language.simple.SimpleLanguage} expression. + */ + public void setUri(String uri) { + this.uri = uri; + } + + public String getLoadBalancerRef() { + return loadBalancerRef; + } + + public void setLoadBalancerRef(String loadBalancerRef) { + this.loadBalancerRef = loadBalancerRef; + } + + public ServiceCallLoadBalancer getLoadBalancer() { + return loadBalancer; + } + + public void setLoadBalancer(ServiceCallLoadBalancer loadBalancer) { + this.loadBalancer = loadBalancer; + } + + public String getServerListStrategyRef() { + return serverListStrategyRef; + } + + public void setServerListStrategyRef(String serverListStrategyRef) { + this.serverListStrategyRef = serverListStrategyRef; + } + + public ServiceCallServerListStrategy getServerListStrategy() { + return serverListStrategy; + } + + public void setServerListStrategy(ServiceCallServerListStrategy serverListStrategy) { + this.serverListStrategy = serverListStrategy; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/java/org/apache/camel/model/remote/package-info.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/remote/package-info.java b/camel-core/src/main/java/org/apache/camel/model/remote/package-info.java new file mode 100644 index 0000000..5d6e89e --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/remote/package-info.java @@ -0,0 +1,23 @@ +/** + * 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. + */ + + +/** + * The JAXB POJOs for the remote service call DSL + */ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://camel.apache.org/schema/spring", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package org.apache.camel.model.remote; http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/java/org/apache/camel/support/ServiceCallExpressionSupport.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/support/ServiceCallExpressionSupport.java b/camel-core/src/main/java/org/apache/camel/support/ServiceCallExpressionSupport.java index b08e074..eda1092 100644 --- a/camel-core/src/main/java/org/apache/camel/support/ServiceCallExpressionSupport.java +++ b/camel-core/src/main/java/org/apache/camel/support/ServiceCallExpressionSupport.java @@ -17,12 +17,13 @@ package org.apache.camel.support; import org.apache.camel.Exchange; +import org.apache.camel.model.remote.ServiceCallDefinition; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Support class for custom implementations of {@link org.apache.camel.model.ServiceCallDefinition ServiceCall EIP} components. + * Support class for custom implementations of {@link ServiceCallDefinition ServiceCall EIP} components. */ public abstract class ServiceCallExpressionSupport extends ExpressionAdapter { http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/resources/org/apache/camel/model/jaxb.index ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index index 18892e0..9859736 100644 --- a/camel-core/src/main/resources/org/apache/camel/model/jaxb.index +++ b/camel-core/src/main/resources/org/apache/camel/model/jaxb.index @@ -74,8 +74,6 @@ RoutesDefinition RoutingSlipDefinition SamplingDefinition ScriptDefinition -ServiceCallDefinition -ServiceCallConfigurationDefinition SetBodyDefinition SetExchangePatternDefinition SetFaultBodyDefinition http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/camel-core/src/main/resources/org/apache/camel/model/remote/jaxb.index ---------------------------------------------------------------------- diff --git a/camel-core/src/main/resources/org/apache/camel/model/remote/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/remote/jaxb.index new file mode 100644 index 0000000..498dc90 --- /dev/null +++ b/camel-core/src/main/resources/org/apache/camel/model/remote/jaxb.index @@ -0,0 +1,18 @@ +## ------------------------------------------------------------------------ +## 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. +## ------------------------------------------------------------------------ +ServiceCallDefinition +ServiceCallConfigurationDefinition http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java ---------------------------------------------------------------------- diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java index f0c204c..362f057 100644 --- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java +++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java @@ -56,9 +56,9 @@ import org.apache.camel.model.RestContextRefDefinition; import org.apache.camel.model.RouteBuilderDefinition; import org.apache.camel.model.RouteContextRefDefinition; import org.apache.camel.model.RouteDefinition; -import org.apache.camel.model.ServiceCallConfigurationDefinition; import org.apache.camel.model.ThreadPoolProfileDefinition; import org.apache.camel.model.dataformat.DataFormatsDefinition; +import org.apache.camel.model.remote.ServiceCallConfigurationDefinition; import org.apache.camel.model.rest.RestConfigurationDefinition; import org.apache.camel.model.rest.RestDefinition; import org.apache.camel.spi.PackageScanFilter; http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-kubernetes/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/pom.xml b/components/camel-kubernetes/pom.xml index fd13f1a..89c3fcc 100644 --- a/components/camel-kubernetes/pom.xml +++ b/components/camel-kubernetes/pom.xml @@ -52,7 +52,7 @@ <!-- testing --> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-spring</artifactId> <scope>test</scope> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesProcessorFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesProcessorFactory.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesProcessorFactory.java index fcf2a65..7378d69 100644 --- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesProcessorFactory.java +++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesProcessorFactory.java @@ -24,8 +24,8 @@ import org.apache.camel.ExchangePattern; import org.apache.camel.Processor; import org.apache.camel.component.kubernetes.KubernetesConfiguration; import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.model.ServiceCallConfigurationDefinition; -import org.apache.camel.model.ServiceCallDefinition; +import org.apache.camel.model.remote.ServiceCallConfigurationDefinition; +import org.apache.camel.model.remote.ServiceCallDefinition; import org.apache.camel.spi.ProcessorFactory; import org.apache.camel.spi.RouteContext; import org.apache.camel.spi.ServiceCallLoadBalancer; http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/ServiceCallRouteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/ServiceCallRouteTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/ServiceCallRouteTest.java index 0df2937..2c1ca37 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/ServiceCallRouteTest.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/ServiceCallRouteTest.java @@ -19,7 +19,7 @@ package org.apache.camel.component.kubernetes.processor; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.JndiRegistry; -import org.apache.camel.model.ServiceCallConfigurationDefinition; +import org.apache.camel.model.remote.ServiceCallConfigurationDefinition; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Ignore; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/SpringServiceCallRouteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/SpringServiceCallRouteTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/SpringServiceCallRouteTest.java new file mode 100644 index 0000000..06fcb81 --- /dev/null +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/SpringServiceCallRouteTest.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 + * + * 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.kubernetes.processor; + +import org.apache.camel.test.spring.CamelSpringTestSupport; +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +@Ignore("Manual test") +public class SpringServiceCallRouteTest extends CamelSpringTestSupport { + + @Override + protected AbstractApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/component/kubernetes/processor/SpringServiceCallRouteTest.xml"); + } + + @Test + public void testServiceCall() throws Exception { + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-kubernetes/src/test/resources/org/apache/camel/component/kubernetes/processor/SpringServiceCallRouteTest.xml ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/test/resources/org/apache/camel/component/kubernetes/processor/SpringServiceCallRouteTest.xml b/components/camel-kubernetes/src/test/resources/org/apache/camel/component/kubernetes/processor/SpringServiceCallRouteTest.xml new file mode 100644 index 0000000..3cb0a2f --- /dev/null +++ b/components/camel-kubernetes/src/test/resources/org/apache/camel/component/kubernetes/processor/SpringServiceCallRouteTest.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd + "> + + <camelContext xmlns="http://camel.apache.org/schema/spring"> + + <!-- service call configuration to use ribbon --> + <serviceCallConfiguration id="myConfig" masterUrl="https://fabric8-master.vagrant.f8:8443" + username="admin" password="admin" namespace="default" loadBalancerRef="roundrobin"/> + + <route> + <from uri="direct:start"/> + <serviceCall name="cdi-camel-jetty"/> + <serviceCall name="cdi-camel-jetty"/> + <to uri="mock:result"/> + </route> + </camelContext> + +</beans> http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/processor/RibbonProcessorFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/processor/RibbonProcessorFactory.java b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/processor/RibbonProcessorFactory.java index 84b6bb5..e3ab4d9 100644 --- a/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/processor/RibbonProcessorFactory.java +++ b/components/camel-ribbon/src/main/java/org/apache/camel/component/ribbon/processor/RibbonProcessorFactory.java @@ -26,8 +26,8 @@ import org.apache.camel.Processor; import org.apache.camel.component.ribbon.RibbonConfiguration; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.PropertyDefinition; -import org.apache.camel.model.ServiceCallConfigurationDefinition; -import org.apache.camel.model.ServiceCallDefinition; +import org.apache.camel.model.remote.ServiceCallConfigurationDefinition; +import org.apache.camel.model.remote.ServiceCallDefinition; import org.apache.camel.spi.ProcessorFactory; import org.apache.camel.spi.RouteContext; import org.apache.camel.spi.ServiceCallServerListStrategy; @@ -67,7 +67,7 @@ public class RibbonProcessorFactory implements ProcessorFactory { Set<ServiceCallConfigurationDefinition> set = routeContext.getCamelContext().getRegistry().findByType(ServiceCallConfigurationDefinition.class); if (set != null) { for (ServiceCallConfigurationDefinition candidate : set) { - if (candidate.getComponent() == null || "kubernetes".equals(candidate.getComponent())) { + if (candidate.getComponent() == null || "ribbon".equals(candidate.getComponent())) { config = candidate; break; } http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/processor/RibbonServiceCallKubernetesRouteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/processor/RibbonServiceCallKubernetesRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/processor/RibbonServiceCallKubernetesRouteTest.java index f829ba0..2dff71c 100644 --- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/processor/RibbonServiceCallKubernetesRouteTest.java +++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/processor/RibbonServiceCallKubernetesRouteTest.java @@ -18,7 +18,7 @@ package org.apache.camel.component.ribbon.processor; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.model.ServiceCallConfigurationDefinition; +import org.apache.camel.model.remote.ServiceCallConfigurationDefinition; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Ignore; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/processor/RibbonServiceCallRegistryRouteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/processor/RibbonServiceCallRegistryRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/processor/RibbonServiceCallRegistryRouteTest.java index 17159e9..39e75ff 100644 --- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/processor/RibbonServiceCallRegistryRouteTest.java +++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/processor/RibbonServiceCallRegistryRouteTest.java @@ -19,7 +19,7 @@ package org.apache.camel.component.ribbon.processor; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.JndiRegistry; -import org.apache.camel.model.ServiceCallConfigurationDefinition; +import org.apache.camel.model.remote.ServiceCallConfigurationDefinition; public class RibbonServiceCallRegistryRouteTest extends RibbonServiceCallRouteTest { http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java index f7518f7..227cd2e 100644 --- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java +++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java @@ -55,9 +55,9 @@ import org.apache.camel.model.RestContextRefDefinition; import org.apache.camel.model.RouteBuilderDefinition; import org.apache.camel.model.RouteContextRefDefinition; import org.apache.camel.model.RouteDefinition; -import org.apache.camel.model.ServiceCallConfigurationDefinition; import org.apache.camel.model.ThreadPoolProfileDefinition; import org.apache.camel.model.dataformat.DataFormatsDefinition; +import org.apache.camel.model.remote.ServiceCallConfigurationDefinition; import org.apache.camel.model.rest.RestConfigurationDefinition; import org.apache.camel.model.rest.RestDefinition; import org.apache.camel.spi.PackageScanFilter; http://git-wip-us.apache.org/repos/asf/camel/blob/c97e816f/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java index 442e529..ae119ff 100644 --- a/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java +++ b/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java @@ -40,7 +40,7 @@ import org.apache.camel.impl.DefaultCamelContextNameStrategy; import org.apache.camel.model.FromDefinition; import org.apache.camel.model.HystrixConfigurationDefinition; import org.apache.camel.model.SendDefinition; -import org.apache.camel.model.ServiceCallConfigurationDefinition; +import org.apache.camel.model.remote.ServiceCallConfigurationDefinition; import org.apache.camel.spi.CamelContextNameStrategy; import org.apache.camel.spi.NamespaceAware; import org.apache.camel.spring.CamelBeanPostProcessor; @@ -140,7 +140,7 @@ public class CamelNamespaceHandler extends NamespaceHandlerSupport { addBeanDefinitionParser("threadPool", CamelThreadPoolFactoryBean.class, true, true); addBeanDefinitionParser("redeliveryPolicyProfile", CamelRedeliveryPolicyFactoryBean.class, true, true); - // jmx agent, stream caching, hystrix configuration and property placeholder cannot be used outside of the camel context + // jmx agent, stream caching, hystrix, service call configuration and property placeholder cannot be used outside of the camel context addBeanDefinitionParser("jmxAgent", CamelJMXAgentDefinition.class, false, false); addBeanDefinitionParser("streamCaching", CamelStreamCachingStrategyDefinition.class, false, false); addBeanDefinitionParser("propertyPlaceholder", CamelPropertyPlaceholderDefinition.class, false, false);