1 22 package org.jboss.ejb3.test.regression.ejbthree653; 23 24 import javax.annotation.PostConstruct; 25 import javax.ejb.Remote ; 26 import javax.ejb.Stateless ; 27 28 34 @Stateless 35 @Remote (MyStateless.class) 36 public class MyStatelessBean 37 { 38 private static long currentThreadId; 39 40 43 @PostConstruct 44 public void ejb3Create() 45 { 46 System.out.println("New SessionBean " + this); 47 System.out.println("Thread " + Thread.currentThread().getId()); 48 if(currentThreadId == 0) 50 { 51 currentThreadId = Thread.currentThread().getId(); 52 } 53 else 54 { 55 if(Thread.currentThread().getId() == currentThreadId) 56 { 57 throw new IllegalStateException ("no new instance should be created"); 58 } 59 else 60 { 61 currentThreadId = Thread.currentThread().getId(); 63 } 64 } 65 } 66 67 public String sayHelloTo(String name) 68 { 69 return "Hi " + name; 70 } 71 } 72 | Popular Tags |