I believe that Romain was trying to be concise in his examples. In his examples, it can be surmised that he was using javax.sql.DataSource
or DataSource
. Despite that, though, this will work for any type of resource, even custom resources. There are also already implementations that you can check out:
In the page you mentioned, Romain also notes that your class can either implement org.apache.openejb.api.resource.PropertiesResourceProvider
, or supply a Properties provides();
method.
Here is a small example:
org.superbiz.provider.MyPropertiesReader.java
package org.superbiz.provider;
import org.apache.openejb.api.resource.PropertiesResourceProvider;
import org.apache.openejb.testng.PropertiesBuilder;
import java.util.Properties;
public class MyPropertiesReader implements PropertiesResourceProvider {
public Properties provides() {
return new PropertiesBuilder()
.p("JdbcDriver", "org.hsqldb.jdbcDriver")
.p("JdbcUrl", "jdbc:hsqldb:mem:moviedb")
.build();
}
}
src/main/webapp/WEB-INF/resources.xml
<resources>
<Resource id="movieDatabase"
type="DataSource"
properties-provider="org.superbiz.provider.MyPropertiesReader"/>
</resources>
These are the key snippets that I hope will help clear your doubts. Implementation of the datasource is left for you to code. :)