...
| Code Block | ||
|---|---|---|
| ||
<!-------------------------------------------------------------------------------------- -->
<!-- Configure a Jotm instance which provides a javax.transaction.TransactionManager -->
<!-- and a javax.transaction.UserTransaction implementation. -->
<!-------------------------------------------------------------------------------------- -->
<New id="jotm" class="org.objectweb.jotm.Jotm">
<Arg type="boolean">True</Arg>
<Arg type="boolean">False</Arg>
<Call id="tm" name="getTransactionManager"/>
<Call id="ut" name="getUserTransaction"/>
</New>
<!-------------------------------------------------------------------------------------- -->
<!-- Set up the UserTransaction impl from JOTM as the transaction manager for jetty -->
<!-------------------------------------------------------------------------------------- -->
<New class="org.mortbay.jetty.plus.naming.Resource">
<Arg></Arg>
<Arg>javax.transaction.TransactionManager</Arg>
<Arg><Ref id="ut"/></Arg>
</New>
<New id="tx" class="org.mortbay.jetty.plus.naming.Transaction">
<Arg>
<Ref id="ut"/>
</Arg>
</New>
|
...
| Code Block | ||
|---|---|---|
| ||
<!-------------------------------------------------------------------------------------- -->
<!-- Set up a DataSource that is XA aware. JOTM uses XAPool for this. -->
<!-------------------------------------------------------------------------------------- -->
<New class="org.mortbay.jetty.plus.naming.Resource">
<Arg>myxadatasource</Arg>
<Arg>
<New id="myxadatasourceA" class="org.enhydra.jdbc.standard.StandardXADataSource">
<Set name="DriverName">org.apache.derby.jdbc.EmbeddedDriver</Set>
<Set name="Url">jdbc:derby:myderbyDB1A;create=true</Set>
<Set name="User"></Set>
<Set name="Password"></Set>
<Set name="transactionManager"><Ref id="tm"/></Set>
</New>
</Arg>
</New>
<New id="mydatasource" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/mydatasource</Arg>
<Arg>
<New class="org.enhydra.jdbc.pool.StandardXAPoolDataSource">
<Arg><Ref id="myxadatasourceA"/></Arg>
<Set name="DataSourceName">myxadatasource</Set>
</New>
</Arg>
</New>
<!-- If you want to be able to set up more references in webapp specific files -->
<!-- such as context deployment files and WEB-INF/jetty-env.xml files, you -->
<!-- need to save a reference to the JOTM tm object: -->
<Call name="setAttribute">
<Arg>tm</Arg>
<Arg><Ref id="tm"/></Arg>
</Call>
|
Now you can hookup a web.xml resource-ref entry for jdbc/mydatasource and then you'll be able to do lookups in your webapp of java:comp/env/jdbc/mydatasource.
...