openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@bea.com>
Subject RE: Setting a datasource and a transaction manager
Date Thu, 14 Dec 2006 01:21:19 GMT
I believe that you can set openjpa.ConnectionDriver property to the
actua DataSource to use, and OpenJPA will use it. Of course, you can
only do this in code, and if you use a Map (not a Properties object).

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: Matthieu Riou [mailto:matthieu.riou@gmail.com] 
> Sent: Wednesday, December 13, 2006 5:07 PM
> To: open-jpa-dev@incubator.apache.org
> Subject: Re: Setting a datasource and a transaction manager
> 
> But I can't use that. In the same way that I have to provide 
> the transaction
> manager to Kodo, I have to provide this transaction manager to the
> datasource as well. To create the datasource we're doing 
> something like:
> 
>         MinervaPool minervaPool = new MinervaPool();
>         minervaPool.setTransactionManager(_txMgr);
>         minervaPool.getConnectionFactory().setConnectionURL(url);
>         minervaPool.getConnectionFactory().setUserName("sa");
>         minervaPool.getConnectionFactory().setDriver(
>                 org.apache.derby.jdbc.EmbeddedDriver.class.getName());
> 
>         minervaPool.getPoolParams().maxSize = 
> _odeConfig.getPoolMaxSize();
>         minervaPool.getPoolParams().minSize = 
> _odeConfig.getPoolMinSize();
>         minervaPool.getPoolParams().blocking = false;
>         minervaPool.setType(MinervaPool.PoolType.MANAGED);
> 
>         try {
>             minervaPool.start();
>         } catch (Exception ex) {
>             String errmsg = __msgs.msgOdeDbPoolStartupFailed(url);
>             __log.error(errmsg, ex);
>             throw new ServletException(errmsg, ex);
>         }
> 
>         _datasource = minervaPool.createDataSource();
> 
> The most important things are to set the tx mgr and the type 
> of the pool to
> 'managed'. So if I use the "openjpa.ConnectionDriverName", would Kodo
> configure Miverva properly?
> 
> Thanks,
> 
> Matthieu
> 
> On 12/13/06, Marc Prud'hommeaux <mprudhom@apache.org> wrote:
> >
> > Matthieu-
> >
> > You can specify the full class name of your DataSource in the
> > "openjpa.ConnectionDriverName" property. This too is discussed at
> > http://incubator.apache.org/openjpa/docs/latest/manual/
> > manual.html#ref_guide_dbsetup
> >
> >
> >
> > On Dec 13, 2006, at 4:42 PM, Matthieu Riou wrote:
> >
> > > Sorry to be a pain but the thing is, we don't want to use 
> any JNDI to
> > > register our datasource. We just create our own so that would mean
> > > creating
> > > a whole JNDI registry just to pass a datasource to Kodo. So my
> > > question was
> > > whether there was the same type of interface I could implement to
> > > return our
> > > custom datasource.
> > >
> > > Thanks,
> > >
> > > Matthieu
> > >
> > > On 12/13/06, Marc Prud'hommeaux <mprudhom@apache.org> wrote:
> > >>
> > >> Matthieu-
> > >>
> > >> If you set the openjpa.ConnectionFactoryName to the JNDI 
> name of a
> > >> DataSource, then Kodo will use that.
> > >>
> > >> See: http://incubator.apache.org/openjpa/docs/latest/manual/
> > >> manual.html#ref_guide_dbsetup
> > >>
> > >>
> > >>
> > >> On Dec 13, 2006, at 4:21 PM, Matthieu Riou wrote:
> > >>
> > >> > Thanks Marc! And what about the datasource? Is there another
> > >> > equivalent
> > >> > interface and property to use?
> > >> >
> > >> > On 12/13/06, Marc Prud'hommeaux <mprudhom@apache.org> wrote:
> > >> >>
> > >> >> Matthieu-
> > >> >>
> > >> >> If you have a custom TransactionManager, you can tell Kodo to
> > >> access
> > >> >> it using a ManagedRuntime implementation (see http://
> > >> >> incubator.apache.org/openjpa/docs/latest/javadoc/org/apache/
> > >> openjpa/
> > >> >> ee/ManagedRuntime.html ).
> > >> >>
> > >> >> For example, if your TransactionManager is accessible 
> via the JNDI
> > >> >> name "comp/env/MyTransactionManager", then you could tell
> > >> OpenJPA to
> > >> >> access it by setting the "openjpa.ManagedRuntime" 
> property to the
> > >> >> value: "org.apache.openjpa.ee.JNDIManagedRuntime
> > >> >> 
> (TransactionManagerName=comp/env/MyTransactionManager)". For more
> > >> >> exotic mechanisms of accessing the TransactionManager, you can
> > >> just
> > >> >> make a custom implementation of the ManagedRuntime class.
> > >> >>
> > >> >> In the future, we intent to make this more standard by
> > >> utilizing the
> > >> >> new javax.transaction.TransactionSynchronizationRegistry
> > >> mechanism,
> > >> >> but for now, we have custom implementations for each of our
> > >> known and
> > >> >> supported application servers (see the code at http://
> > >> svn.apache.org/
> > >> >> 
> viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/
> > >> >> apache/openjpa/ee/AutomaticManagedRuntime.java?
> > >> >> view=markup&pathrev=468504 ).
> > >> >>
> > >> >> See also: 
> http://incubator.apache.org/openjpa/docs/latest/manual/
> > >> >> manual.html#ref_guide_enterprise_trans
> > >> >>
> > >> >>
> > >> >>
> > >> >>
> > >> >> On Dec 13, 2006, at 1:13 PM, Matthieu Riou wrote:
> > >> >>
> > >> >> > Hi JPA guys,
> > >> >> >
> > >> >> > In the Apache Ode podling we're currently working 
> on replacing
> > >> >> > Hibernate
> > >> >> > with OpenJPA. It's been working great so far but I have a
> > >> couple of
> > >> >> > questions. I'd need to set the transaction manager and the
> > >> >> datasource
> > >> >> > manually using the OpenJPA API and I've been unable 
> to find the
> > >> >> > right class
> > >> >> > and the right setters so far. Is there an easy way 
> to do that?
> > >> >> >
> > >> >> > The use case is we need to run both in containers with their
> > >> own tx
> > >> >> > manager
> > >> >> > (like Geronimo) and lightweight containers (like 
> Tomcat). In the
> > >> >> > lightweight
> > >> >> > case we instantiate our own transaction manager (JOTM) and
> > >> our own
> > >> >> > datasource (Minerva) and we don't need any JNDI (unnecessary
> > >> >> painful).
> > >> >> >
> > >> >> > I've been looking around and haven't found an easy 
> way. I could
> > >> >> > have a look
> > >> >> > at the sources but I figured that asking you 
> directly would be
> > >> >> > quicker.
> > >> >> >
> > >> >> > Thanks!
> > >> >> >
> > >> >> > Matthieu
> > >> >>
> > >> >>
> > >>
> > >>
> >
> >
> 

Mime
View raw message