1 22 package org.jboss.ejb3.test.regression; 23 24 import java.io.Serializable ; 25 import javax.ejb.PrePassivate ; 26 import javax.ejb.Remote ; 27 import javax.ejb.Stateful ; 28 import javax.naming.Context ; 29 import javax.naming.InitialContext ; 30 import javax.naming.NamingException ; 31 import javax.persistence.EntityManager; 32 import javax.persistence.PersistenceContext; 33 import javax.persistence.PersistenceContext; 34 import javax.transaction.UserTransaction ; 35 import javax.persistence.PersistenceContext; 36 import org.jboss.annotation.ejb.cache.simple.CacheConfig; 37 import org.jboss.ejb3.Container; 38 39 44 @Stateful 45 @CacheConfig(maxSize = 1000, idleTimeoutSeconds = 1) 46 @Remote (PassivationTest.class) 47 public class PassivationTestBean implements PassivationTest, Serializable 48 { 49 @PersistenceContext private EntityManager em; 50 51 52 public String echo(String echo) 53 { 54 System.out.println("***: " + echo); 55 try 56 { 57 InitialContext ctx = new InitialContext (); 58 UserTransaction ut = (UserTransaction )ctx.lookup(Container.ENC_CTX_NAME + "/UserTransaction"); 59 Context env = (Context )ctx.lookup(Container.ENC_CTX_NAME + "/env"); 60 EntityManager em2 = (EntityManager)env.lookup("EntityManager"); 61 } 62 catch (NamingException e) 63 { 64 throw new RuntimeException (e); 65 } 66 return echo; 67 } 68 69 public void createContact() 70 { 71 Contact c = new Contact(); 72 c.setEmail("bill@jboss.org"); 73 c.setName("Bill"); 74 c.setPhone("666-666-6666"); 75 em.persist(c); 76 } 77 78 @PrePassivate 79 public void prePassivate() 80 { 81 System.out.println("PASSIVATING!!!"); 82 } 83 } 84 | Popular Tags |