1 /** 2 * EasyBeans 3 * Copyright (C) 2006 Bull S.A.S. 4 * Contact: easybeans@objectweb.org 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 * USA 20 * 21 * -------------------------------------------------------------------------- 22 * $Id: SFSBBeanManagedPCtxLifeCMETest00.java 965 2006-07-27 16:27:08Z studzine $ 23 * -------------------------------------------------------------------------- 24 */ 25 package org.objectweb.easybeans.tests.common.ejbs.stateful.beanmanaged.persistencectxlife; 26 27 import javax.annotation.PostConstruct; 28 import javax.annotation.Resource; 29 import javax.ejb.EJB; 30 import javax.ejb.Remote; 31 import javax.ejb.Remove; 32 import javax.ejb.Stateful; 33 import javax.ejb.TransactionManagement; 34 import javax.ejb.TransactionManagementType; 35 import javax.transaction.UserTransaction; 36 37 import org.objectweb.easybeans.tests.common.ejbs.base.persistencectxlife.ItfEntityFactory; 38 import org.objectweb.easybeans.tests.common.ejbs.base.persistencectxlife.ItfPCtxLifeCMETest00; 39 40 41 /** 42 * Persistence Context lifetime Tests. 43 * @author Eduardo Studzinski Estima de Castro 44 * @author Gisele Pinheiro Souza 45 * 46 */ 47 @Stateful(name="SFSBBeanManagedPCtxLifeCMETest00") 48 @Remote(ItfPCtxLifeCMETest00.class) 49 @TransactionManagement(value = TransactionManagementType.BEAN) 50 public class SFSBBeanManagedPCtxLifeCMETest00 implements ItfPCtxLifeCMETest00{ 51 52 /** 53 * Transaction. 54 */ 55 @Resource 56 private UserTransaction utx; 57 58 /** 59 * Bean. 60 */ 61 @EJB(mappedName="SFSBEntityFactoryCME00") 62 private ItfEntityFactory bean; 63 64 /** 65 * Starts a transaction. 66 * @throws Exception if a problem occurs. 67 */ 68 @PostConstruct 69 protected void beginTransaction() throws Exception{ 70 utx.begin(); 71 } 72 73 /** 74 * @see org.objectweb.easybeans.tests.common.ejbs.base.persistencectxlife.ItfPCtxLifeCMETest00 75 * @throws Exception if a problem occurs. 76 */ 77 public void create() throws Exception{ 78 bean.createEntity(); 79 bean.checkManaged(); 80 utx.commit(); 81 bean.checkManaged(); 82 } 83 84 /** 85 * @see org.objectweb.easybeans.tests.common.ejbs.base.persistencectxlife.ItfPCtxLifeCMETest00 86 */ 87 public void check(){ 88 bean.checkManaged(); 89 this.remove(); 90 } 91 92 /** 93 * Remove method. 94 */ 95 @Remove 96 private void remove(){ 97 bean.removeEntity(); 98 } 99 100 } 101