You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gz...@apache.org on 2014/06/26 05:27:05 UTC
git commit: CAMEL-7542: Expose component options for Camel JCR
Repository: camel
Updated Branches:
refs/heads/master 98d91c941 -> fea4c6ebf
CAMEL-7542: Expose component options for Camel JCR
Signed-off-by: Gregor Zurowski <gr...@zurowski.org>
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fea4c6eb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fea4c6eb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fea4c6eb
Branch: refs/heads/master
Commit: fea4c6ebf6ebd354596a7575209bc986a91af66a
Parents: 98d91c9
Author: Gregor Zurowski <gr...@zurowski.org>
Authored: Wed Jun 25 23:25:24 2014 -0400
Committer: Gregor Zurowski <gr...@zurowski.org>
Committed: Wed Jun 25 23:25:24 2014 -0400
----------------------------------------------------------------------
.../camel/component/jcr/JcrComponent.java | 13 ++++-
.../apache/camel/component/jcr/JcrEndpoint.java | 11 +++-
...ponentConfigurationAndDocumentationTest.java | 59 ++++++++++++++++++++
3 files changed, 80 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/fea4c6eb/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrComponent.java b/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrComponent.java
index 76802aa..7804b65 100644
--- a/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrComponent.java
+++ b/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrComponent.java
@@ -18,13 +18,22 @@ package org.apache.camel.component.jcr;
import java.util.Map;
+import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
/**
* A component for integrating with JSR-170 (JCR) compliant content repositories
*/
-public class JcrComponent extends DefaultComponent {
+public class JcrComponent extends UriEndpointComponent {
+
+ public JcrComponent() {
+ super(JcrEndpoint.class);
+ }
+
+ public JcrComponent(CamelContext context) {
+ super(context, JcrEndpoint.class);
+ }
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> properties) throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/fea4c6eb/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrEndpoint.java b/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrEndpoint.java
index b0f2e79..4a0f39d 100644
--- a/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrEndpoint.java
+++ b/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrEndpoint.java
@@ -28,24 +28,33 @@ import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
import org.apache.camel.util.ObjectHelper;
/**
* A JCR endpoint
*/
+@UriEndpoint(scheme = "jcr", consumerClass = JcrConsumer.class)
public class JcrEndpoint extends DefaultEndpoint {
private Credentials credentials;
private Repository repository;
private String base;
+ @UriParam
private int eventTypes;
+ @UriParam
private boolean deep;
+ @UriParam
private String uuids;
+ @UriParam
private String nodeTypeNames;
+ @UriParam
private boolean noLocal;
-
+ @UriParam
private long sessionLiveCheckIntervalOnStart = 3000L;
+ @UriParam
private long sessionLiveCheckInterval = 60000L;
protected JcrEndpoint(String endpointUri, JcrComponent component) {
http://git-wip-us.apache.org/repos/asf/camel/blob/fea4c6eb/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrComponentConfigurationAndDocumentationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrComponentConfigurationAndDocumentationTest.java b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrComponentConfigurationAndDocumentationTest.java
new file mode 100755
index 0000000..19b4ce6
--- /dev/null
+++ b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrComponentConfigurationAndDocumentationTest.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.jcr;
+
+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 JcrComponentConfigurationAndDocumentationTest extends CamelTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Test
+ public void testComponentConfiguration() throws Exception {
+ JcrComponent component = context.getComponent("jcr", JcrComponent.class);
+ String uri = "jcr://gregor:secret@repo/home/gregor?deep=true&eventTypes=3&noLocal=false";
+ EndpointConfiguration configuration = component.createConfiguration(uri);
+
+ assertEquals("true", configuration.getParameter("deep"));
+ assertEquals("3", configuration.getParameter("eventTypes"));
+ assertEquals("false", configuration.getParameter("noLocal"));
+
+ ComponentConfiguration componentConfiguration = component.createComponentConfiguration();
+ String json = componentConfiguration.createParameterJsonSchema();
+
+ assertNotNull(json);
+ assertTrue(json.contains("\"deep\": { \"type\": \"boolean\" }"));
+ assertTrue(json.contains("\"eventTypes\": { \"type\": \"int\" }"));
+ assertTrue(json.contains("\"noLocal\": { \"type\": \"boolean\" }"));
+ }
+
+ @Test
+ public void testComponentDocumentation() throws Exception {
+ CamelContext context = new DefaultCamelContext();
+ String html = context.getComponentDocumentation("jcr");
+ assertNotNull("Should have found some auto-generated HTML if on Java 7", html);
+ }
+
+}