Skip to content
Permalink
Browse files

Added a Camel connector for Ethereum blockchain using Web3j library

  • Loading branch information...
bibryam committed Apr 25, 2018
1 parent ca14beb commit ef2bbb8799b83c70b0b8c267e7da0042d59f7e3b
Showing with 5,634 additions and 1 deletion.
  1. +9 −0 apache-camel/pom.xml
  2. +2 −0 apache-camel/src/main/descriptors/common-bin.xml
  3. +10 −0 bom/camel-bom/pom.xml
  4. +93 −0 components/camel-web3j/pom.xml
  5. +97 −0 components/camel-web3j/src/main/docs/web3j-component.adoc
  6. +55 −0 components/camel-web3j/src/main/java/org/apache/camel/component/web3j/Web3jComponent.java
  7. +349 −0 components/camel-web3j/src/main/java/org/apache/camel/component/web3j/Web3jConfiguration.java
  8. +132 −0 components/camel-web3j/src/main/java/org/apache/camel/component/web3j/Web3jConstants.java
  9. +242 −0 components/camel-web3j/src/main/java/org/apache/camel/component/web3j/Web3jConsumer.java
  10. +124 −0 components/camel-web3j/src/main/java/org/apache/camel/component/web3j/Web3jEndpoint.java
  11. +930 −0 components/camel-web3j/src/main/java/org/apache/camel/component/web3j/Web3jProducer.java
  12. +203 −0 components/camel-web3j/src/main/resources/META-INF/LICENSE.txt
  13. +11 −0 components/camel-web3j/src/main/resources/META-INF/NOTICE.txt
  14. +18 −0 components/camel-web3j/src/main/resources/META-INF/services/org/apache/camel/component/web3j
  15. +108 −0 .../camel-web3j/src/test/java/org/apache/camel/component/web3j/Web3jConsumerBlockObservableTest.java
  16. +110 −0 ...ache/camel/component/web3j/Web3jConsumerCatchUpToLatestAndSubscribeToNewBlocksObservableTest.java
  17. +109 −0 ...amel/component/web3j/Web3jConsumerCatchUpToLatestAndSubscribeToNewTransactionsObservableTest.java
  18. +110 −0 .../test/java/org/apache/camel/component/web3j/Web3jConsumerCatchUpToLatestBlocksObservableTest.java
  19. +110 −0 ...java/org/apache/camel/component/web3j/Web3jConsumerCatchUpToLatestTransactionsObservableTest.java
  20. +107 −0 ...web3j/src/test/java/org/apache/camel/component/web3j/Web3jConsumerEthBlockHashObservableTest.java
  21. +109 −0 ...camel-web3j/src/test/java/org/apache/camel/component/web3j/Web3jConsumerEthLogObservableTest.java
  22. +108 −0 ...t/java/org/apache/camel/component/web3j/Web3jConsumerEthPendingTransactionHashObservableTest.java
  23. +64 −0 ...ents/camel-web3j/src/test/java/org/apache/camel/component/web3j/Web3jConsumerIntegrationTest.java
  24. +109 −0 ...src/test/java/org/apache/camel/component/web3j/Web3jConsumerPendingTransactionObservableTest.java
  25. +109 −0 ...-web3j/src/test/java/org/apache/camel/component/web3j/Web3jConsumerReplyBlocksObservableTest.java
  26. +111 −0 .../src/test/java/org/apache/camel/component/web3j/Web3jConsumerReplyTransactionsObservableTest.java
  27. +29 −0 components/camel-web3j/src/test/java/org/apache/camel/component/web3j/Web3jConsumerTestSupport.java
  28. +108 −0 ...-web3j/src/test/java/org/apache/camel/component/web3j/Web3jConsumerTransactionObservableTest.java
  29. +73 −0 ...ents/camel-web3j/src/test/java/org/apache/camel/component/web3j/Web3jProducerIntegrationTest.java
  30. +946 −0 components/camel-web3j/src/test/java/org/apache/camel/component/web3j/Web3jProducerTest.java
  31. +97 −0 components/camel-web3j/src/test/java/org/apache/camel/component/web3j/Web3jTestSupport.java
  32. +34 −0 components/camel-web3j/src/test/resources/log4j2.properties
  33. +1 −0 components/camel-web3j/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
  34. +1 −0 components/pom.xml
  35. +4 −1 components/readme.adoc
  36. +1 −0 docs/user-manual/en/SUMMARY.md
  37. +11 −0 parent/pom.xml
  38. +7 −0 platforms/karaf/features/src/main/resources/features.xml
  39. +53 −0 platforms/spring-boot/components-starter/camel-web3j-starter/pom.xml
  40. +128 −0 ...er/src/main/java/org/apache/camel/component/web3j/springboot/Web3jComponentAutoConfiguration.java
  41. +331 −0 ...tarter/src/main/java/org/apache/camel/component/web3j/springboot/Web3jComponentConfiguration.java
  42. +203 −0 platforms/spring-boot/components-starter/camel-web3j-starter/src/main/resources/META-INF/LICENSE.txt
  43. +11 −0 platforms/spring-boot/components-starter/camel-web3j-starter/src/main/resources/META-INF/NOTICE.txt
  44. +10 −0 ...ter/camel-web3j-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
  45. +19 −0 ...s/spring-boot/components-starter/camel-web3j-starter/src/main/resources/META-INF/spring.factories
  46. +17 −0 ...ms/spring-boot/components-starter/camel-web3j-starter/src/main/resources/META-INF/spring.provides
  47. +1 −0 platforms/spring-boot/components-starter/pom.xml
  48. +10 −0 platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
@@ -1129,6 +1129,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-web3j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-wordpress</artifactId>
@@ -2410,6 +2414,11 @@
<artifactId>camel-websocket-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-web3j-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-wordpress-starter</artifactId>
@@ -290,6 +290,7 @@
<include>org.apache.camel:camel-vertx</include>
<include>org.apache.camel:camel-weather</include>
<include>org.apache.camel:camel-websocket</include>
<include>org.apache.camel:camel-web3j</include>
<include>org.apache.camel:camel-wordpress</include>
<include>org.apache.camel:camel-xmlbeans</include>
<include>org.apache.camel:camel-xchange</include>
@@ -589,6 +590,7 @@
<include>org.apache.camel:camel-vertx-starter</include>
<include>org.apache.camel:camel-weather-starter</include>
<include>org.apache.camel:camel-websocket-starter</include>
<include>org.apache.camel:camel-web3j-starter</include>
<include>org.apache.camel:camel-wordpress-starter</include>
<include>org.apache.camel:camel-xmlbeans-starter</include>
<include>org.apache.camel:camel-xchange-starter</include>
@@ -2678,6 +2678,16 @@
<artifactId>camel-weather-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-web3j</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-web3j-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-websocket</artifactId>
@@ -0,0 +1,93 @@
<?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</artifactId>
<version>2.22.0-SNAPSHOT</version>
</parent>

<artifactId>camel-web3j</artifactId>
<packaging>jar</packaging>
<name>Camel :: Web3j</name>
<description>Camel Ethereum support through Web3j</description>

<properties>
<camel.osgi.export.pkg>org.apache.camel.component.web3j.*</camel.osgi.export.pkg>
<camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=web3j</camel.osgi.export.service>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>${web3j-version}</version>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>geth</artifactId>
<version>${web3j-version}</version>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>parity</artifactId>
<version>${web3j-version}</version>
</dependency>

<!-- for testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
@@ -0,0 +1,97 @@
[[web3j-component]]
== web3j Component

*Available as of Camel version 2.20*

*Available as of Camel version 2.20*


The web3j component uses the
https://github.com/web3j/web3j[web3j] client
API and allows you to read/write from geth/parity compatible Ethereum nodes.

### URI Format

[source,java]
------------------------------
web3j://ethereumServerUrl[?options]
------------------------------

You can append query options to the URI in the following format,
?options=value&option2=value&...

### Web3j Options

// component options: START
The web3j component supports 2 options which are listed below.



[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *configuration* (common) | Default configuration | | Web3jConfiguration
| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
|===
// component options: END

// endpoint options: START
The web3j endpoint is configured using URI syntax:

----
web3j:cmsUrl
----

with the following path and query parameters:

==== Path Parameters (1 parameters):


[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *web3j* | *Required* URL to the web3j repository | | Web3j
|===


==== Query Parameters (4 parameters):


[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
| *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler
| *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern
| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
|===
// endpoint options: END


### Usage


### Dependencies

Maven users will need to add the following dependency to their pom.xml.

*pom.xml*

[source,xml]
---------------------------------------
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-web3j</artifactId>
<version>${camel-version}</version>
</dependency>
---------------------------------------

where `${camel-version`} must be replaced by the actual version of Camel
(2.22 or higher).

### See Also

* Configuring Camel
* Component
* Endpoint
* Getting Started
@@ -0,0 +1,55 @@
/**
* 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.web3j;

import java.util.Map;

import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.impl.DefaultComponent;
import org.apache.camel.spi.Metadata;

/**
* Represents the component that manages {@link Web3jComponent}.
*/
public class Web3jComponent extends DefaultComponent {

@Metadata(description = "Default configuration")
private Web3jConfiguration configuration;

public Web3jComponent() {
}

public Web3jComponent(CamelContext camelContext) {
super(camelContext);
}

public Web3jConfiguration getConfiguration() {
return configuration;
}

public void setConfiguration(Web3jConfiguration configuration) {
this.configuration = configuration;
}

protected Endpoint createEndpoint(String uri, final String remaining, final Map<String, Object> parameters) throws Exception {
Web3jConfiguration conf = configuration != null ? configuration.copy() : new Web3jConfiguration();
setProperties(conf, parameters);
return new Web3jEndpoint(uri, remaining, this, conf);
}

}
Oops, something went wrong.

0 comments on commit ef2bbb8

Please sign in to comment.
You can’t perform that action at this time.