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 2014/06/14 09:10:42 UTC

[1/3] git commit: Fix for CAMEL-7507 Expose the component options for Camel JPA

Repository: camel
Updated Branches:
  refs/heads/master 0da7ade0b -> 65a6ffba8


Fix for CAMEL-7507 Expose the component options for Camel JPA


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b00f75e4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b00f75e4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b00f75e4

Branch: refs/heads/master
Commit: b00f75e426f96586e09cf0fb0c82a2ca038ca195
Parents: 0da7ade
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Fri Jun 13 14:56:42 2014 +0200
Committer: Kevin Earls <ke...@kevinearls.com>
Committed: Fri Jun 13 14:56:42 2014 +0200

----------------------------------------------------------------------
 .../camel/component/jpa/JpaComponent.java       |  8 ++-
 .../apache/camel/component/jpa/JpaEndpoint.java | 12 ++++
 ...ponentConfigurationAndDocumentationTest.java | 59 ++++++++++++++++++++
 3 files changed, 77 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b00f75e4/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaComponent.java b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaComponent.java
index 3b0cae5..c59b48a 100644
--- a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaComponent.java
+++ b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaComponent.java
@@ -20,7 +20,7 @@ import java.util.Map;
 import javax.persistence.EntityManagerFactory;
 
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
 import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,12 +32,16 @@ import org.springframework.transaction.support.TransactionTemplate;
  *
  * @version 
  */
-public class JpaComponent extends DefaultComponent {
+public class JpaComponent extends UriEndpointComponent {
     private static final Logger LOG = LoggerFactory.getLogger(JpaComponent.class);
     private EntityManagerFactory entityManagerFactory;
     private PlatformTransactionManager transactionManager;
     private boolean joinTransaction = true;
 
+    public JpaComponent() {
+        super(JpaEndpoint.class);
+    }
+
     // Properties
     //-------------------------------------------------------------------------
     public EntityManagerFactory getEntityManagerFactory() {

http://git-wip-us.apache.org/repos/asf/camel/blob/b00f75e4/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
index 2b3e17c..09e549d 100644
--- a/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
+++ b/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
@@ -29,6 +29,8 @@ import org.apache.camel.InvalidPayloadRuntimeException;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.ScheduledPollEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.ExpressionAdapter;
 import org.apache.camel.util.CastUtils;
 import org.apache.camel.util.IntrospectionSupport;
@@ -39,21 +41,31 @@ import org.springframework.transaction.PlatformTransactionManager;
 import org.springframework.transaction.TransactionDefinition;
 import org.springframework.transaction.support.TransactionTemplate;
 
+@UriEndpoint(scheme = "jpa", consumerClass = JpaConsumer.class)
 public class JpaEndpoint extends ScheduledPollEndpoint {
 
     private EntityManagerFactory entityManagerFactory;
     private PlatformTransactionManager transactionManager;
+    @UriParam
     private String persistenceUnit = "camel";
     private Expression producerExpression;
+    @UriParam
     private int maximumResults = -1;
     private Class<?> entityType;
     private Map<String, Object> entityManagerProperties;
+    @UriParam
     private boolean consumeDelete = true;
+    @UriParam
     private boolean consumeLockEntity = true;
+    @UriParam
     private boolean flushOnSend = true;
+    @UriParam
     private int maxMessagesPerPoll;
+    @UriParam
     private boolean usePersist;
+    @UriParam
     private boolean joinTransaction = true;
+    @UriParam
     private boolean usePassedInEntityManager;
 
     public JpaEndpoint() {

http://git-wip-us.apache.org/repos/asf/camel/blob/b00f75e4/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaComponentConfigurationAndDocumentationTest.java b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaComponentConfigurationAndDocumentationTest.java
new file mode 100644
index 0000000..6836ec4
--- /dev/null
+++ b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaComponentConfigurationAndDocumentationTest.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jpa;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ComponentConfiguration;
+import org.apache.camel.EndpointConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import javax.swing.*;
+
+public class JpaComponentConfigurationAndDocumentationTest extends CamelTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testComponentConfiguration() throws Exception {
+        JpaComponent comp = context.getComponent("jpa", JpaComponent.class);
+        EndpointConfiguration conf = comp.createConfiguration("jpa://org.apache.camel.examples.SendEmail" +
+                "?usePersist=true&persistenceUnit=custom");
+
+        assertEquals("true", conf.getParameter("usePersist"));
+        assertEquals("custom", conf.getParameter("persistenceUnit"));
+
+        ComponentConfiguration compConf = comp.createComponentConfiguration();
+        String json = compConf.createParameterJsonSchema();
+        assertNotNull(json);
+
+        assertTrue(json.contains("\"persistenceUnit\": { \"type\": \"java.lang.String\" }"));
+        assertTrue(json.contains("\"usePassedInEntityManager\": { \"type\": \"boolean\" }"));
+    }
+
+    @Test
+    public void testComponentDocumentation() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        String html = context.getComponentDocumentation("jpa");
+        assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+    }
+
+}


[3/3] git commit: Merge branch 'CAMEL-7508' of https://github.com/kevinearls/camel

Posted by da...@apache.org.
Merge branch 'CAMEL-7508' of https://github.com/kevinearls/camel


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/65a6ffba
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/65a6ffba
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/65a6ffba

Branch: refs/heads/master
Commit: 65a6ffba8ee63b23a92427880c8985916ea3b7a3
Parents: b00f75e 2be3d6f
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Jun 14 09:10:00 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Jun 14 09:10:00 2014 +0200

----------------------------------------------------------------------
 .../infinispan/InfinispanComponent.java         |  8 ++-
 .../infinispan/InfinispanConfiguration.java     |  7 +++
 .../infinispan/InfinispanEndpoint.java          |  4 ++
 ...ponentConfigurationAndDocumentationTest.java | 57 ++++++++++++++++++++
 4 files changed, 74 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[2/3] git commit: Fixes CAMEL-7508 Expose the component options for Camel Infinispan

Posted by da...@apache.org.
Fixes CAMEL-7508 Expose the component options for Camel Infinispan


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2be3d6f8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2be3d6f8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2be3d6f8

Branch: refs/heads/master
Commit: 2be3d6f8d8c77a7f26d608c2b5048438d3ac6424
Parents: 0da7ade
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Fri Jun 13 17:45:36 2014 +0200
Committer: Kevin Earls <ke...@kevinearls.com>
Committed: Fri Jun 13 17:45:36 2014 +0200

----------------------------------------------------------------------
 .../infinispan/InfinispanComponent.java         |  8 ++-
 .../infinispan/InfinispanConfiguration.java     |  7 +++
 .../infinispan/InfinispanEndpoint.java          |  4 ++
 ...ponentConfigurationAndDocumentationTest.java | 57 ++++++++++++++++++++
 4 files changed, 74 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2be3d6f8/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
index cb2a6c8..7547836 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanComponent.java
@@ -19,9 +19,13 @@ package org.apache.camel.component.infinispan;
 import java.util.Map;
 
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
 
-public class InfinispanComponent extends DefaultComponent {
+public class InfinispanComponent extends UriEndpointComponent {
+
+    public InfinispanComponent() {
+        super(InfinispanEndpoint.class);
+    }
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/2be3d6f8/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
index 187daf3..0c31a0c 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
@@ -20,13 +20,20 @@ import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
 import org.infinispan.commons.api.BasicCacheContainer;
 
+@UriParams
 public class InfinispanConfiguration {
     private BasicCacheContainer cacheContainer;
+    @UriParam
     private String cacheName;
+    @UriParam
     private String host;
+    @UriParam
     private String command;
+    @UriParam
     private boolean sync = true;
     private Set<String> eventTypes;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/2be3d6f8/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
index 8680c26..899f7fb 100644
--- a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
+++ b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
@@ -20,8 +20,12 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
 
+@UriEndpoint(scheme = "infinispan", consumerClass = InfinispanConsumer.class)
 public class InfinispanEndpoint extends DefaultEndpoint {
+    @UriParam
     private InfinispanConfiguration configuration;
 
     public InfinispanEndpoint() {

http://git-wip-us.apache.org/repos/asf/camel/blob/2be3d6f8/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentConfigurationAndDocumentationTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentConfigurationAndDocumentationTest.java
new file mode 100644
index 0000000..6f5d94a
--- /dev/null
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/InfinispanComponentConfigurationAndDocumentationTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.infinispan;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ComponentConfiguration;
+import org.apache.camel.EndpointConfiguration;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class InfinispanComponentConfigurationAndDocumentationTest extends CamelTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testComponentConfiguration() throws Exception {
+        InfinispanComponent comp = context.getComponent("infinispan", InfinispanComponent.class);
+        String configUri = "infinispan://localhost?cacheContainer=#cacheContainer&sync=false&eventTypes=CACHE_ENTRY_CREATED";
+        EndpointConfiguration conf = comp.createConfiguration(configUri);
+
+        assertEquals("localhost", conf.getParameter("host"));
+        assertEquals("cacheContainer=", conf.getParameter("query"));
+
+        ComponentConfiguration compConf = comp.createComponentConfiguration();
+        String json = compConf.createParameterJsonSchema();
+        assertNotNull(json);
+
+        assertTrue(json.contains("\"command\": { \"type\": \"java.lang.String\" }"));
+        assertTrue(json.contains("\"sync\": { \"type\": \"boolean\" }"));
+    }
+
+    @Test
+    public void testComponentDocumentation() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        String html = context.getComponentDocumentation("infinispan");
+        assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+    }
+
+}