Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 7606 invoked from network); 21 Feb 2007 21:22:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Feb 2007 21:22:37 -0000 Received: (qmail 8990 invoked by uid 500); 21 Feb 2007 21:22:45 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 8979 invoked by uid 99); 21 Feb 2007 21:22:45 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Feb 2007 13:22:45 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [192.18.42.249] (HELO nwk-ea-fw-1.sun.com) (192.18.42.249) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Feb 2007 13:22:32 -0800 Received: from d1-sfbay-09.sun.com ([192.18.39.119]) by nwk-ea-fw-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id l1LLM8ZY024913 for ; Wed, 21 Feb 2007 13:22:08 -0800 (PST) Received: from conversion-daemon.d1-sfbay-09.sun.com by d1-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) id <0JDU00C010MXJK00@d1-sfbay-09.sun.com> (original mail from Craig.Russell@Sun.COM) for jdo-dev@db.apache.org; Wed, 21 Feb 2007 13:22:08 -0800 (PST) Received: from [129.144.89.131] by d1-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPSA id <0JDU00CEE0OVPJ70@d1-sfbay-09.sun.com> for jdo-dev@db.apache.org; Wed, 21 Feb 2007 13:22:07 -0800 (PST) Date: Wed, 21 Feb 2007 13:22:07 -0800 From: Craig L Russell Subject: Re: [DISCUSS] getPersistenceManagerProxy In-reply-to: Sender: Craig.Russell@Sun.COM To: jdo-dev@db.apache.org Message-id: <83B6D6D7-D818-4D87-9E21-08BF2D4AFFE7@SUN.com> MIME-version: 1.0 X-Mailer: Apple Mail (2.752.2) Content-type: multipart/signed; protocol="application/pkcs7-signature"; boundary=Apple-Mail-11-512199377; micalg=sha1 References: <24d3172c0702120439o26b5d9f0ub63a9e921b1223eb@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-11-512199377 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Feb 21, 2007, at 12:24 AM, Guido Anzuoni wrote: > Craig L Russell Sun.COM> writes: > >> >> Hi Guido, >> >> Thanks for your comments. >> >> On Feb 12, 2007, at 4:39 AM, Guido Anzuoni wrote: >> >>> when >>> it associate the PM with the transaction, but there could be >>> ordering issues >>> with other Synchronization objects referencing >>> the same PM. >> >> I believe that this scenario is covered already in the specification. >> The PM is responsible to call the user's registered Synchronization >> instance during transaction completion. The proxy does not complicate >> this existing usage. > > Well, maybe it's too late, but, you know, thinking process might > take some time :) > I have some extra comments on closing PM in a JTA scenario. > You say that actually the real PM is closed by the afterCompletion > registered by the real PersistenceManager. > I disagree on this. > PersistenceManager outlives the transaction boundaries, either > global or local. > You can have the following usage: > PersistenceManager pm = ... > UserTransaction ut = ... > ut.begin(); > pm.makePersistent(); > ut.commit(); > ... > ut.begin(); > pm.makePersistent(); > ut.commit(); > .. > pm.close(); I think this case doesn't need a proxy at all. The proxy is needed if your use case requires binding to a different pm each time, based on the existence of a container-managed transaction. If you want to manage the life cycle of the pm yourself, and manage transactions yourself, there is no need for a proxy. > > In a proxy-based scenario the real PM has a lifecycle that is > completely bound > to the (global) transaction lifespan: it is created when the user > requires > a PM the first time and is closed by the proxy upon completion > (Synchronization.afterCompletion on the JTA transaction). > This lead to the assumption that: > 1. no PM (proxy) can be acquired without an open JTA transaction Actually, I've updated the spec such that in the case of using the proxy without a JTA transaction, a PM will be created that does its work outside a transaction. > 2. Synchronization.afterCompletion of the proxy should be called > **after** any > other Synchronization that might be registered by the real > implementation on > the JTA transaction itself (this is critical because JTA does not > enforce any > ordering in Synchronization objects). This is done by containers that implement javax.transaction.TransactionSynchronizationRegistry, a new feature of Java EE 5. JDO implementations that use non-TSR containers need to have a private contract with the container so that the proper ordering is done. > An alternative to guarantee that > the proxy Synchronization.afterCompletion is invoked after > any "finalization" actions performed by the PM, is to register the > synchro > on pm.currentTransaction(), but this would "consume" the only slot > available. We looked at allowing users to register multiple synchronizations with the JDO Transaction, but concluded that it would be a rare case where the synchronizations would truly be independent. > This would not be a big problem, because the real pm remains almost > hidden > to the app (unless JDOHelper.getPersistenceManager(o) is called). The current design does allow the user to get access to the "real PM" but I don't think that this is a major problem. Any code that deliberately bypasses the proxy usage by storing the real PM and using it out of scope will simply get a "PM has been closed" exception. > > What I like is the JDO implementations being unaware of > PersistenceManagerProxy, > so it is responsibility of the proxy to close the real pm. Me too. Craig > > Guido. > > > Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:Craig.Russell@sun.com P.S. A good JDO? O, Gasp! --Apple-Mail-11-512199377 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGUDCCAwkw ggJyoAMCAQICECpJVMO68ii+Xfsc1O1YYFIwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA2MTIwOTE5NTEwNVoXDTA3MTIwOTE5NTEw NVowbDEQMA4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