1 //----------------------------------------------------------------------
2 //
3 // PerfectJPattern: "Design patterns are good but components are better!"
4 // JpaManagedTransactionStrategy.java Copyright (c) 2009 Giovanni Azua Garcia
5 // bravegag@hotmail.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 3
10 // of the License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, see <http://www.gnu.org/licenses/>.
19 //
20 //----------------------------------------------------------------------
21 package org.perfectjpattern.jee.integration.dao;
22
23 import org.apache.commons.lang.*;
24 import org.perfectjpattern.jee.api.integration.dao.*;
25
26 /**
27 * Concrete implementation of {@link ITransactionStrategy} targeting
28 * the Ejb managed environment
29 *
30 * @author <a href="mailto:bravegag@hotmail.com">Giovanni Azua</a>
31 * @version $Revision: 1.0 $Date: Feb 8, 2009 5:24:51 PM $
32 */
33 public final
34 class JpaManagedTransactionStrategy
35 implements ITransactionStrategy
36 {
37 //------------------------------------------------------------------------
38 // public
39 //------------------------------------------------------------------------
40 /**
41 * Sets the sessionStrategy
42 *
43 * @param anSessionStrategy the sessionStrategy to set
44 */
45 public final void
46 setSessionStrategy(ISessionStrategy aSessionStrategy)
47 {
48 Validate.notNull(aSessionStrategy,
49 "'aSessionStrategy' must not be null");
50
51 theSessionStrategy = aSessionStrategy;
52 }
53
54 //------------------------------------------------------------------------
55 /**
56 * {@inheritDoc}
57 */
58 public ITransaction
59 getTransaction()
60 {
61 return theSessionStrategy.getSession().getTransaction();
62 }
63
64 //------------------------------------------------------------------------
65 // members
66 //------------------------------------------------------------------------
67 private ISessionStrategy theSessionStrategy;
68 }