You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/03/19 09:43:22 UTC
[2/5] camel git commit: CAMEL-10160 reflected review comments
CAMEL-10160 reflected review comments
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/20b54ae5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/20b54ae5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/20b54ae5
Branch: refs/heads/master
Commit: 20b54ae5a820b0316778cd76fc1592198e04973d
Parents: a0a2c99
Author: Tomohisa Igarashi <tm...@gmail.com>
Authored: Fri Mar 17 23:15:32 2017 +0900
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Mar 19 09:57:48 2017 +0100
----------------------------------------------------------------------
components/camel-git/pom.xml | 26 ++++++++-----
components/camel-github/pom.xml | 26 ++++++++-----
components/camel-influxdb/pom.xml | 26 ++++++++-----
components/camel-jira/pom.xml | 26 ++++++++-----
components/camel-nats/pom.xml | 26 ++++++++-----
components/camel-zendesk/pom.xml | 28 +++++++------
.../src/main/docs/zendesk-component.adoc | 3 +-
.../component/zendesk/ZendeskComponent.java | 24 +++++-------
.../component/zendesk/ZendeskConfiguration.java | 26 +++++++++++++
.../component/zendesk/ZendeskEndpoint.java | 22 +++++++----
.../zendesk/AbstractZendeskTestSupport.java | 41 +++++++++++++++-----
.../ZendeskComponentConfiguration.java | 15 +++++++
12 files changed, 196 insertions(+), 93 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-git/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-git/pom.xml b/components/camel-git/pom.xml
index ee6a8fc..4a061bc 100644
--- a/components/camel-git/pom.xml
+++ b/components/camel-git/pom.xml
@@ -1,14 +1,20 @@
<?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. -->
+<!--
+ 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.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-github/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-github/pom.xml b/components/camel-github/pom.xml
index 68fd7a8..b0cdd7f 100644
--- a/components/camel-github/pom.xml
+++ b/components/camel-github/pom.xml
@@ -1,14 +1,20 @@
<?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. -->
+<!--
+ 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.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-influxdb/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-influxdb/pom.xml b/components/camel-influxdb/pom.xml
index 4856738..ed74bcc 100644
--- a/components/camel-influxdb/pom.xml
+++ b/components/camel-influxdb/pom.xml
@@ -1,14 +1,20 @@
<?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. -->
+<!--
+ 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.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-jira/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-jira/pom.xml b/components/camel-jira/pom.xml
index b056fe7..fec024b 100644
--- a/components/camel-jira/pom.xml
+++ b/components/camel-jira/pom.xml
@@ -1,14 +1,20 @@
<?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. -->
+<!--
+ 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.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-nats/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-nats/pom.xml b/components/camel-nats/pom.xml
index f56cd5b..c1228cd 100644
--- a/components/camel-nats/pom.xml
+++ b/components/camel-nats/pom.xml
@@ -1,14 +1,20 @@
<?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. -->
+<!--
+ 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.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-zendesk/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-zendesk/pom.xml b/components/camel-zendesk/pom.xml
index 9271d51..4532e6a 100644
--- a/components/camel-zendesk/pom.xml
+++ b/components/camel-zendesk/pom.xml
@@ -1,14 +1,20 @@
<?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. -->
+<!--
+ 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.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -42,13 +48,11 @@
<dependency>
<groupId>com.cloudbees.thirdparty</groupId>
<artifactId>zendesk-java-client</artifactId>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>com.cloudbees.thirdparty</groupId>
<artifactId>zendesk-java-client</artifactId>
<classifier>javadoc</classifier>
- <scope>provided</scope>
</dependency>
<!-- testing -->
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-zendesk/src/main/docs/zendesk-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-zendesk/src/main/docs/zendesk-component.adoc b/components/camel-zendesk/src/main/docs/zendesk-component.adoc
index 8161b10..6a42d90 100644
--- a/components/camel-zendesk/src/main/docs/zendesk-component.adoc
+++ b/components/camel-zendesk/src/main/docs/zendesk-component.adoc
@@ -21,7 +21,7 @@ for this component:
### Zendesk Options
// component options: START
-The Zendesk component supports 2 options which are listed below.
+The Zendesk component supports 3 options which are listed below.
@@ -29,6 +29,7 @@ The Zendesk component supports 2 options which are listed below.
|=======================================================================
| Name | Group | Default | Java Type | Description
| configuration | common | | ZendeskConfiguration | To use the shared configuration
+| zendesk | advanced | | Zendesk | To use a shared Zendesk instance.
| resolvePropertyPlaceholders | advanced | true | boolean | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders.
|=======================================================================
// component options: END
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskComponent.java b/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskComponent.java
index f1bc681..c52366c 100644
--- a/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskComponent.java
+++ b/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskComponent.java
@@ -25,6 +25,7 @@ import org.apache.camel.component.zendesk.internal.ZendeskApiName;
import org.apache.camel.component.zendesk.internal.ZendeskHelper;
import org.apache.camel.impl.DefaultComponent;
import org.apache.camel.spi.Metadata;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.component.AbstractApiComponent;
import org.zendesk.client.v2.Zendesk;
@@ -74,6 +75,10 @@ public class ZendeskComponent extends AbstractApiComponent<ZendeskApiName, Zende
return zendesk;
}
+ public void setZendesk(Zendesk zendesk) {
+ this.zendesk = zendesk;
+ }
+
@Override
protected Endpoint createEndpoint(String uri, String methodName, ZendeskApiName apiName,
ZendeskConfiguration endpointConfiguration) {
@@ -85,29 +90,20 @@ public class ZendeskComponent extends AbstractApiComponent<ZendeskApiName, Zende
protected void doStart() throws Exception {
super.doStart();
- if (zendesk == null) {
- if (configuration != null) {
- zendesk = ZendeskHelper.create(configuration);
- } else {
- throw new IllegalArgumentException("Unable to connect, Zendesk component configuration is missing");
- }
+ if (zendesk == null && configuration != null) {
+ zendesk = ZendeskHelper.create(configuration);
}
}
@Override
protected void doStop() throws Exception {
- if (zendesk != null) {
- zendesk.close();
- zendesk = null;
- }
+ IOHelper.close(zendesk);
+ super.doStop();
}
@Override
public void doShutdown() throws Exception {
- if (zendesk != null) {
- zendesk.close();
- zendesk = null;
- }
+ IOHelper.close(zendesk);
super.doShutdown();
}
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskConfiguration.java b/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskConfiguration.java
index 6c3a588..15c755d 100644
--- a/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskConfiguration.java
+++ b/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskConfiguration.java
@@ -24,6 +24,7 @@ import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.ObjectHelper;
/**
* Component configuration for Zendesk component.
@@ -156,4 +157,29 @@ public class ZendeskConfiguration {
public void setPassword(String password) {
this.password = password;
}
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof ZendeskConfiguration) {
+ ZendeskConfiguration otherZendeskConf = (ZendeskConfiguration)other;
+ return ObjectHelper.equal(methodName, otherZendeskConf.getMethodName())
+ && ObjectHelper.equal(serverUrl, otherZendeskConf.getServerUrl())
+ && ObjectHelper.equal(username, otherZendeskConf.getUsername())
+ && ObjectHelper.equal(password, otherZendeskConf.getPassword())
+ && ObjectHelper.equal(token, otherZendeskConf.getToken())
+ && ObjectHelper.equal(oauthToken, otherZendeskConf.getOauthToken());
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("ZendeskConfiguration:[methodName=%s, serverUrl=%s, username=%s, password=%s, token=%s, oauthToken=%s]",
+ methodName, serverUrl, username, password, token, oauthToken);
+ }
+
+ @Override
+ public int hashCode() {
+ return toString().hashCode();
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskEndpoint.java b/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskEndpoint.java
index 3058020..5b44b1f 100644
--- a/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskEndpoint.java
+++ b/components/camel-zendesk/src/main/java/org/apache/camel/component/zendesk/ZendeskEndpoint.java
@@ -32,6 +32,7 @@ import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.component.AbstractApiEndpoint;
import org.apache.camel.util.component.ApiMethod;
@@ -78,10 +79,15 @@ public class ZendeskEndpoint extends AbstractApiEndpoint<ZendeskApiName, Zendesk
}
@Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ // verify configuration is valid
+ getZendesk();
+ }
+
+ @Override
public void doStop() throws Exception {
- if (apiProxy != null && !apiProxy.isClosed()) {
- apiProxy.close();
- }
+ IOHelper.close(apiProxy);
super.doStop();
}
@@ -96,9 +102,6 @@ public class ZendeskEndpoint extends AbstractApiEndpoint<ZendeskApiName, Zendesk
@Override
protected void afterConfigureProperties() {
- // create connection eagerly, a good way to validate configuration
- getZendesk();
-
}
@Override
@@ -108,8 +111,13 @@ public class ZendeskEndpoint extends AbstractApiEndpoint<ZendeskApiName, Zendesk
private Zendesk getZendesk() {
if (apiProxy == null) {
- apiProxy = ZendeskHelper.create(configuration);
+ if (getConfiguration().equals(getComponent().getConfiguration())) {
+ apiProxy = getComponent().getZendesk();
+ } else {
+ apiProxy = ZendeskHelper.create(getConfiguration());
+ }
}
return apiProxy;
}
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/AbstractZendeskTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/AbstractZendeskTestSupport.java b/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/AbstractZendeskTestSupport.java
index 9110a71..ddafa7f 100644
--- a/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/AbstractZendeskTestSupport.java
+++ b/components/camel-zendesk/src/test/java/org/apache/camel/component/zendesk/AbstractZendeskTestSupport.java
@@ -35,26 +35,49 @@ import org.apache.camel.util.IntrospectionSupport;
* </p>
*/
public class AbstractZendeskTestSupport extends CamelTestSupport {
- private static final String TEST_OPTIONS_PROPERTIES = "/test-options.properties";
+ public static final String TEST_OPTIONS_PROPERTIES = "/test-options.properties";
+ public static final String SYSPROP_ZENDESK_SERVER_URL = "zendesk.serverUrl";
+ public static final String SYSPROP_ZENDESK_USERNAME = "zendesk.username";
+ public static final String SYSPROP_ZENDESK_PASSWORD = "zendesk.password";
+ public static final String SYSPROP_ZENDESK_TOKEN = "zendesk.token";
+ public static final String SYSPROP_ZENDESK_OAUTH_TOKEN = "zendesk.oauthToken";
+ public static final String ENV_ZENDESK_SERVER_URL = "ZENDESK_SERVER_URL";
+ public static final String ENV_ZENDESK_USERNAME = "ZENDESK_SERVER_URL";
+ public static final String ENV_ZENDESK_PASSWORD = "zendesk.password";
+ public static final String ENV_ZENDESK_TOKEN = "zendesk.token";
+ public static final String ENV_ZENDESK_OAUTH_TOKEN = "zendesk.oauthToken";
@Override
protected CamelContext createCamelContext() throws Exception {
final CamelContext context = super.createCamelContext();
+ final ZendeskConfiguration configuration = new ZendeskConfiguration();
final Properties properties = new Properties();
try {
properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
+ Map<String, Object> options = new HashMap<String, Object>();
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ options.put(entry.getKey().toString(), entry.getValue());
+ }
+
+ IntrospectionSupport.setProperties(configuration, options);
} catch (Exception e) {
- throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()),
- e);
+ // ignore - system property or ENV may be supplied
}
- Map<String, Object> options = new HashMap<String, Object>();
- for (Map.Entry<Object, Object> entry : properties.entrySet()) {
- options.put(entry.getKey().toString(), entry.getValue());
+ configuration.setServerUrl(System.getenv(ENV_ZENDESK_SERVER_URL) != null ? System.getenv(ENV_ZENDESK_SERVER_URL) : configuration.getServerUrl());
+ configuration.setUsername(System.getenv(ENV_ZENDESK_USERNAME) != null ? System.getenv(ENV_ZENDESK_USERNAME) : configuration.getUsername());
+ configuration.setPassword(System.getenv(ENV_ZENDESK_PASSWORD) != null ? System.getenv(ENV_ZENDESK_PASSWORD) : configuration.getPassword());
+ configuration.setToken(System.getenv(ENV_ZENDESK_TOKEN) != null ? System.getenv(ENV_ZENDESK_TOKEN) : configuration.getToken());
+ configuration.setOauthToken(System.getenv(ENV_ZENDESK_OAUTH_TOKEN) != null ? System.getenv(ENV_ZENDESK_OAUTH_TOKEN) : configuration.getOauthToken());
+ configuration.setServerUrl(System.getProperty(SYSPROP_ZENDESK_SERVER_URL, configuration.getServerUrl()));
+ configuration.setUsername(System.getProperty(SYSPROP_ZENDESK_USERNAME, configuration.getUsername()));
+ configuration.setPassword(System.getProperty(SYSPROP_ZENDESK_PASSWORD, configuration.getPassword()));
+ configuration.setToken(System.getProperty(SYSPROP_ZENDESK_TOKEN, configuration.getToken()));
+ configuration.setOauthToken(System.getProperty(SYSPROP_ZENDESK_OAUTH_TOKEN, configuration.getOauthToken()));
+ if (configuration.getServerUrl() == null || configuration.getUsername() == null
+ || (configuration.getPassword() == null && configuration.getToken() == null && configuration.getOauthToken() == null)) {
+ throw new IllegalArgumentException("Zendesk configuration is missing");
}
- final ZendeskConfiguration configuration = new ZendeskConfiguration();
- IntrospectionSupport.setProperties(configuration, options);
-
// add ZendeskComponent to Camel context
final ZendeskComponent component = new ZendeskComponent(context);
component.setConfiguration(configuration);
http://git-wip-us.apache.org/repos/asf/camel/blob/20b54ae5/platforms/spring-boot/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentConfiguration.java
index 94b29e0..8fa7d00 100644
--- a/platforms/spring-boot/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentConfiguration.java
@@ -17,6 +17,8 @@
package org.apache.camel.component.zendesk.springboot;
import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.NestedConfigurationProperty;
+import org.zendesk.client.v2.Zendesk;
/**
* The zendesk endpoint interacts with the Zendesk server.
@@ -31,6 +33,11 @@ public class ZendeskComponentConfiguration {
*/
private ZendeskConfigurationNestedConfiguration configuration;
/**
+ * To use a shared Zendesk instance.
+ */
+ @NestedConfigurationProperty
+ private Zendesk zendesk;
+ /**
* Whether the component should resolve property placeholders on itself when
* starting. Only properties which are of String type can use property
* placeholders.
@@ -46,6 +53,14 @@ public class ZendeskComponentConfiguration {
this.configuration = configuration;
}
+ public Zendesk getZendesk() {
+ return zendesk;
+ }
+
+ public void setZendesk(Zendesk zendesk) {
+ this.zendesk = zendesk;
+ }
+
public Boolean getResolvePropertyPlaceholders() {
return resolvePropertyPlaceholders;
}