- The changed classloading to a more OSGI like architecture.
- The simplification of have only one configuration file.
You find module in $JBOSS_HOME/modules folder. To create a new module you need to do three things:
- Create a folder hierarchy for files.
- Copy module jar files.
- Create module configuration file – module.xml.
$ mkdir -p $JBOSS_HOME/modules/com/mysql/main
$ cp mysql-connector-java-5.1.19.jar $JBOSS_HOME/modules/com/mysql/mainmysql-connector-java-5.1.19.jar
$ touch $JBOSS_HOME/modules/com/mysql/main/module.xml
Now edit the module.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.19.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
Now you are ready to use configure your DataSource. Here I will use the JBoss Standalone and not the Domain configuration. In short the main differences between Module and Standalone JBoss configuration is if you want to reuse your configuration through several JBoss instance you shoud use the Domain configuration approach. In this blog I will use the Standalone configuration, but the differences of doing the other way around is not big.
The configuration of the JBoss can be done in several way: 1. CLI 2. Web interface 3. or manually through editing xml file. Which way you choose is up to you, here I will show the result.
$JBOSS_HOME/standalone/configuration/standalone.xml:
<subsystem xmlns="urn:jboss:domain:datasources:1.1">
<datasources>
...
<datasource jndi-name="java:jboss/datasources/YourProjectDS" pool-name="YourProjectDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/YourProjectDB</connection-url>
<driver>mysql</driver>
<security>
<user-name>uid</user-name>
<password>pwd</password>
</security>
</datasource>
<drivers>
...
<driver name="mysql" module="com.mysql"/>
</drivers>
</datasources>
</subsystem>
No comments:
Post a Comment