CAMEL-9683: Renamed to ServiceCall
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8121da71 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8121da71 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8121da71 Branch: refs/heads/remoteServiceCall Commit: 8121da71d584183c69f05854e082d8b269a0d236 Parents: 27bec8f Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Apr 26 09:55:28 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon May 23 09:22:55 2016 +0200 ---------------------------------------------------------------------- .../apache/camel/model/ProcessorDefinition.java | 8 +- .../ServiceCallConfigurationDefinition.java | 326 +++++++++++++++++++ .../camel/model/ServiceCallDefinition.java | 201 ++++++++++++ .../model/ToServiceConfigurationDefinition.java | 326 ------------------- .../apache/camel/model/ToServiceDefinition.java | 201 ------------ .../resources/org/apache/camel/model/jaxb.index | 4 +- .../processor/KubernetesProcessorFactory.java | 16 +- .../processor/KubernetesServiceDiscovery.java | 1 - .../processor/KubernetesServiceProcessor.java | 1 + .../apache/camel/model/ServiceCallDefinition | 18 + .../org/apache/camel/model/ToServiceDefinition | 18 - .../processor/ServiceCallRouteTest.java | 54 +++ .../processor/ToServiceRouteTest.java | 54 --- 13 files changed, 614 insertions(+), 614 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/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 6c0e8f9..4849b9a 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 @@ -654,18 +654,18 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> } /** - * Sends the exchange to the given service + * Calls the service * * @param name the service name * @param uri the endpoint uri to use for calling the service * @return the builder */ @SuppressWarnings("unchecked") - public Type toService(String name, String uri, ToServiceConfigurationDefinition configuration) { - ToServiceDefinition answer = new ToServiceDefinition(); + public Type serviceCall(String name, String uri, ServiceCallConfigurationDefinition configuration) { + ServiceCallDefinition answer = new ServiceCallDefinition(); answer.setName(name); answer.setUri(uri); - answer.setToServiceConfiguration(configuration); + answer.setServiceCallConfiguration(configuration); addOutput(answer); return (Type) this; } http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/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 new file mode 100644 index 0000000..2363a63 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/ServiceCallConfigurationDefinition.java @@ -0,0 +1,326 @@ +/** + * 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.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.apache.camel.spi.Metadata; + +@Metadata(label = "eip,routing") +@XmlRootElement(name = "toServiceConfiguration") +@XmlAccessorType(XmlAccessType.FIELD) +public class ServiceCallConfigurationDefinition extends IdentifiedType { + + @XmlTransient + private ServiceCallDefinition parent; + @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; + + public ServiceCallConfigurationDefinition() { + } + + public ServiceCallConfigurationDefinition(ServiceCallDefinition parent) { + this.parent = parent; + } + + // Getter/Setter + // ------------------------------------------------------------------------- + + 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; + } + + + // Fluent API + // ------------------------------------------------------------------------- + + /** + * 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; + } + + /** + * End of configuration + */ + public ServiceCallDefinition end() { + return parent; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/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 new file mode 100644 index 0000000..7b2d1a5 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/ServiceCallDefinition.java @@ -0,0 +1,201 @@ +/** + * 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 org.apache.camel.ExchangePattern; +import org.apache.camel.Processor; +import org.apache.camel.spi.Metadata; +import org.apache.camel.spi.RouteContext; + +@Metadata(label = "eip,routing") +@XmlRootElement(name = "serviceCall") +@XmlAccessorType(XmlAccessType.FIELD) +public class ServiceCallDefinition extends NoOutputDefinition<ServiceCallDefinition> { + + // TODO: load balancing strategy + + @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 discovery; + @XmlAttribute + private String serviceCallConfigurationRef; + + public ServiceCallDefinition() { + } + + // serviceCall("myService") (will use http by default) + // serviceCall("myService/foo") (will use http by default) + // serviceCall("http:myService/foo") + // serviceCall("myService", "http:myService.host:myService.port/foo") + // serviceCall("myService", "netty4:tcp:myService?connectTimeout=1000") + + @Override + public String toString() { + return "ServiceCall[" + name + "]"; + } + + @Override + public String getLabel() { + return "serviceCall"; + } + + @Override + public Processor createProcessor(RouteContext routeContext) throws Exception { + if (discovery != null) { + throw new IllegalStateException("Cannot find Camel component on the classpath implementing the discovery provider: " + discovery); + } else { + throw new IllegalStateException("Cannot find Camel component supporting the ToService EIP. Add camel-kubernetes if you are using Kubernetes."); + } + } + + // 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 discovery provided to use. + * <p/> + * Use kubernetes to use kubernetes. + * Use ribbon to use ribbon. + */ + public ServiceCallDefinition discovery(String discovery) { + setDiscovery(discovery); + return this; + } + + 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; + } + + // 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 String getDiscovery() { + return discovery; + } + + public void setDiscovery(String discovery) { + this.discovery = discovery; + } + + 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; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/camel-core/src/main/java/org/apache/camel/model/ToServiceConfigurationDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/ToServiceConfigurationDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ToServiceConfigurationDefinition.java deleted file mode 100644 index f42205e..0000000 --- a/camel-core/src/main/java/org/apache/camel/model/ToServiceConfigurationDefinition.java +++ /dev/null @@ -1,326 +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.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import org.apache.camel.spi.Metadata; - -@Metadata(label = "eip,routing") -@XmlRootElement(name = "toServiceConfiguration") -@XmlAccessorType(XmlAccessType.FIELD) -public class ToServiceConfigurationDefinition extends IdentifiedType { - - @XmlTransient - private ToServiceDefinition parent; - @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; - - public ToServiceConfigurationDefinition() { - } - - public ToServiceConfigurationDefinition(ToServiceDefinition parent) { - this.parent = parent; - } - - // Getter/Setter - // ------------------------------------------------------------------------- - - 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; - } - - - // Fluent API - // ------------------------------------------------------------------------- - - /** - * Sets the URL to the master - */ - public ToServiceConfigurationDefinition masterUrl(String masterUrl) { - setMasterUrl(masterUrl); - return this; - } - - /** - * Sets the namespace to use - */ - public ToServiceConfigurationDefinition namespace(String namespace) { - setNamespace(namespace); - return this; - } - - /** - * Sets the API version - */ - public ToServiceConfigurationDefinition apiVersion(String apiVersion) { - setApiVersion(apiVersion); - return this; - } - - /** - * Sets the username for authentication - */ - public ToServiceConfigurationDefinition username(String username) { - setUsername(username); - return this; - } - - /** - * Sets the password for authentication - */ - public ToServiceConfigurationDefinition password(String password) { - setPassword(password); - return this; - } - - /** - * Sets the OAUTH token for authentication (instead of username/password) - */ - public ToServiceConfigurationDefinition oauthToken(String oauthToken) { - setOauthToken(oauthToken); - return this; - } - - /** - * Sets the Certificate Authority data - */ - public ToServiceConfigurationDefinition caCertData(String caCertData) { - setCaCertData(caCertData); - return this; - } - - /** - * Sets the Certificate Authority data that are loaded from the file - */ - public ToServiceConfigurationDefinition caCertFile(String caCertFile) { - setCaCertFile(caCertFile); - return this; - } - - /** - * Sets the Client Certificate data - */ - public ToServiceConfigurationDefinition clientCertData(String clientCertData) { - setClientCertData(clientCertData); - return this; - } - - /** - * Sets the Client Certificate data that are loaded from the file - */ - public ToServiceConfigurationDefinition clientCertFile(String clientCertFile) { - setClientCertFile(clientCertFile); - return this; - } - - /** - * Sets the Client Keystore algorithm, such as RSA. - */ - public ToServiceConfigurationDefinition clientKeyAlgo(String clientKeyAlgo) { - setClientKeyAlgo(clientKeyAlgo); - return this; - } - - /** - * Sets the Client Keystore data - */ - public ToServiceConfigurationDefinition clientKeyData(String clientKeyData) { - setClientKeyData(clientKeyData); - return this; - } - - /** - * Sets the Client Keystore data that are loaded from the file - */ - public ToServiceConfigurationDefinition clientKeyFile(String clientKeyFile) { - setClientKeyFile(clientKeyFile); - return this; - } - - /** - * Sets the Client Keystore passphrase - */ - public ToServiceConfigurationDefinition clientKeyPassphrase(String clientKeyPassphrase) { - setClientKeyPassphrase(clientKeyPassphrase); - return this; - } - - /** - * Sets whether to turn on trust certificate check - */ - public ToServiceConfigurationDefinition trustCerts(boolean trustCerts) { - setTrustCerts(trustCerts); - return this; - } - - /** - * End of configuration - */ - public ToServiceDefinition end() { - return parent; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/camel-core/src/main/java/org/apache/camel/model/ToServiceDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/ToServiceDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ToServiceDefinition.java deleted file mode 100644 index 1c5dfc4..0000000 --- a/camel-core/src/main/java/org/apache/camel/model/ToServiceDefinition.java +++ /dev/null @@ -1,201 +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 org.apache.camel.ExchangePattern; -import org.apache.camel.Processor; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.RouteContext; - -@Metadata(label = "eip,routing") -@XmlRootElement(name = "toService") -@XmlAccessorType(XmlAccessType.FIELD) -public class ToServiceDefinition extends NoOutputDefinition<ToServiceDefinition> { - - // TODO: load balancing strategy - - @XmlElement - private ToServiceConfigurationDefinition toServiceConfiguration; - @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 discovery; - @XmlAttribute - private String toServiceConfigurationRef; - - public ToServiceDefinition() { - } - - // toService("myService") (will use http by default) - // toService("myService/foo") (will use http by default) - // toService("http:myService/foo") - // toService("myService", "http:myService.host:myService.port/foo") - // toService("myService", "netty4:tcp:myService?connectTimeout=1000") - - @Override - public String toString() { - return "ToService[" + name + "]"; - } - - @Override - public String getLabel() { - return "toService"; - } - - @Override - public Processor createProcessor(RouteContext routeContext) throws Exception { - if (discovery != null) { - throw new IllegalStateException("Cannot find Camel component on the classpath implementing the discovery provider: " + discovery); - } else { - throw new IllegalStateException("Cannot find Camel component supporting the ToService EIP. Add camel-kubernetes if you are using Kubernetes."); - } - } - - // Fluent API - // ------------------------------------------------------------------------- - - /** - * Sets the optional {@link ExchangePattern} used to invoke this endpoint - */ - public ToServiceDefinition pattern(ExchangePattern pattern) { - setPattern(pattern); - return this; - } - - /** - * Sets the namespace of the service to use - */ - public ToServiceDefinition namespace(String namespace) { - setNamespace(namespace); - return this; - } - - /** - * Sets the name of the service to use - */ - public ToServiceDefinition name(String name) { - setName(name); - return this; - } - - /** - * Sets the discovery provided to use. - * <p/> - * Use kubernetes to use kubernetes. - * Use ribbon to use ribbon. - */ - public ToServiceDefinition discovery(String discovery) { - setDiscovery(discovery); - return this; - } - - public ToServiceConfigurationDefinition toServiceConfiguration() { - toServiceConfiguration = new ToServiceConfigurationDefinition(this); - return toServiceConfiguration; - } - - /** - * Configures the Hystrix EIP using the given configuration - */ - public ToServiceDefinition toServiceConfiguration(ToServiceConfigurationDefinition configuration) { - toServiceConfiguration = configuration; - return this; - } - - /** - * Refers to a Hystrix configuration to use for configuring the Hystrix EIP. - */ - public ToServiceDefinition toServiceConfiguration(String ref) { - toServiceConfigurationRef = ref; - 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 String getDiscovery() { - return discovery; - } - - public void setDiscovery(String discovery) { - this.discovery = discovery; - } - - public ToServiceConfigurationDefinition getToServiceConfiguration() { - return toServiceConfiguration; - } - - public void setToServiceConfiguration(ToServiceConfigurationDefinition toServiceConfiguration) { - this.toServiceConfiguration = toServiceConfiguration; - } - - public String getToServiceConfigurationRef() { - return toServiceConfigurationRef; - } - - public void setToServiceConfigurationRef(String toServiceConfigurationRef) { - this.toServiceConfigurationRef = toServiceConfigurationRef; - } - - 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; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/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 549557f..18892e0 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,6 +74,8 @@ RoutesDefinition RoutingSlipDefinition SamplingDefinition ScriptDefinition +ServiceCallDefinition +ServiceCallConfigurationDefinition SetBodyDefinition SetExchangePatternDefinition SetFaultBodyDefinition @@ -89,8 +91,6 @@ ThrottleDefinition ThrowExceptionDefinition ToDefinition ToDynamicDefinition -ToServiceDefinition -ToServiceConfigurationDefinition TransactedDefinition TransformDefinition TryDefinition http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/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 104ace7..2cc103d 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 @@ -23,8 +23,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.ToServiceConfigurationDefinition; -import org.apache.camel.model.ToServiceDefinition; +import org.apache.camel.model.ServiceCallConfigurationDefinition; +import org.apache.camel.model.ServiceCallDefinition; import org.apache.camel.spi.ProcessorFactory; import org.apache.camel.spi.RouteContext; import org.apache.camel.util.CamelContextHelper; @@ -40,8 +40,8 @@ public class KubernetesProcessorFactory implements ProcessorFactory { @Override public Processor createProcessor(RouteContext routeContext, ProcessorDefinition<?> definition) throws Exception { - if (definition instanceof ToServiceDefinition) { - ToServiceDefinition ts = (ToServiceDefinition) definition; + if (definition instanceof ServiceCallDefinition) { + ServiceCallDefinition ts = (ServiceCallDefinition) definition; // discovery must either not be set, or if set then must be us if (ts.getDiscovery() != null && !"kubernetes".equals(ts.getDiscovery())) { @@ -53,10 +53,10 @@ public class KubernetesProcessorFactory implements ProcessorFactory { String uri = ts.getUri(); ExchangePattern mep = ts.getPattern(); - ToServiceConfigurationDefinition config = ts.getToServiceConfiguration(); - ToServiceConfigurationDefinition configRef = null; - if (ts.getToServiceConfigurationRef() != null) { - configRef = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), ts.getToServiceConfigurationRef(), ToServiceConfigurationDefinition.class); + ServiceCallConfigurationDefinition config = ts.getServiceCallConfiguration(); + ServiceCallConfigurationDefinition configRef = null; + if (ts.getServiceCallConfigurationRef() != null) { + configRef = CamelContextHelper.mandatoryLookup(routeContext.getCamelContext(), ts.getServiceCallConfigurationRef(), ServiceCallConfigurationDefinition.class); } // extract the properties from the configuration from the model http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesServiceDiscovery.java ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesServiceDiscovery.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesServiceDiscovery.java index 42f7002..ce870c9 100644 --- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesServiceDiscovery.java +++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesServiceDiscovery.java @@ -23,7 +23,6 @@ import io.fabric8.kubernetes.api.model.EndpointAddress; import io.fabric8.kubernetes.api.model.EndpointPort; import io.fabric8.kubernetes.api.model.EndpointSubset; import io.fabric8.kubernetes.api.model.Endpoints; -import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.openshift.client.OpenShiftClient; import org.apache.camel.support.ServiceSupport; import org.apache.camel.util.IOHelper; http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesServiceProcessor.java ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesServiceProcessor.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesServiceProcessor.java index d9bfd5b..a07c047 100644 --- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesServiceProcessor.java +++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/processor/KubernetesServiceProcessor.java @@ -136,6 +136,7 @@ public class KubernetesServiceProcessor extends ServiceSupport implements AsyncP } private OpenShiftClient createKubernetesClient() { + // TODO: need to use OpenShiftClient until fabric8-client can auto detect OS vs Kube environment LOG.debug("Create Kubernetes client with the following Configuration: " + configuration.toString()); ConfigBuilder builder = new ConfigBuilder(); http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/model/ServiceCallDefinition ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/model/ServiceCallDefinition b/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/model/ServiceCallDefinition new file mode 100644 index 0000000..acf5be8 --- /dev/null +++ b/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/model/ServiceCallDefinition @@ -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. +# + +class=org.apache.camel.component.kubernetes.processor.KubernetesProcessorFactory http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/model/ToServiceDefinition ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/model/ToServiceDefinition b/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/model/ToServiceDefinition deleted file mode 100644 index acf5be8..0000000 --- a/components/camel-kubernetes/src/main/resources/META-INF/services/org/apache/camel/model/ToServiceDefinition +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.component.kubernetes.processor.KubernetesProcessorFactory http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/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 new file mode 100644 index 0000000..6595b48 --- /dev/null +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/ServiceCallRouteTest.java @@ -0,0 +1,54 @@ +/** + * 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.component.kubernetes.processor; + +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.ServiceCallConfigurationDefinition; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class ServiceCallRouteTest extends CamelTestSupport { + + @Test + public void testServiceCall() throws Exception { + getMockEndpoint("mock:result").expectedMessageCount(1); + + template.sendBody("direct:start", "Hello World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RoutesBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + ServiceCallConfigurationDefinition config = new ServiceCallConfigurationDefinition(); + config.setMasterUrl("https://fabric8-master.vagrant.f8:8443"); + config.setUsername("admin"); + config.setPassword("admin"); +// config.setOauthToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImZhYnJpYzgtdG9rZW4tZzNsdGoiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZmFicmljOCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImU0NGJhYzA0LWZmYjQtMTFlNS05MWM0LTA4MDAyN2I1YzJmNCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpkZWZhdWx0OmZhYnJpYzgifQ.yqhevtuqliAV7RlRhaSjG8oFSOn2V1vfmj5V9JKpaOCWbWXMYS0y_v4QPfI4vIGsJtpZgasrt-8brkiOkq7zx0BJxVm-Ae5QIE1uJNeWFYcno823SUV2ebHykhp0eUEtCmWtHByBIoTTF8dG3NZ6jWow7KVGN289Y2ryi8QoYupfQ9ABddVVcduolStIqBu3pu-dJqIvlt6L8wE6AHfhS4uSaPwcimbs5hrg6gB_iONCSCSayhOyiT6fNlXdpxndRRBg9MP3X3f4dD3kDyHE0860HzqZ05jFIwGfV_rbFJeNY3SLDQNO_QFXqUZKg01OH-OJaqDSjuV48P9b6n4uHA"); + config.setNamespace("default"); + + from("direct:start") + .serviceCall("cdi-camel-jetty", "http:cdi-camel-jetty", config) + .to("mock:result"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/8121da71/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/ToServiceRouteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/ToServiceRouteTest.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/ToServiceRouteTest.java deleted file mode 100644 index a7d51fc..0000000 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/processor/ToServiceRouteTest.java +++ /dev/null @@ -1,54 +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 - * <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.component.kubernetes.processor; - -import org.apache.camel.RoutesBuilder; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.model.ToServiceConfigurationDefinition; -import org.apache.camel.test.junit4.CamelTestSupport; -import org.junit.Test; - -public class ToServiceRouteTest extends CamelTestSupport { - - @Test - public void testToService() throws Exception { - getMockEndpoint("mock:result").expectedMessageCount(1); - - template.sendBody("direct:start", "Hello World"); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RoutesBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - ToServiceConfigurationDefinition config = new ToServiceConfigurationDefinition(); - config.setMasterUrl("https://fabric8-master.vagrant.f8:8443"); - config.setUsername("admin"); - config.setPassword("admin"); -// config.setOauthToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImZhYnJpYzgtdG9rZW4tZzNsdGoiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZmFicmljOCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImU0NGJhYzA0LWZmYjQtMTFlNS05MWM0LTA4MDAyN2I1YzJmNCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpkZWZhdWx0OmZhYnJpYzgifQ.yqhevtuqliAV7RlRhaSjG8oFSOn2V1vfmj5V9JKpaOCWbWXMYS0y_v4QPfI4vIGsJtpZgasrt-8brkiOkq7zx0BJxVm-Ae5QIE1uJNeWFYcno823SUV2ebHykhp0eUEtCmWtHByBIoTTF8dG3NZ6jWow7KVGN289Y2ryi8QoYupfQ9ABddVVcduolStIqBu3pu-dJqIvlt6L8wE6AHfhS4uSaPwcimbs5hrg6gB_iONCSCSayhOyiT6fNlXdpxndRRBg9MP3X3f4dD3kDyHE0860HzqZ05jFIwGfV_rbFJeNY3SLDQNO_QFXqUZKg01OH-OJaqDSjuV48P9b6n4uHA"); - config.setNamespace("default"); - - from("direct:start") - .toService("cdi-camel-jetty", "http:cdi-camel-jetty", config) - .to("mock:result"); - } - }; - } -}