Re: Does OJB supports Geronimo?

Armin Waibel <[email protected]>
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Hi Andreas,

Andreas Bohnert wrote:
> hi,
> 
> I wonder if OJB supports Geronimo. I haven't found an TransactionManager
> in /org/apache/ojb/broker/transaction/tm, also I haven't found any
> geronimo topics in the mailing list or the documentation.
> 
> Are there any Geronimo users here?
> 
> I try to migrate from jboss to geronimo, but now I'm doubtful, if I will
> be sucessful, if there is no transactionmager to use ...
>

Sorry Geronimo support is on my todo-list, but it slipped my mind.

To implement the TransactionManagerFactory I this document about 
JBoss/Hibernate migration (scroll down to GeronimoTransactionManagerLookup)
http://cwiki.apache.org/GMOxDOC10/jboss-to-geronimo-hibernate-migration.html

The OJB version (compatible with current sources) will look like this:

public class GeronimoTransactionManagerFactory implements 
TransactionManagerFactory
{
     public static final String 
TransactionMgrGBeanName="geronimo.server:J2EEApplication=null," +
 
"J2EEModule=geronimo/j2ee-server/1.0/car,J2EEServer=geronimo,j2eeType=TransactionManager," 
+
             "name=TransactionManager";

     private TransactionManager tm;

     public TransactionManager getTransactionManager() throws 
TransactionManagerFactoryException
     {
         if(tm == null)
         {
             tm = lookupManager();
         }
         return tm;
     }

     private TransactionManager lookupManager() throws 
TransactionManagerFactoryException
     {
         try
         {
             Class kernelClass = 
ClassHelper.getClass("org.apache.geronimo.kernel.Kernel");
             Class kernelRegistryClass = 
ClassHelper.getClass("org.apache.geronimo.kernel.KernelRegistry");
             Class proxyManagerClass = 
ClassHelper.getClass("org.apache.geronimo.kernel.proxy.ProxyManager");
             Class objectNameClass = 
ClassHelper.getClass("javax.management.ObjectName");

             Object transactionManagerName = ClassHelper.newInstance(
                     objectNameClass, String.class, 
TransactionMgrGBeanName);
             Object kernel = 
kernelRegistryClass.getMethod("getSingleKernel", null).invoke(null, null);
             Object proxyManager = 
kernelClass.getMethod("getProxyManager", null).invoke(kernel, null);
             Class[] clzArray = {objectNameClass, Class.class};
             Object[] objArray = {transactionManagerName, 
TransactionManager.class};
             return (TransactionManager) 
proxyManagerClass.getMethod("createProxy", clzArray)
                     .invoke(proxyManager, objArray);

         }
         catch(Exception e)
         {
             throw new TransactionManagerFactoryException("Geronimo 
Transaction Manager Lookup Failed", e);
         }
     }
}

It would be great if you could check this class.

regards,
Armin


> Thanks for your help,
> andreas
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.