tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gegas <andreas.lc.eriks...@gmail.com>
Subject Re: No Maven2 Best Practices?
Date Tue, 13 May 2008 11:38:00 GMT


David Blevins wrote:
> 
> 
> Don't know why I didn't think of this before, but we could just add  
> some support for checking and resetting that property if hibernate is  
> your persistence provider.  Not sure why they make you set it in the  
> first place, they could easily figure out which lookup strategy to use  
> on their own.
> 
> In the meantime, you can use a custom lookup strategy like this:
> 
> import org.hibernate.HibernateException;
> import org.hibernate.transaction.TransactionManagerLookup;
> import javax.transaction.TransactionManager;
> import java.util.Properties;
> 
> public class DynamicTransactionManagerLookup implements  
> TransactionManagerLookup {
> 
>      private TransactionManagerLookup impl;
> 
>      public DynamicTransactionManagerLookup() {
>          String[] strategies = {
>                   
> "org.apache.openejb.hibernate.TransactionManagerLookup",
>                   
> "org.hibernate.transaction.JBossTransactionManagerLookup"
>          };
>          for (String className : strategies) {
>              try {
>                  Class<?> clazz =  
> this.getClass().getClassLoader().loadClass(className);
>                  impl = (TransactionManagerLookup) clazz.newInstance();
>              } catch (Exception e) {
>              }
>          }
> 
>          if (impl == null) throw new IllegalStateException("No  
> TransactionManagerLookup available");
>      }
> 
>      public TransactionManager getTransactionManager(Properties  
> properties) throws HibernateException {
>          return impl.getTransactionManager(properties);
>      }
> 
>      public String getUserTransactionName() {
>          return impl.getUserTransactionName();
>      }
> }
> 
> 
> 

I'm sorry David but I cannot see how this would help? The code isn't
complete and that's intended, or am I missing something?

Kind regards, Andreas

-- 
View this message in context: http://www.nabble.com/No-Maven2-Best-Practices--tp17129308p17206415.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Mime
View raw message