<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>RE: [seam-dev] Implementing REQUIRES_NEW for seam transaction management</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>

<P><FONT SIZE=2>It is pluggable, you create a component that extends SeamTransactionManager and install it over the top of the default implementation, or if the TransactionManager is in jndi but in a different location then that can be configured through components.xml as well.<BR>
<BR>
I'm not going to write app server specific components and documentation until after I have got the rest of the patch complete.<BR>
<BR>
<BR>
Stuart<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: Pete Muir [<A HREF="mailto:pmuir@redhat.com">mailto:pmuir@redhat.com</A>]<BR>
Sent: Thu 3/09/2009 12:58 AM<BR>
To: Denis Forveille<BR>
Cc: Stuart Douglas; seam-dev@lists.jboss.org<BR>
Subject: Re: [seam-dev] Implementing REQUIRES_NEW for seam transaction management<BR>
<BR>
<BR>
On 2 Sep 2009, at 09:44, Denis Forveille wrote:<BR>
<BR>
&gt; Stuart,<BR>
&gt;<BR>
&gt; I don't agree with the proposed patch as it assume that the<BR>
&gt; &quot;TransactionManager&quot; is exposed and accessible to the applications and<BR>
&gt; is bound in JNDI&nbsp; (you assume &quot;java:/TransactionManager&quot; as the<BR>
&gt; default name)<BR>
&gt;<BR>
&gt; As said before, this is not part of the J2EE contract for the AS to<BR>
&gt; expose their TransactionManager and some do not, like WebSphere.<BR>
<BR>
This is correct, and has not been fixed in Java EE.<BR>
<BR>
If you really need a portable way to get the TM, you would need to&nbsp;<BR>
make this a pluggable service provider.<BR>
<BR>
&gt;<BR>
&gt; To my knowledge, there is no &quot;standard&quot; way to get this object in J2EE<BR>
&gt; and every AS may have their way, some may not exposes it at all.<BR>
&gt;<BR>
&gt; If you want to know what WebSphere officially exposes to users<BR>
&gt; concerning transactions management, , you should read this article in<BR>
&gt; the WebSphere information center :<BR>
&gt; <A HREF="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.express.doc/info/exp/ae/cjta_extjta.html">http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.express.doc/info/exp/ae/cjta_extjta.html</A><BR>
&gt;<BR>
&gt; One &quot;easy&quot; solution could be to declare that this functionality is<BR>
&gt; only available to AS that expose their TransactionManager via JNDI,<BR>
&gt; but thsi is not very elegant for a framework like Seam to do that<BR>
&gt; IMHO.<BR>
&gt;<BR>
&gt; Denis<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt; 2009/9/2 Stuart Douglas &lt;stuart@baileyroberts.com.au&gt;:<BR>
&gt;&gt; I have attached the first version of the REQUIRES_NEW patch to<BR>
&gt;&gt; JBSEAM-4391.<BR>
&gt;&gt;<BR>
&gt;&gt;<BR>
&gt;&gt; It seems to work ok, however I have not yet created the tests for it,<BR>
&gt;&gt; and at the moment I have only supplied a simple transaction manager&nbsp;<BR>
&gt;&gt; that<BR>
&gt;&gt; looks up the JTA TransactionManager from JNDI.<BR>
&gt;&gt;<BR>
&gt;&gt; I do however have a few questions about the best way to handle<BR>
&gt;&gt; persistence context propagation. The SMPC does not properly support<BR>
&gt;&gt; REQUIRES_NEW on EJB's (you should use @PersistenceContext instead),&nbsp;<BR>
&gt;&gt; and<BR>
&gt;&gt; it also will not properly support REQUIRES_NEW on seam components.<BR>
&gt;&gt;<BR>
&gt;&gt; This is a much bigger problem for seam components, as there is not<BR>
&gt;&gt; direct equivalent of @PersistenceContext. I have a few solutions in<BR>
&gt;&gt; mind:<BR>
&gt;&gt;<BR>
&gt;&gt; 1) When suspending the transaction pull all persistence contexts&nbsp;<BR>
&gt;&gt; out of<BR>
&gt;&gt; all scopes and store them in a map, when the original transaction<BR>
&gt;&gt; resumes put them back (there is more to it that this, like do we&nbsp;<BR>
&gt;&gt; flush<BR>
&gt;&gt; the PC's that are created in the new transaction).<BR>
&gt;&gt;<BR>
&gt;&gt; 2) Place some kind of warning in the log whenever a user accesses a<BR>
&gt;&gt; persistence context that they shouldn't. This would probably require<BR>
&gt;&gt; hacking up the ManagedPersistenceContext class, and would not really<BR>
&gt;&gt; help the use get hold of an EntityManager they are allowed to use.<BR>
&gt;&gt;<BR>
&gt;&gt; 3) Do nothing, but document this in the manual. The user would have&nbsp;<BR>
&gt;&gt; to<BR>
&gt;&gt; create their own entity managers by getting hold of an<BR>
&gt;&gt; EntityManagerFactory.<BR>
&gt;&gt;<BR>
&gt;&gt;<BR>
&gt;&gt; Comments?<BR>
&gt;&gt;<BR>
&gt;&gt; Stuart<BR>
&gt;&gt;<BR>
&gt;&gt;<BR>
&gt;&gt;<BR>
&gt;&gt;<BR>
&gt;&gt;<BR>
&gt;&gt;<BR>
&gt;&gt; On Mon, 2009-08-31 at 14:36 -0400, Dan Allen wrote:<BR>
&gt;&gt;&gt; On Wed, Aug 26, 2009 at 8:55 PM, Stuart Douglas<BR>
&gt;&gt;&gt; &lt;stuart@baileyroberts.com.au&gt; wrote:<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I would like to implement REQUIRES_NEW as a transaction type<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for the<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @Transactional annotation. My basic plan is:<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Create a TransactionManager component that can be&nbsp;<BR>
&gt;&gt;&gt; installed<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; into<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; components.xml, and give the option to configure the JNDI<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; location of<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the JTA TransactionManager.<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - modify the Work.workInTransaction method to check if the<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; existing<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transaction need to be suspended, as if so use the<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TransactionManager<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; component to suspend and resume the transaction.<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I can't help thinking that there is some problem with this<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; approach,<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; otherwise someone else would have already done it.<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt; Try it, create some tests and if it works, prove it.<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I also know that TransactionManager is not supposed to be&nbsp;<BR>
&gt;&gt;&gt; used<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; by the<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; application, does anyone know if this will cause problems?<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt; Spring has been doing this for a long time. It's of course app&nbsp;<BR>
&gt;&gt;&gt; server<BR>
&gt;&gt;&gt; dependent, but the general feeling is that using it is so common to<BR>
&gt;&gt;&gt; consider it a public API.<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I would also like to implement the ability to control seam<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; global<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transactions based on a flag in pages.xml, so they can be<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; disabled for<BR>
&gt;&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; specific views. Would anyone have any objections to this?<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt; I've always been in favor of this idea.<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt; -Dan<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt; --<BR>
&gt;&gt;&gt; Dan Allen<BR>
&gt;&gt;&gt; Senior Software Engineer, Red Hat | Author of Seam in Action<BR>
&gt;&gt;&gt; Registered Linux User #231597<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt; <A HREF="http://mojavelinux.com">http://mojavelinux.com</A><BR>
&gt;&gt;&gt; <A HREF="http://mojavelinux.com/seaminaction">http://mojavelinux.com/seaminaction</A><BR>
&gt;&gt;&gt; <A HREF="http://in.relation.to/Bloggers/Dan">http://in.relation.to/Bloggers/Dan</A><BR>
&gt;&gt; _______________________________________________<BR>
&gt;&gt; seam-dev mailing list<BR>
&gt;&gt; seam-dev@lists.jboss.org<BR>
&gt;&gt; <A HREF="https://lists.jboss.org/mailman/listinfo/seam-dev">https://lists.jboss.org/mailman/listinfo/seam-dev</A><BR>
&gt;&gt;<BR>
&gt;<BR>
&gt; _______________________________________________<BR>
&gt; seam-dev mailing list<BR>
&gt; seam-dev@lists.jboss.org<BR>
&gt; <A HREF="https://lists.jboss.org/mailman/listinfo/seam-dev">https://lists.jboss.org/mailman/listinfo/seam-dev</A><BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>