You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2017/01/12 12:16:12 UTC
[2/7] camel git commit: CAMEL-10375: Move camel-couchbase from extra
to ASF
CAMEL-10375: Move camel-couchbase from extra to ASF
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0f1f14fa
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0f1f14fa
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0f1f14fa
Branch: refs/heads/master
Commit: 0f1f14fa972fd739a4db8614ff9a63361f9c0cb3
Parents: ab530bf
Author: Andrea Cosentino <an...@gmail.com>
Authored: Thu Jan 12 11:42:51 2017 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Thu Jan 12 13:14:45 2017 +0100
----------------------------------------------------------------------
apache-camel/pom.xml | 9 +
.../src/main/descriptors/common-bin.xml | 2 +
.../camel-couchbase-starter/pom.xml | 51 ++
.../CouchbaseComponentAutoConfiguration.java | 80 +++
.../src/main/resources/META-INF/LICENSE.txt | 203 +++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
...dditional-spring-configuration-metadata.json | 10 +
.../main/resources/META-INF/spring.factories | 19 +
.../src/main/resources/META-INF/spring.provides | 18 +
components-starter/pom.xml | 1 +
components/camel-couchbase/pom.xml | 77 +++
.../component/couchbase/CouchbaseComponent.java | 44 ++
.../component/couchbase/CouchbaseConstants.java | 50 ++
.../component/couchbase/CouchbaseConsumer.java | 155 +++++
.../component/couchbase/CouchbaseEndpoint.java | 590 +++++++++++++++++++
.../component/couchbase/CouchbaseException.java | 37 ++
.../component/couchbase/CouchbaseProducer.java | 160 +++++
.../src/main/resources/META-INF/LICENSE.txt | 203 +++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../org/apache/camel/component/couchbase | 19 +
...umeBeerMessagesWithLimitIntegrationTest.java | 48 ++
.../couchbase/CouchbaseComponentTest.java | 179 ++++++
.../couchbase/CouchbaseConsumerTest.java | 41 ++
.../couchbase/CouchbaseEndpointTest.java | 162 +++++
.../couchbase/CouchbaseProducerTest.java | 231 ++++++++
.../couchbase/ProduceMessagesSimpleTest.java | 51 ++
...roduceMessagesWithAutoIDIntegrationTest.java | 49 ++
.../RemoveMessagesIntegrationTest.java | 49 ++
.../src/test/resources/log4j2.properties | 30 +
components/pom.xml | 1 +
parent/pom.xml | 10 +
31 files changed, 2601 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index 835a2f0..86d1559 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -191,6 +191,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-couchbase</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-couchdb</artifactId>
</dependency>
<dependency>
@@ -1202,6 +1206,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-couchbase-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-crypto-starter</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index e9dd576..5e1c25d 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -59,6 +59,7 @@
<include>org.apache.camel:camel-consul</include>
<include>org.apache.camel:camel-context</include>
<include>org.apache.camel:camel-couchdb</include>
+ <include>org.apache.camel:camel-couchbase</include>
<include>org.apache.camel:camel-crypto</include>
<include>org.apache.camel:camel-csv</include>
<include>org.apache.camel:camel-cxf</include>
@@ -329,6 +330,7 @@
<include>org.apache.camel:camel-core-starter</include>
<include>org.apache.camel:camel-core-xml-starter</include>
<include>org.apache.camel:camel-couchdb-starter</include>
+ <include>org.apache.camel:camel-couchbase-starter</include>
<include>org.apache.camel:camel-crypto-starter</include>
<include>org.apache.camel:camel-csv-starter</include>
<include>org.apache.camel:camel-cxf-starter</include>
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components-starter/camel-couchbase-starter/pom.xml
----------------------------------------------------------------------
diff --git a/components-starter/camel-couchbase-starter/pom.xml b/components-starter/camel-couchbase-starter/pom.xml
new file mode 100644
index 0000000..d4a53f2
--- /dev/null
+++ b/components-starter/camel-couchbase-starter/pom.xml
@@ -0,0 +1,51 @@
+<?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.
+-->
+<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>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components-starter</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>camel-couchbase-starter</artifactId>
+ <packaging>jar</packaging>
+ <name>Spring-Boot Starter :: Camel Extra :: Couchbase</name>
+ <description>Spring-Boot Starter for Camel Couchbase component</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ <version>${spring-boot-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-couchbase</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!--START OF GENERATED CODE-->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-starter</artifactId>
+ </dependency>
+ <!--END OF GENERATED CODE-->
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components-starter/camel-couchbase-starter/src/main/java/org/apache/camel/component/couchbase/springboot/CouchbaseComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components-starter/camel-couchbase-starter/src/main/java/org/apache/camel/component/couchbase/springboot/CouchbaseComponentAutoConfiguration.java b/components-starter/camel-couchbase-starter/src/main/java/org/apache/camel/component/couchbase/springboot/CouchbaseComponentAutoConfiguration.java
new file mode 100644
index 0000000..e9bdd3b
--- /dev/null
+++ b/components-starter/camel-couchbase-starter/src/main/java/org/apache/camel/component/couchbase/springboot/CouchbaseComponentAutoConfiguration.java
@@ -0,0 +1,80 @@
+/**
+ * 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.couchbase.springboot;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.couchbase.CouchbaseComponent;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionMessage;
+import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
+import org.springframework.boot.bind.RelaxedPropertyResolver;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Generated by camel-package-maven-plugin - do not edit this file!
+ */
+@Configuration
+@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+@Conditional(CouchbaseComponentAutoConfiguration.Condition.class)
+@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
+public class CouchbaseComponentAutoConfiguration {
+
+ @Lazy
+ @Bean(name = "couchbase-component")
+ @ConditionalOnClass(CamelContext.class)
+ @ConditionalOnMissingBean(CouchbaseComponent.class)
+ public CouchbaseComponent configureCouchbaseComponent(
+ CamelContext camelContext) throws Exception {
+ CouchbaseComponent component = new CouchbaseComponent();
+ component.setCamelContext(camelContext);
+ return component;
+ }
+
+ public static class Condition extends SpringBootCondition {
+ @Override
+ public ConditionOutcome getMatchOutcome(
+ ConditionContext conditionContext,
+ AnnotatedTypeMetadata annotatedTypeMetadata) {
+ boolean groupEnabled = isEnabled(conditionContext,
+ "camel.component.", true);
+ ConditionMessage.Builder message = ConditionMessage
+ .forCondition("camel.component.couchbase");
+ if (isEnabled(conditionContext, "camel.component.couchbase.",
+ groupEnabled)) {
+ return ConditionOutcome.match(message.because("enabled"));
+ }
+ return ConditionOutcome.noMatch(message.because("not enabled"));
+ }
+
+ private boolean isEnabled(
+ org.springframework.context.annotation.ConditionContext context,
+ java.lang.String prefix, boolean defaultValue) {
+ RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
+ context.getEnvironment(), prefix);
+ return resolver.getProperty("enabled", Boolean.class, defaultValue);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components-starter/camel-couchbase-starter/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components-starter/camel-couchbase-starter/src/main/resources/META-INF/LICENSE.txt b/components-starter/camel-couchbase-starter/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components-starter/camel-couchbase-starter/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components-starter/camel-couchbase-starter/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components-starter/camel-couchbase-starter/src/main/resources/META-INF/NOTICE.txt b/components-starter/camel-couchbase-starter/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components-starter/camel-couchbase-starter/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components-starter/camel-couchbase-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
----------------------------------------------------------------------
diff --git a/components-starter/camel-couchbase-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/components-starter/camel-couchbase-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
new file mode 100644
index 0000000..86842db
--- /dev/null
+++ b/components-starter/camel-couchbase-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -0,0 +1,10 @@
+{
+ "properties": [
+ {
+ "defaultValue": true,
+ "name": "camel.component.couchbase.enabled",
+ "description": "Enable couchbase component",
+ "type": "java.lang.Boolean"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components-starter/camel-couchbase-starter/src/main/resources/META-INF/spring.factories
----------------------------------------------------------------------
diff --git a/components-starter/camel-couchbase-starter/src/main/resources/META-INF/spring.factories b/components-starter/camel-couchbase-starter/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000..65be58b
--- /dev/null
+++ b/components-starter/camel-couchbase-starter/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.camel.component.couchbase.springboot.CouchbaseComponentAutoConfiguration
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components-starter/camel-couchbase-starter/src/main/resources/META-INF/spring.provides
----------------------------------------------------------------------
diff --git a/components-starter/camel-couchbase-starter/src/main/resources/META-INF/spring.provides b/components-starter/camel-couchbase-starter/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000..cfe55a0
--- /dev/null
+++ b/components-starter/camel-couchbase-starter/src/main/resources/META-INF/spring.provides
@@ -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.
+#
+
+provides: camel-couchbase
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components-starter/pom.xml
----------------------------------------------------------------------
diff --git a/components-starter/pom.xml b/components-starter/pom.xml
index 8af07b8..87f05e3 100644
--- a/components-starter/pom.xml
+++ b/components-starter/pom.xml
@@ -107,6 +107,7 @@
<module>camel-context-starter</module>
<module>camel-core-starter</module>
<module>camel-core-xml-starter</module>
+ <module>camel-couchbase-starter</module>
<module>camel-couchdb-starter</module>
<module>camel-crypto-starter</module>
<module>camel-csv-starter</module>
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/pom.xml b/components/camel-couchbase/pom.xml
new file mode 100644
index 0000000..5996cd4
--- /dev/null
+++ b/components/camel-couchbase/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ https://camel-extra.github.io
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 3
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ http://www.gnu.org/licenses/lgpl-3.0-standalone.html
+-->
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-couchbase</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Couchbase</name>
+ <description>Camel Couchbase component</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.component.couchbase</camel.osgi.export.pkg>
+ <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=couchbase
+ </camel.osgi.export.service>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>com.couchbase.client</groupId>
+ <artifactId>couchbase-client</artifactId>
+ <version>1.4.12</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseComponent.java b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseComponent.java
new file mode 100644
index 0000000..74f02c1
--- /dev/null
+++ b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseComponent.java
@@ -0,0 +1,44 @@
+/**
+ * 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.couchbase;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * Couchbase component.
+ */
+
+public class CouchbaseComponent extends DefaultComponent {
+
+ public CouchbaseComponent() {
+
+ }
+
+ public CouchbaseComponent(CamelContext context) {
+ super(context);
+ }
+
+ @Override
+ protected CouchbaseEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ CouchbaseEndpoint endpoint = new CouchbaseEndpoint(uri, remaining, this);
+ setProperties(endpoint, parameters);
+ return endpoint;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConstants.java b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConstants.java
new file mode 100644
index 0000000..8831fe8
--- /dev/null
+++ b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConstants.java
@@ -0,0 +1,50 @@
+/**
+ * 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.couchbase;
+
+/**
+ * Couchbase Constants and default connection parameters
+ */
+
+public interface CouchbaseConstants {
+
+ String COUCHBASE_URI_ERROR = "Invalid URI. Format must be of the form couchbase:http[s]://hostname[:port]/bucket?[options...]";
+ String COUCHBASE_PUT = "CCB_PUT";
+ String COUCHBASE_GET = "CCB_GET";
+ String COUCHBASE_DELETE = "CCB_DEL";
+ String DEFAULT_DESIGN_DOCUMENT_NAME = "beer";
+ String DEFAULT_VIEWNAME = "brewery_beers";
+ String HEADER_KEY = "CCB_KEY";
+ String HEADER_ID = "CCB_ID";
+ String HEADER_TTL = "CCB_TTL";
+ String HEADER_DESIGN_DOCUMENT_NAME = "CCB_DDN";
+ String HEADER_VIEWNAME = "CCB_VN";
+
+ int DEFAULT_PRODUCER_RETRIES = 2;
+ int DEFAULT_PAUSE_BETWEEN_RETRIES = 5000;
+ int DEFAULT_COUCHBASE_PORT = 8091;
+ int DEFAULT_TTL = 0;
+ long DEFAULT_OP_TIMEOUT = 2500;
+ int DEFAULT_TIMEOUT_EXCEPTION_THRESHOLD = 998;
+ int DEFAULT_READ_BUFFER_SIZE = 16384;
+ long DEFAULT_OP_QUEUE_MAX_BLOCK_TIME = 10000;
+ long DEFAULT_MAX_RECONNECT_DELAY = 30000;
+ long DEFAULT_OBS_POLL_INTERVAL = 400;
+ long DEFAULT_OBS_TIMEOUT = -1;
+ String DEFAULT_CONSUME_PROCESSED_STRATEGY = "none";
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConsumer.java b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConsumer.java
new file mode 100644
index 0000000..e9b307e
--- /dev/null
+++ b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConsumer.java
@@ -0,0 +1,155 @@
+/**
+ * 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.couchbase;
+
+import com.couchbase.client.CouchbaseClient;
+import com.couchbase.client.protocol.views.Query;
+import com.couchbase.client.protocol.views.View;
+import com.couchbase.client.protocol.views.ViewResponse;
+import com.couchbase.client.protocol.views.ViewRow;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultScheduledPollConsumer;
+
+import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_DESIGN_DOCUMENT_NAME;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_ID;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_KEY;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_VIEWNAME;
+
+public class CouchbaseConsumer extends DefaultScheduledPollConsumer {
+
+ private final CouchbaseEndpoint endpoint;
+ private final CouchbaseClient client;
+ private final View view;
+ private final Query query;
+
+ public CouchbaseConsumer(CouchbaseEndpoint endpoint, CouchbaseClient client, Processor processor) {
+
+ super(endpoint, processor);
+ this.client = client;
+ this.endpoint = endpoint;
+ this.view = client.getView(endpoint.getDesignDocumentName(), endpoint.getViewName());
+ this.query = new Query();
+ init();
+
+ }
+
+ private void init() {
+
+ query.setIncludeDocs(true);
+
+ int limit = endpoint.getLimit();
+ if (limit > 0) {
+ query.setLimit(limit);
+ }
+
+ int skip = endpoint.getSkip();
+ if (skip > 0) {
+ query.setSkip(skip);
+ }
+
+ query.setDescending(endpoint.isDescending());
+
+ String rangeStartKey = endpoint.getRangeStartKey();
+ String rangeEndKey = endpoint.getRangeEndKey();
+ if ("".equals(rangeStartKey) || "".equals(rangeEndKey)) {
+ return;
+ }
+ query.setRange(rangeStartKey, rangeEndKey);
+
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ log.info("Starting Couchbase consumer");
+ super.doStart();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ log.info("Stopping Couchbase consumer");
+ super.doStop();
+ }
+
+ @Override
+ protected synchronized int poll() throws Exception {
+ ViewResponse result = client.query(view, query);
+ log.info("Received result set from Couchbase");
+
+ if (log.isTraceEnabled()) {
+ log.trace("ViewResponse = {}", result);
+ }
+
+ String consumerProcessedStrategy = endpoint.getConsumerProcessedStrategy();
+
+ for (ViewRow row : result) {
+
+ String id = row.getId();
+ Object doc = row.getDocument();
+
+ String key = row.getKey();
+ String designDocumentName = endpoint.getDesignDocumentName();
+ String viewName = endpoint.getViewName();
+
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody(doc);
+ exchange.getIn().setHeader(HEADER_ID, id);
+ exchange.getIn().setHeader(HEADER_KEY, key);
+ exchange.getIn().setHeader(HEADER_DESIGN_DOCUMENT_NAME, designDocumentName);
+ exchange.getIn().setHeader(HEADER_VIEWNAME, viewName);
+
+ if ("delete".equalsIgnoreCase(consumerProcessedStrategy)) {
+ if (log.isTraceEnabled()) {
+ log.trace("Deleting doc with ID {}", id);
+ }
+ client.delete(id);
+ } else if ("filter".equalsIgnoreCase(consumerProcessedStrategy)) {
+ if (log.isTraceEnabled()) {
+ log.trace("Filtering out ID {}", id);
+ }
+ // add filter for already processed docs
+ } else {
+ log.trace("No strategy set for already processed docs, beware of duplicates!");
+ }
+
+ logDetails(id, doc, key, designDocumentName, viewName, exchange);
+
+ try {
+ this.getProcessor().process(exchange);
+ } catch (Exception e) {
+ this.getExceptionHandler().handleException("Error processing exchange.", exchange, e);
+ }
+ }
+
+ return result.size();
+ }
+
+ private void logDetails(String id, Object doc, String key, String designDocumentName, String viewName, Exchange exchange) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("Created exchange = {}", exchange);
+ log.trace("Added Document in body = {}", doc);
+ log.trace("Adding to Header");
+ log.trace("ID = {}", id);
+ log.trace("Key = {}", key);
+ log.trace("Design Document Name = {}", designDocumentName);
+ log.trace("View Name = {}", viewName);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java
new file mode 100644
index 0000000..46c8d29
--- /dev/null
+++ b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseEndpoint.java
@@ -0,0 +1,590 @@
+/**
+ * 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.couchbase;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.couchbase.client.CouchbaseClient;
+import com.couchbase.client.CouchbaseConnectionFactoryBuilder;
+
+import org.apache.camel.Consumer;
+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.spi.UriPath;
+
+import static org.apache.camel.component.couchbase.CouchbaseConstants.COUCHBASE_PUT;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.COUCHBASE_URI_ERROR;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_CONSUME_PROCESSED_STRATEGY;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_COUCHBASE_PORT;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_DESIGN_DOCUMENT_NAME;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_MAX_RECONNECT_DELAY;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_OBS_POLL_INTERVAL;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_OBS_TIMEOUT;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_OP_QUEUE_MAX_BLOCK_TIME;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_OP_TIMEOUT;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_PAUSE_BETWEEN_RETRIES;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_PRODUCER_RETRIES;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_READ_BUFFER_SIZE;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_TIMEOUT_EXCEPTION_THRESHOLD;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_VIEWNAME;
+
+/**
+ * Represents a Couchbase endpoint that can query Views with a Poll strategy
+ * and/or produce various type of operations.
+ */
+@UriEndpoint(scheme = "couchbase", title = "Couchbase", syntax = "couchbase:url", consumerClass = CouchbaseConsumer.class, label = "database,nosql")
+public class CouchbaseEndpoint extends ScheduledPollEndpoint {
+
+ @UriPath
+ private String protocol;
+ private String bucket;
+ private String hostname;
+ private int port;
+
+ // Couchbase key
+ @UriParam
+ private String key;
+
+ // Authentication
+ @UriParam
+ private String username = "";
+ @UriParam
+ private String password = "";
+
+ // Additional hosts
+ @UriParam
+ private String additionalHosts = "";
+
+ // Persistence and replication parameters
+ @UriParam
+ private int persistTo;
+
+ @UriParam
+ private int replicateTo;
+
+ // Producer parameters
+ @UriParam
+ private String operation = COUCHBASE_PUT;
+ @UriParam
+ private boolean autoStartIdForInserts;
+ @UriParam
+ private int producerRetryAttempts = DEFAULT_PRODUCER_RETRIES;
+ @UriParam
+ private int producerRetryPause = DEFAULT_PAUSE_BETWEEN_RETRIES;
+
+ @UriParam
+ private long startingIdForInsertsFrom;
+ // View control
+ @UriParam
+ private String designDocumentName = DEFAULT_DESIGN_DOCUMENT_NAME;
+ @UriParam
+ private String viewName = DEFAULT_VIEWNAME;
+ @UriParam
+ private int limit = -1;
+ @UriParam
+ private boolean descending;
+ @UriParam
+ private int skip = -1;
+ @UriParam
+ private String rangeStartKey = "";
+
+ @UriParam
+ private String rangeEndKey = "";
+
+ // Consumer strategy
+ @UriParam
+ private String consumerProcessedStrategy = DEFAULT_CONSUME_PROCESSED_STRATEGY;
+
+ // Connection fine tuning parameters
+ @UriParam
+ private long opTimeOut = DEFAULT_OP_TIMEOUT;
+ @UriParam
+ private int timeoutExceptionThreshold = DEFAULT_TIMEOUT_EXCEPTION_THRESHOLD;
+ @UriParam
+ private int readBufferSize = DEFAULT_READ_BUFFER_SIZE;
+ @UriParam
+ private boolean shouldOptimize;
+ @UriParam
+ private long maxReconnectDelay = DEFAULT_MAX_RECONNECT_DELAY;
+ @UriParam
+ private long opQueueMaxBlockTime = DEFAULT_OP_QUEUE_MAX_BLOCK_TIME;
+ @UriParam
+ private long obsPollInterval = DEFAULT_OBS_POLL_INTERVAL;
+ @UriParam
+ private long obsTimeout = DEFAULT_OBS_TIMEOUT;
+
+ public CouchbaseEndpoint() {
+ }
+
+ public CouchbaseEndpoint(String uri, String remaining, CouchbaseComponent component) throws URISyntaxException {
+ super(uri, component);
+ URI remainingUri = new URI(remaining);
+
+ protocol = remainingUri.getScheme();
+ if (protocol == null) {
+ throw new IllegalArgumentException(COUCHBASE_URI_ERROR);
+ }
+
+ port = remainingUri.getPort() == -1 ? DEFAULT_COUCHBASE_PORT : remainingUri.getPort();
+
+ if (remainingUri.getPath() == null || remainingUri.getPath().trim().length() == 0) {
+ throw new IllegalArgumentException(COUCHBASE_URI_ERROR);
+ }
+ bucket = remainingUri.getPath().substring(1);
+
+ hostname = remainingUri.getHost();
+ if (hostname == null) {
+ throw new IllegalArgumentException(COUCHBASE_URI_ERROR);
+ }
+ }
+
+ public CouchbaseEndpoint(String endpointUri, CouchbaseComponent component) {
+ super(endpointUri, component);
+ }
+
+ @Override
+ public Producer createProducer() throws Exception {
+ return new CouchbaseProducer(this, createClient(), persistTo, replicateTo);
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ return new CouchbaseConsumer(this, createClient(), processor);
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ /**
+ * The protocol to use
+ */
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getBucket() {
+ return bucket;
+ }
+
+ /**
+ * The bucket to use
+ */
+ public void setBucket(String bucket) {
+ this.bucket = bucket;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ /**
+ * The hostname to use
+ */
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * The port number to use
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * The key to use
+ */
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * The username to use
+ */
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * The password to use
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getAdditionalHosts() {
+ return additionalHosts;
+ }
+
+ /**
+ * The additional hosts
+ */
+ public void setAdditionalHosts(String additionalHosts) {
+ this.additionalHosts = additionalHosts;
+ }
+
+ public int getPersistTo() {
+ return persistTo;
+ }
+
+ /**
+ * Where to persist the data
+ */
+ public void setPersistTo(int persistTo) {
+ this.persistTo = persistTo;
+ }
+
+ public int getReplicateTo() {
+ return replicateTo;
+ }
+
+ /**
+ * Where to replicate the data
+ */
+ public void setReplicateTo(int replicateTo) {
+ this.replicateTo = replicateTo;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ /**
+ * The operation to do
+ */
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ public boolean isAutoStartIdForInserts() {
+ return autoStartIdForInserts;
+ }
+
+ /**
+ * Define if we want an autostart Id when we are doing an insert operation
+ */
+ public void setAutoStartIdForInserts(boolean autoStartIdForInserts) {
+ this.autoStartIdForInserts = autoStartIdForInserts;
+ }
+
+ public long getStartingIdForInsertsFrom() {
+ return startingIdForInsertsFrom;
+ }
+
+ /**
+ * Define the starting Id where we are doing an insert operation
+ */
+ public void setStartingIdForInsertsFrom(long startingIdForInsertsFrom) {
+ this.startingIdForInsertsFrom = startingIdForInsertsFrom;
+ }
+
+ public int getProducerRetryAttempts() {
+ return producerRetryAttempts;
+ }
+
+ /**
+ * Define the number of retry attempts
+ */
+ public void setProducerRetryAttempts(int producerRetryAttempts) {
+ this.producerRetryAttempts = producerRetryAttempts;
+ }
+
+ public int getProducerRetryPause() {
+ return producerRetryPause;
+ }
+
+ /**
+ * Define the retry pause between different attempts
+ */
+ public void setProducerRetryPause(int producerRetryPause) {
+ this.producerRetryPause = producerRetryPause;
+ }
+
+ public String getDesignDocumentName() {
+ return designDocumentName;
+ }
+
+ /**
+ * The design document name to use
+ */
+ public void setDesignDocumentName(String designDocumentName) {
+ this.designDocumentName = designDocumentName;
+ }
+
+ public String getViewName() {
+ return viewName;
+ }
+
+ /**
+ * The view name to use
+ */
+ public void setViewName(String viewName) {
+ this.viewName = viewName;
+ }
+
+ public int getLimit() {
+ return limit;
+ }
+
+ /**
+ * The output limit to use
+ */
+ public void setLimit(int limit) {
+ this.limit = limit;
+ }
+
+ public boolean isDescending() {
+ return descending;
+ }
+
+ /**
+ * Define if this operation is descending or not
+ */
+ public void setDescending(boolean descending) {
+ this.descending = descending;
+ }
+
+ public int getSkip() {
+ return skip;
+ }
+
+ /**
+ * Define the skip to use
+ */
+ public void setSkip(int skip) {
+ this.skip = skip;
+ }
+
+ public String getRangeStartKey() {
+ return rangeStartKey;
+ }
+
+ /**
+ * Define a range for the start key
+ */
+ public void setRangeStartKey(String rangeStartKey) {
+ this.rangeStartKey = rangeStartKey;
+ }
+
+ public String getRangeEndKey() {
+ return rangeEndKey;
+ }
+
+ /**
+ * Define a range for the end key
+ */
+ public void setRangeEndKey(String rangeEndKey) {
+ this.rangeEndKey = rangeEndKey;
+ }
+
+ public String getConsumerProcessedStrategy() {
+ return consumerProcessedStrategy;
+ }
+
+ /**
+ * Define the consumer Processed strategy to use
+ */
+ public void setConsumerProcessedStrategy(String consumerProcessedStrategy) {
+ this.consumerProcessedStrategy = consumerProcessedStrategy;
+ }
+
+ public long getOpTimeOut() {
+ return opTimeOut;
+ }
+
+ /**
+ * Define the operation timeout
+ */
+ public void setOpTimeOut(long opTimeOut) {
+ this.opTimeOut = opTimeOut;
+ }
+
+ public int getTimeoutExceptionThreshold() {
+ return timeoutExceptionThreshold;
+ }
+
+ /**
+ * Define the threshold for throwing a timeout Exception
+ */
+ public void setTimeoutExceptionThreshold(int timeoutExceptionThreshold) {
+ this.timeoutExceptionThreshold = timeoutExceptionThreshold;
+ }
+
+ public int getReadBufferSize() {
+ return readBufferSize;
+ }
+
+ /**
+ * Define the buffer size
+ */
+ public void setReadBufferSize(int readBufferSize) {
+ this.readBufferSize = readBufferSize;
+ }
+
+ public boolean isShouldOptimize() {
+ return shouldOptimize;
+ }
+
+ /**
+ * Define if we want to use optimization or not where possible
+ */
+ public void setShouldOptimize(boolean shouldOptimize) {
+ this.shouldOptimize = shouldOptimize;
+ }
+
+ public long getMaxReconnectDelay() {
+ return maxReconnectDelay;
+ }
+
+ /**
+ * Define the max delay during a reconnection
+ */
+ public void setMaxReconnectDelay(long maxReconnectDelay) {
+ this.maxReconnectDelay = maxReconnectDelay;
+ }
+
+ public long getOpQueueMaxBlockTime() {
+ return opQueueMaxBlockTime;
+ }
+
+ /**
+ * Define the max time an operation can be in queue blocked
+ */
+ public void setOpQueueMaxBlockTime(long opQueueMaxBlockTime) {
+ this.opQueueMaxBlockTime = opQueueMaxBlockTime;
+ }
+
+ public long getObsPollInterval() {
+ return obsPollInterval;
+ }
+
+ /**
+ * Define the observation polling interval
+ */
+ public void setObsPollInterval(long obsPollInterval) {
+ this.obsPollInterval = obsPollInterval;
+ }
+
+ public long getObsTimeout() {
+ return obsTimeout;
+ }
+
+ /**
+ * Define the observation timeout
+ */
+ public void setObsTimeout(long obsTimeout) {
+ this.obsTimeout = obsTimeout;
+ }
+
+ public URI[] makeBootstrapURI() throws URISyntaxException {
+
+ if (additionalHosts == null || "".equals(additionalHosts)) {
+ return new URI[] {new URI(protocol + "://" + hostname + ":" + port + "/pools")};
+ }
+ return getAllUris();
+
+ }
+
+ private URI[] getAllUris() throws URISyntaxException {
+
+ String[] hosts = additionalHosts.split(",");
+
+ for (int i = 0; i < hosts.length; i++) {
+ hosts[i] = hosts[i].trim();
+ }
+
+ List<String> hostList = new ArrayList<String>();
+ hostList.add(hostname);
+ hostList.addAll(Arrays.asList(hosts));
+ Set<String> hostSet = new LinkedHashSet<String>(hostList);
+ hosts = hostSet.toArray(new String[hostSet.size()]);
+
+ URI[] uriArray = new URI[hosts.length];
+
+ for (int i = 0; i < hosts.length; i++) {
+ uriArray[i] = new URI(protocol + "://" + hosts[i] + ":" + port + "/pools");
+ }
+
+ return uriArray;
+ }
+
+ private CouchbaseClient createClient() throws IOException, URISyntaxException {
+ List<URI> hosts = Arrays.asList(makeBootstrapURI());
+
+ CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
+
+ if (opTimeOut != DEFAULT_OP_TIMEOUT) {
+ cfb.setOpTimeout(opTimeOut);
+ }
+ if (timeoutExceptionThreshold != DEFAULT_TIMEOUT_EXCEPTION_THRESHOLD) {
+ cfb.setTimeoutExceptionThreshold(timeoutExceptionThreshold);
+ }
+ if (readBufferSize != DEFAULT_READ_BUFFER_SIZE) {
+ cfb.setReadBufferSize(readBufferSize);
+ }
+ if (shouldOptimize) {
+ cfb.setShouldOptimize(true);
+ }
+ if (maxReconnectDelay != DEFAULT_MAX_RECONNECT_DELAY) {
+ cfb.setMaxReconnectDelay(maxReconnectDelay);
+ }
+ if (opQueueMaxBlockTime != DEFAULT_OP_QUEUE_MAX_BLOCK_TIME) {
+ cfb.setOpQueueMaxBlockTime(opQueueMaxBlockTime);
+ }
+ if (obsPollInterval != DEFAULT_OBS_POLL_INTERVAL) {
+ cfb.setObsPollInterval(obsPollInterval);
+ }
+ if (obsTimeout != DEFAULT_OBS_TIMEOUT) {
+ cfb.setObsTimeout(obsTimeout);
+ }
+
+ return new CouchbaseClient(cfb.buildCouchbaseConnection(hosts, bucket, username, password));
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseException.java
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseException.java b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseException.java
new file mode 100644
index 0000000..d9d81c0
--- /dev/null
+++ b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseException.java
@@ -0,0 +1,37 @@
+/**
+ * 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.couchbase;
+
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.Exchange;
+
+/**
+ * Couchbase exception.
+ */
+
+public class CouchbaseException extends CamelExchangeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public CouchbaseException(String message, Exchange exchange) {
+ super(message, exchange);
+ }
+
+ public CouchbaseException(String message, Exchange exchange, Throwable cause) {
+ super(message, exchange, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseProducer.java b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseProducer.java
new file mode 100644
index 0000000..bccc244
--- /dev/null
+++ b/components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseProducer.java
@@ -0,0 +1,160 @@
+/**
+ * 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.couchbase;
+
+import java.util.Map;
+import java.util.concurrent.Future;
+
+import com.couchbase.client.CouchbaseClientIF;
+
+import net.spy.memcached.PersistTo;
+import net.spy.memcached.ReplicateTo;
+import net.spy.memcached.internal.OperationFuture;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+
+import static org.apache.camel.component.couchbase.CouchbaseConstants.COUCHBASE_DELETE;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.COUCHBASE_GET;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.COUCHBASE_PUT;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_TTL;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_ID;
+import static org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_TTL;
+
+/**
+ * Couchbase producer generates various type of operations. PUT, GET, and DELETE
+ * are currently supported
+ */
+
+public class CouchbaseProducer extends DefaultProducer {
+
+ private CouchbaseEndpoint endpoint;
+ private CouchbaseClientIF client;
+ private long startId;
+ private PersistTo persistTo;
+ private ReplicateTo replicateTo;
+ private int producerRetryAttempts;
+ private int producerRetryPause;
+
+ public CouchbaseProducer(CouchbaseEndpoint endpoint, CouchbaseClientIF client, int persistTo, int replicateTo) throws Exception {
+ super(endpoint);
+ this.endpoint = endpoint;
+ this.client = client;
+ if (endpoint.isAutoStartIdForInserts()) {
+ this.startId = endpoint.getStartingIdForInsertsFrom();
+ }
+ this.producerRetryAttempts = endpoint.getProducerRetryAttempts();
+ this.producerRetryPause = endpoint.getProducerRetryPause();
+
+ switch (persistTo) {
+ case 0:
+ this.persistTo = PersistTo.ZERO;
+ break;
+ case 1:
+ this.persistTo = PersistTo.MASTER;
+ break;
+ case 2:
+ this.persistTo = PersistTo.TWO;
+ break;
+ case 3:
+ this.persistTo = PersistTo.THREE;
+ break;
+ case 4:
+ this.persistTo = PersistTo.FOUR;
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported persistTo parameter. Supported values are 0 to 4. Currently provided: " + persistTo);
+ }
+
+ switch (replicateTo) {
+ case 0:
+ this.replicateTo = ReplicateTo.ZERO;
+ break;
+ case 1:
+ this.replicateTo = ReplicateTo.ONE;
+ break;
+ case 2:
+ this.replicateTo = ReplicateTo.TWO;
+ break;
+ case 3:
+ this.replicateTo = ReplicateTo.THREE;
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported replicateTo parameter. Supported values are 0 to 3. Currently provided: " + replicateTo);
+ }
+
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+
+ Map<String, Object> headers = exchange.getIn().getHeaders();
+
+ String id = (headers.containsKey(HEADER_ID)) ? exchange.getIn().getHeader(HEADER_ID, String.class) : endpoint.getId();
+
+ int ttl = (headers.containsKey(HEADER_TTL)) ? Integer.parseInt(exchange.getIn().getHeader(HEADER_TTL, String.class)) : DEFAULT_TTL;
+
+ if (endpoint.isAutoStartIdForInserts()) {
+ id = Long.toString(startId);
+ startId++;
+ } else if (id == null) {
+ throw new CouchbaseException(HEADER_ID + " is not specified in message header or endpoint URL.", exchange);
+ }
+
+ if (endpoint.getOperation().equals(COUCHBASE_PUT)) {
+ log.info("Type of operation: PUT");
+ Object obj = exchange.getIn().getBody();
+ exchange.getOut().setBody(setDocument(id, ttl, obj, persistTo, replicateTo));
+ } else if (endpoint.getOperation().equals(COUCHBASE_GET)) {
+ log.info("Type of operation: GET");
+ Object result = client.get(id);
+ exchange.getOut().setBody(result);
+ } else if (endpoint.getOperation().equals(COUCHBASE_DELETE)) {
+ log.info("Type of operation: DELETE");
+ Future<Boolean> result = client.delete(id);
+ exchange.getOut().setBody(result.get());
+ }
+
+ // cleanup the cache headers
+ exchange.getIn().removeHeader(HEADER_ID);
+
+ }
+
+ private Boolean setDocument(String id, int expiry, Object obj, PersistTo persistTo, ReplicateTo replicateTo) throws Exception {
+ return setDocument(id, expiry, obj, producerRetryAttempts, persistTo, replicateTo);
+ }
+
+ private Boolean setDocument(String id, int expiry, Object obj, int retryAttempts, PersistTo persistTo, ReplicateTo replicateTo) throws Exception {
+
+ OperationFuture<Boolean> result = client.set(id, expiry, obj, persistTo, replicateTo);
+ try {
+ if (!result.get()) {
+ throw new Exception("Unable to save Document. " + id);
+ }
+ return true;
+ } catch (Exception e) {
+ if (retryAttempts <= 0) {
+ throw e;
+ } else {
+ log.info("Unable to save Document, retrying in " + producerRetryPause + "ms (" + retryAttempts + ")");
+ Thread.sleep(producerRetryPause);
+ return setDocument(id, expiry, obj, retryAttempts - 1, persistTo, replicateTo);
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/src/main/resources/META-INF/LICENSE.txt b/components/camel-couchbase/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-couchbase/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/src/main/resources/META-INF/NOTICE.txt b/components/camel-couchbase/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-couchbase/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/src/main/resources/META-INF/services/org/apache/camel/component/couchbase
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/src/main/resources/META-INF/services/org/apache/camel/component/couchbase b/components/camel-couchbase/src/main/resources/META-INF/services/org/apache/camel/component/couchbase
new file mode 100644
index 0000000..c580c63
--- /dev/null
+++ b/components/camel-couchbase/src/main/resources/META-INF/services/org/apache/camel/component/couchbase
@@ -0,0 +1,19 @@
+#
+# 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.couchbase.CouchbaseComponent
+
http://git-wip-us.apache.org/repos/asf/camel/blob/0f1f14fa/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ConsumeBeerMessagesWithLimitIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ConsumeBeerMessagesWithLimitIntegrationTest.java b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ConsumeBeerMessagesWithLimitIntegrationTest.java
new file mode 100644
index 0000000..a4e3365
--- /dev/null
+++ b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ConsumeBeerMessagesWithLimitIntegrationTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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.couchbase;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class ConsumeBeerMessagesWithLimitIntegrationTest extends CamelTestSupport {
+
+ @Test
+ public void testQueryForBeers() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(10);
+
+ assertMockEndpointsSatisfied();
+
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ // need couchbase installed on localhost with beer-sample data
+ from("couchbase:http://localhost/beer-sample?designDocumentName=beer&viewName=brewery_beers&limit=10").to("mock:result");
+ }
+ };
+
+ }
+}