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 2019/12/11 09:36:57 UTC

[camel] branch master updated (0653f9c -> c0ee244)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 0653f9c  CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - JBPM component
     new 99214b2  CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - jclouds component
     new c0ee244  CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - jira component

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/component/jclouds/JcloudsComponent.java  |  1 -
 .../camel-jira/src/main/docs/jira-component.adoc   |  2 +-
 .../apache/camel/component/jira/JiraComponent.java | 12 ++++--------
 .../camel/component/jira/JiraConfiguration.java    | 11 ++++++++++-
 .../apache/camel/component/jira/JiraEndpoint.java  | 22 +++++++++-------------
 .../jira/JiraComponentConfigurationTest.java       | 18 ++++++++++--------
 .../springboot/JiraComponentConfiguration.java     |  2 +-
 7 files changed, 35 insertions(+), 33 deletions(-)


[camel] 02/02: CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - jira component

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit c0ee2447eb42a8fa8a9258a09901c4d70688a866
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 11 10:36:32 2019 +0100

    CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - jira component
---
 .../camel-jira/src/main/docs/jira-component.adoc   |  2 +-
 .../apache/camel/component/jira/JiraComponent.java | 12 ++++--------
 .../camel/component/jira/JiraConfiguration.java    | 11 ++++++++++-
 .../apache/camel/component/jira/JiraEndpoint.java  | 22 +++++++++-------------
 .../jira/JiraComponentConfigurationTest.java       | 18 ++++++++++--------
 .../springboot/JiraComponentConfiguration.java     |  2 +-
 6 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/components/camel-jira/src/main/docs/jira-component.adoc b/components/camel-jira/src/main/docs/jira-component.adoc
index 6cd07a3..860429b 100644
--- a/components/camel-jira/src/main/docs/jira-component.adoc
+++ b/components/camel-jira/src/main/docs/jira-component.adoc
@@ -53,7 +53,7 @@ The Jira component supports 4 options, which are listed below.
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *configuration* (advanced) | The JiraConfiguration parameters |  | JiraConfiguration
+| *configuration* (advanced) | To use a shared base jira configuration. |  | JiraConfiguration
 | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
diff --git a/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraComponent.java b/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraComponent.java
index 3fff581..4f7cc68 100644
--- a/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraComponent.java
+++ b/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraComponent.java
@@ -24,9 +24,6 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.annotations.Component;
 import org.apache.camel.support.DefaultComponent;
 
-/**
- * Represents the component that manages {@link JiraEndpoint}.
- */
 @Component("jira")
 public class JiraComponent extends DefaultComponent {
 
@@ -39,22 +36,21 @@ public class JiraComponent extends DefaultComponent {
 
     public JiraComponent(CamelContext context) {
         super(context);
-        configuration = new JiraConfiguration();
         registerExtension(new JiraVerifierExtension());
     }
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        // override configuration from route parameters
-        setProperties(configuration, parameters);
+        JiraConfiguration config = configuration != null ? configuration.copy() : new JiraConfiguration();
 
-        JiraEndpoint endpoint = new JiraEndpoint(uri, this, configuration);
+        JiraEndpoint endpoint = new JiraEndpoint(uri, this, config);
         endpoint.setType(getCamelContext().getTypeConverter().convertTo(JiraType.class, remaining));
+        setProperties(endpoint, parameters);
         return endpoint;
     }
 
     /**
-     * The JiraConfiguration parameters
+     * To use a shared base jira configuration.
      */
     public JiraConfiguration getConfiguration() {
         return configuration;
diff --git a/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraConfiguration.java b/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraConfiguration.java
index bbf4a7e..2fa2c9e 100644
--- a/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraConfiguration.java
+++ b/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraConfiguration.java
@@ -16,12 +16,13 @@
  */
 package org.apache.camel.component.jira;
 
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 
 @UriParams
-public class JiraConfiguration {
+public class JiraConfiguration implements Cloneable {
 
     @UriParam(label = "security", secret = true)
     private String verificationCode;
@@ -137,4 +138,12 @@ public class JiraConfiguration {
     public void setPassword(String password) {
         this.password = password;
     }
+
+    public JiraConfiguration copy() {
+        try {
+            return (JiraConfiguration)super.clone();
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
 }
diff --git a/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraEndpoint.java b/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraEndpoint.java
index 3fe027e..a7ae9d9 100644
--- a/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraEndpoint.java
+++ b/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraEndpoint.java
@@ -68,17 +68,14 @@ public class JiraEndpoint extends DefaultEndpoint {
     @UriPath
     @Metadata(required = true)
     private JiraType type;
-
     @UriParam(label = "consumer")
     private String jql;
-
     @UriParam(label = "consumer", defaultValue = "50")
     private Integer maxResults = 50;
-
     @UriParam
     private JiraConfiguration configuration;
 
-    private JiraRestClient client;
+    private transient JiraRestClient client;
 
     public JiraEndpoint(String uri, JiraComponent component, JiraConfiguration configuration) {
         super(uri, component);
@@ -142,18 +139,17 @@ public class JiraEndpoint extends DefaultEndpoint {
     }
 
     @Override
-    public Consumer createConsumer(Processor processor) {
+    public Consumer createConsumer(Processor processor) throws Exception {
+        Consumer consumer;
         if (type == JiraType.NEWCOMMENTS) {
-            return new NewCommentsConsumer(this, processor);
+            consumer = new NewCommentsConsumer(this, processor);
         } else if (type == JiraType.NEWISSUES) {
-            return new NewIssuesConsumer(this, processor);
+            consumer = new NewIssuesConsumer(this, processor);
+        } else {
+            throw new IllegalArgumentException("Consumer does not support type: " + type);
         }
-        throw new IllegalArgumentException("Consumer does not support type: " + type);
-    }
-
-    @Override
-    public boolean isSingleton() {
-        return true;
+        configureConsumer(consumer);
+        return consumer;
     }
 
     public JiraType getType() {
diff --git a/components/camel-jira/src/test/java/org/apache/camel/component/jira/JiraComponentConfigurationTest.java b/components/camel-jira/src/test/java/org/apache/camel/component/jira/JiraComponentConfigurationTest.java
index 475cb0e..41c5211 100644
--- a/components/camel-jira/src/test/java/org/apache/camel/component/jira/JiraComponentConfigurationTest.java
+++ b/components/camel-jira/src/test/java/org/apache/camel/component/jira/JiraComponentConfigurationTest.java
@@ -41,6 +41,7 @@ public class JiraComponentConfigurationTest extends CamelTestSupport {
     @Test
     public void createEndpointWithBasicAuthentication() throws Exception {
         JiraComponent component = new JiraComponent(context);
+        component.start();
         String query = Joiner.on("&").join(
                 concat(JIRA_URL, JIRA_URL_VALUE),
                 concat(USERNAME, USERNAME_VALUE),
@@ -49,14 +50,15 @@ public class JiraComponentConfigurationTest extends CamelTestSupport {
         JiraEndpoint endpoint = (JiraEndpoint) component.createEndpoint("jira://newIssues?" + query);
 
         assertEquals("newissues", endpoint.getType().name().toLowerCase());
-        assertEquals(JIRA_URL_VALUE, component.getConfiguration().getJiraUrl());
-        assertEquals(USERNAME_VALUE, component.getConfiguration().getUsername());
-        assertEquals(PASSWORD_VALUE, component.getConfiguration().getPassword());
+        assertEquals(JIRA_URL_VALUE, endpoint.getConfiguration().getJiraUrl());
+        assertEquals(USERNAME_VALUE, endpoint.getConfiguration().getUsername());
+        assertEquals(PASSWORD_VALUE, endpoint.getConfiguration().getPassword());
     }
 
     @Test
     public void createEndpointWithOAuthentication() throws Exception {
         JiraComponent component = new JiraComponent(context);
+        component.start();
         String query = Joiner.on("&").join(
                 concat(JIRA_URL, JIRA_URL_VALUE),
                 concat(VERIF_CODE, VERIF_CODE_VALUE),
@@ -67,11 +69,11 @@ public class JiraComponentConfigurationTest extends CamelTestSupport {
         JiraEndpoint endpoint = (JiraEndpoint) component.createEndpoint("jira://newComments?" + query);
 
         assertEquals("newcomments", endpoint.getType().name().toLowerCase());
-        assertEquals(JIRA_URL_VALUE, component.getConfiguration().getJiraUrl());
-        assertEquals(VERIF_CODE_VALUE, component.getConfiguration().getVerificationCode());
-        assertEquals(ACCESS_TOKEN_VALUE, component.getConfiguration().getAccessToken());
-        assertEquals(CONS_KEY_VALUE, component.getConfiguration().getConsumerKey());
-        assertEquals(PRIV_KEY_VALUE, component.getConfiguration().getPrivateKey());
+        assertEquals(JIRA_URL_VALUE, endpoint.getConfiguration().getJiraUrl());
+        assertEquals(VERIF_CODE_VALUE, endpoint.getConfiguration().getVerificationCode());
+        assertEquals(ACCESS_TOKEN_VALUE, endpoint.getConfiguration().getAccessToken());
+        assertEquals(CONS_KEY_VALUE, endpoint.getConfiguration().getConsumerKey());
+        assertEquals(PRIV_KEY_VALUE, endpoint.getConfiguration().getPrivateKey());
     }
 
     private String concat(String key, String val) {
diff --git a/platforms/spring-boot/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentConfiguration.java
index b344fe7..3c7df5a 100644
--- a/platforms/spring-boot/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentConfiguration.java
@@ -37,7 +37,7 @@ public class JiraComponentConfiguration
      */
     private Boolean enabled;
     /**
-     * The JiraConfiguration parameters
+     * To use a shared base jira configuration.
      */
     private JiraConfigurationNestedConfiguration configuration;
     /**


[camel] 01/02: CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - jclouds component

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 99214b2cd63d64d26ea11067228977b9c5c5c22b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 11 10:30:29 2019 +0100

    CAMEL-14284: Configuring endpoint should set properties on endpoint and not configuration object - jclouds component
---
 .../main/java/org/apache/camel/component/jclouds/JcloudsComponent.java   | 1 -
 1 file changed, 1 deletion(-)

diff --git a/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java b/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
index 752a150..b4eb8b8 100644
--- a/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
+++ b/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
@@ -52,7 +52,6 @@ public class JcloudsComponent extends DefaultComponent {
         JcloudsConfiguration configuration = new JcloudsConfiguration();
         configuration.setCommand(command);
         configuration.setProviderId(providerId);
-        setProperties(configuration, parameters);
 
         JcloudsEndpoint endpoint;
         if (JcloudsCommand.blobstore == command) {