This section provides generic usage information and usage information per Java EE application server.
Within your EAR, you need to include the RAR.
If you use Maven, refer to the e-contract.be Maven repository via:
<repository> <id>e-contract</id> <url>https://www.e-contract.be/maven2/</url> <releases> <enabled>true</enabled> </releases> </repository>
Include within your Java EE application EAR the resource adapter RAR via:
<dependency> <groupId>be.e-contract.ethereum-resource-adapter</groupId> <artifactId>ethereum-rar</artifactId> <version>1.3.0</version> <type>rar</type> </dependency>
and as maven-ear-plugin
configuration under modules
you put:
<rarModule> <groupId>be.e-contract.ethereum-resource-adapter</groupId> <artifactId>ethereum-rar</artifactId> <bundleFileName>ethereum-ra.rar</bundleFileName> </rarModule>
also add web3j
as dependency within your EAR via:
<dependency> <groupId>org.web3j</groupId> <artifactId>core</artifactId> <version>${web3j.version}</version> </dependency>
within your EJB JAR or WAR you add the API dependency under dependencies
via:
<dependency> <groupId>be.e-contract.ethereum-resource-adapter</groupId> <artifactId>ethereum-ra-api</artifactId> <version>1.3.0</version> <scope>provided</scope> </dependency>
The EthereumConnectionFactory
will be available within JNDI under:
java:/EthereumConnectionFactory
Hence you can refer to it via:
@Resource(mappedName = "java:/EthereumConnectionFactory") private EthereumConnectionFactory ethereumConnectionFactory;
or in an application server independent way via:
@Resource(name = "EthereumConnectionFactory") private EthereumConnectionFactory ethereumConnectionFactory;
where you provide within your META-INF/jboss-ejb3.xml
to following mapping:
<jboss:enterprise-beans> <session> <ejb-name>YourBeanNameHere</ejb-name> <resource-ref> <res-ref-name>EthereumConnectionFactory</res-ref-name> <jndi-name>java:/EthereumConnectionFactory</jndi-name> </resource-ref> </session> </jboss:enterprise-beans>
For usage of the EthereumMessageListener
you need to refer to the resource adapter explicitly. Do this by adding the following to your META-INF/jboss-ejb3.xml
:
<assembly-descriptor> <mdb:resource-adapter-binding> <ejb-name>YourEthereumMDB</ejb-name> <mdb:resource-adapter-name>#ethereum-ra.rar</mdb:resource-adapter-name> </mdb:resource-adapter-binding> </assembly-descriptor>
Or via a JBoss specific annotation on the MDB class:
import org.jboss.ejb3.annotation.ResourceAdapter; @ResourceAdapter("#ethereum-ra.rar")
The EthereumConnectionFactory
will be available within JNDI under:
EthereumConnectionFactory
So you can refer to it via:
@Resource(name = "EthereumConnectionFactory") private EthereumConnectionFactory ethereumConnectionFactory;
where you provide within your META-INF/weblogic-ejb-jar.xml
to following mapping:
<weblogic-enterprise-bean> <ejb-name>YourBeanNameHere</ejb-name> <resource-description> <res-ref-name>EthereumConnectionFactory</res-ref-name> <jndi-name>EthereumConnectionFactory</jndi-name> </resource-description> </weblogic-enterprise-bean>
For usage of the EthereumMessageListener
you need to refer to the resource adapter explicitly. Do this by adding the following to your META-INF/weblogic-ejb-jar.xml
:
<weblogic-enterprise-bean> <ejb-name>YourEthereumMDB</ejb-name> <message-driven-descriptor> <resource-adapter-jndi-name>EthereumResourceAdapter</resource-adapter-jndi-name> </message-driven-descriptor> </weblogic-enterprise-bean>