On Thu, Apr 15, 2004 at 06:46:10PM +0000, Derek McKee wrote:
> Hi,
>
> I'm trying to integrate OpenEJB0.9.2 and JOTM1.5.3 with Tomcat
> 4.1. Has anyone done this yet ?
> 
> Is there any documentation or examples that might help me in
> configuring OpenEJB to use the JOTM transaction manager instead of
> its OpenEJB's default one?

No one has done it to my knowledge, but it is certainly possible.

IMPLEMENTATION

First, you wrap the transaction manager with the interface 
org.openejb.spi.TransactionService (see http://www.openejb.org/design_txservice.html)

So something like:

---------------
package org.acme;

import javax.transaction.TransactionManager;

class JOTMService implements org.openejb.spi.TransactionService {

   private TransactionManager jotm;

   public void init(java.util.Properties props)
   throws Exception {
       // Use the properties to configure and create a JOTM 

       jotm = ...
   }

   public TransactionManager getTransactionManager(){
       return jotm;
   }
}
---------------

The idea of the wrapper is that you use it to any work required to get
an actual JOTM transaction manager configured and ready to go.  The
properties passed into the init(...) method can be whatever you want.
They come for the service-jar.xml (more on that later) and are
overwritten by anything in the related section in openejb.conf.  

The practice is that you put enough default properties in the
service-jar.xml to get something running and use the service's section
of the openejb.conf to override and tweak those values.  You may need
to change things from time to time, such as file locations, hostnames,
etc.

PACAKGING

You need to create a jar containing:
  1. The TransactionService wrapper class.
  2. The JOTM classes.
  3. A META-INF/service-jar.xml 

The service-jar.xml is like a deployment descriptor for services
deployable in OpenEJB.  Here is an example doc on creating one for a
J2EE Connector (http://www.openejb.org/connector_service.html).  Yours
would look something like this:

---------------
<?xml version="1.0"?>

<ServiceJar>

<ServiceProvider id="JOTM Transaction Manager"
        provider-type="TransactionService"
        class-name="org.acme.JOTMService">

# The default properties of the JOTMService
foo = bar

# Comments are ignored
somefile = C:\default\location

life.universe.everything = 42

</ServiceProvider>

</ServiceJar>
---------------

Once you jar all that stuff up, you "deploy" it into your openejb.conf
file and edit any values you need.

<openejb>
  <Container id="Default CMP Container" ctype="CMP_ENTITY">
    Global_TX_Database  c:/my/app/conf/postgresql.cmp_global_database.xml
    Local_TX_Database   c:/my/app/conf/postgresql.cmp_local_database.xml
  </Container>
  <Deployments jar="c:/my/app/employee.jar"/>

  ...// all the other stuff

  <TransactionService id="JOTM Transaction Manager" 
jar="c:/foo/my/app/jotm-service.jar">
    # override this property to point to an
    # actual some other file
    somefile = C:/this/file

    # Feel free to add a new property if you want
    the.question = 6x9
  </Connector>
</openejb>

Well, there is a short how-to I didn't expect to write ;) Let me know
how it goes.  We'll be happy to publish your jotm service jar for
download if you get things working.

-David

Reply via email to