-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a Camel connector for Ethereum blockchain using Web3j library
- Loading branch information
Showing
48 changed files
with
5,634 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
55 changes: 55 additions & 0 deletions
55
components/camel-web3j/src/main/java/org/apache/camel/component/web3j/Web3jComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.