geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: Problem at geronimo boot
Date Thu, 30 Aug 2007 06:55:11 GMT
I'd recommend a slight change...

            AbstractNameQuery query = new AbstractNameQuery 
(TransactionManager.class.getName ());
            Set<AbstractName> names = kernel.listGBeans(query);
            if (names.size() != 1) {
                throw new IllegalStateException("Expected one  
transaction manager, not " + names.size());
            }
            AbstractName name = names.iterator().next();
            TransactionManager transMg = (TransactionManager)  
kernel.getGBean(name);
            return (TransactionManager)transMg;

I don't think there's a good reason to use a proxy...

thanks
david jencks


On Aug 29, 2007, at 7:02 PM, Viet Nguyen wrote:

> Well I try your code Kevan, and I altered it some to get this:
>
> package org.hibernate.transaction;
>
> import java.util.Iterator;
> import java.util.Properties;
> import java.util.Set;
>
> import javax.transaction.TransactionManager ;
> import org.hibernate.HibernateException;
> import org.hibernate.transaction.TransactionManagerLookup;
>
> import org.apache.geronimo.gbean.AbstractName;
> import org.apache.geronimo.gbean.AbstractNameQuery;
> import org.apache.geronimo.kernel.Kernel;
> import org.apache.geronimo.kernel.KernelRegistry;
> import org.apache.geronimo.kernel.proxy.ProxyManager;
>
> public class GeronimoTransactionManagerLookup
>     implements TransactionManagerLookup {
>
>    public static final String UserTransactionName = "java:comp/ 
> UserTransaction";
>
>    public TransactionManager getTransactionManager(Properties  
> props) throws HibernateException {
>        try {
>            Kernel kernel = KernelRegistry.getSingleKernel();
>            ProxyManager proxyManager = kernel.getProxyManager();
>            AbstractNameQuery query = new AbstractNameQuery 
> (TransactionManager.class.getName ());
>            Set names = kernel.listGBeans(query);
>            AbstractName name = null;
>            for (Iterator it = names.iterator(); it.hasNext();)
>                name = (AbstractName) it.next();
>            Object transMg = (Object) proxyManager.createProxy(name,  
> TransactionManager.class);
>            return (TransactionManager)transMg;
>        }catch (Exception e) {
>            e.printStackTrace();
>            System.out.println();
>            throw new HibernateException("Geronimo Transaction  
> Manager Lookup Failed", e);
>        }
> }
>
>    public String getUserTransactionName() {
>        return UserTransactionName;
>    }
> }
>
> I tested it out and everything works on geronimo-jetty6-jee5-2.0.1
>
> So I hope you can test it out Paolos.
>
> Hope this works,
> Viet Nguyen


Mime
View raw message