geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: Spring support in Geronimo
Date Fri, 03 Feb 2006 16:54:29 GMT
This looks like it should work.  I think there is some chance that it  
would work even better if we provided a transaction manager that  
wraps our transactioncontextmanager, but it's too early in the  
morning for me to think straight about it.  If you get into problem  
with connections not being returned to the pool let me know and I  
will think about it harder.  How do you provide access to the jdbc  
connection?  By declaring a resource-ref in the j2ee component that  
is calling hibernate, or some other way?

thanks
david jencks

On Feb 3, 2006, at 12:42 AM, Jason Dillon wrote:

>> It looks like you can be the first to test out my new  
>> SpringTransactionManager :-).  It wraps our  
>> TransactionContextManager in a PlatformTransactionManager  
>> subclass.  You need to give it 2 constructor args, the kernel name  
>> and the tcm object name.  The normal values are in the comments in  
>> the class.
>
> Aight... kick it down yo.
>
>
>> What does Hibernate need?   Can it work off a spring tm or does it  
>> need something else?
>
> I think it wants a special lookup class... I wrote one up tonight  
> based on comments to the dev list a while ago... creating a proxy  
> to the TransactionManager instance.  I have yet to test it though.
>
>
>> If you can come up with some kind of spring app that ought to work  
>> and uses the spring tm I would be able to test and perhaps debug  
>> my code :-)
>
> I might be able to come up with something simple... though right  
> now first priority is to just get something... anything working  
> inside of Geronimo so our SE dept. can test it.
>
> Anyways, looks like spring needs a Geronimo version like:
>
> http://www.springframework.org/docs/api/org/springframework/ 
> transaction/jta/WebSphereTransactionManagerFactoryBean.html
>
> I've yet to look at what this puppy does.
>
> And Hibernate needs a Geronimo version of:
>
> http://cvs.sourceforge.net/viewcvs.py/hibernate/Hibernate3/src/org/ 
> hibernate/transaction/JOTMTransactionManagerLookup.java? 
> rev=1.1&view=auto
>
> This is what I wrote and will be testing out tomorrow.
>
> <snip>
> package com.solidusnetworks.utils.geronimo;
>
> import java.util.Properties;
>
> import javax.transaction.TransactionManager;
> import javax.management.ObjectName;
>
> import net.sf.hibernate.HibernateException;
> import net.sf.hibernate.transaction.TransactionManagerLookup;
>
> import org.apache.geronimo.kernel.Kernel;
> import org.apache.geronimo.kernel.KernelRegistry;
>
> /**
> * Provides lookup of the Geronimo (1.0) transaction manager.
> *
> * @version $Id$ $Date$
> * @author <a href="mailto:jason.dillon@paybytouch.com">Jason  
> Dillon</a>
> */
> public class GeronimoTransactionManagerLookup
>     implements TransactionManagerLookup
> {
>     public static final String TXM_GBEAN_NAME =  
> "geronimo.server:J2EEApplication=null,J2EEModule=geronimo/j2ee- 
> server/1.0/ 
> car,J2EEServer=geronimo,j2eeType=TransactionManager,name=TransactionMa 
> nager";
>     public static final String USER_TXN_NAME = "java:comp/ 
> UserTransaction";
>
> 	public TransactionManager getTransactionManager(final Properties  
> props) throws HibernateException {
> 		try {
>             //
>             // FIXME: This is probably not work when Geronimo  
> versions change... :-(
>             //
>             ObjectName TM_NAME = new ObjectName(TXM_GBEAN_NAME);
>             Kernel kernel = KernelRegistry.getSingleKernel();
>             return (TransactionManager) kernel.getProxyManager 
> ().createProxy(TM_NAME, TransactionManager.class);
> 		}
> 		catch (Exception e) {
> 			throw new HibernateException("Failed to lookup Geronimo  
> transaction manager", e);
> 		}
> 	}
>
> 	public String getUserTransactionName() {
> 		return USER_TXN_NAME;
> 	}
> }
> </snip>
>
> --jason


Mime
View raw message