Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 486 invoked from network); 14 Dec 2006 01:07:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Dec 2006 01:07:47 -0000 Received: (qmail 50249 invoked by uid 500); 14 Dec 2006 01:07:29 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 50227 invoked by uid 500); 14 Dec 2006 01:07:29 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 50201 invoked by uid 99); 14 Dec 2006 01:07:29 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Dec 2006 17:07:29 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of matthieu.riou@gmail.com designates 64.233.182.186 as permitted sender) Received: from [64.233.182.186] (HELO nf-out-0910.google.com) (64.233.182.186) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Dec 2006 17:07:18 -0800 Received: by nf-out-0910.google.com with SMTP id a4so714803nfc for ; Wed, 13 Dec 2006 17:06:57 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:references; b=kVInmgz/618u5cg/9ottGGC8BnsHKPXg4YGgqGgfcMxHnQ15G/BAge0PcU0OdAK/uanEHbbnu2y3ceBZmTz8HLh3gYm78NUQSCTKMo+QI+W8CYA8XTVLEdYXWS5CfLQnf9ZGU/a3x1JOfKaSg8E9xBnBd7jwcGPc5iRyfz1SDIA= Received: by 10.49.12.4 with SMTP id p4mr477669nfi.1166058416718; Wed, 13 Dec 2006 17:06:56 -0800 (PST) Received: by 10.49.60.20 with HTTP; Wed, 13 Dec 2006 17:06:56 -0800 (PST) Message-ID: Date: Wed, 13 Dec 2006 17:06:56 -0800 From: "Matthieu Riou" Reply-To: matthieu.riou@gmail.com To: open-jpa-dev@incubator.apache.org Subject: Re: Setting a datasource and a transaction manager In-Reply-To: <7E796C3C-4388-463C-82CC-CEDEE6A1B497@apache.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_26630_32753142.1166058416676" References: <72A4C3D7-E4EB-4854-AEC0-D88C04565771@apache.org> <397C270A-E565-437A-9BAF-D17F277F8EAB@apache.org> <7E796C3C-4388-463C-82CC-CEDEE6A1B497@apache.org> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_26630_32753142.1166058416676 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 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 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 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 > >> >> > >> >> > >> > >> > > ------=_Part_26630_32753142.1166058416676--