1 22 package org.jboss.test.idgen.ejb; 23 24 import java.rmi.RemoteException ; 25 import javax.ejb.*; 26 import javax.naming.*; 27 28 import org.jboss.test.util.ejb.EntitySupport; 29 30 36 public abstract class IdCounterBean 37 extends EntitySupport 38 { 39 long nextId; 40 long size; 41 42 public long getNextValue() 43 { 44 47 if (nextId == (getCurrentValue() + size)) 48 { 49 setCurrentValue(nextId); 50 } 51 52 return nextId++; 53 } 54 55 public abstract long getCurrentValue(); 56 public abstract void setCurrentValue(long current); 57 58 public abstract String getName(); 59 public abstract void setName(String beanName); 60 61 public void ejbLoad() 62 throws RemoteException 63 { 64 nextId = getCurrentValue(); 65 } 66 67 public void setEntityContext(EntityContext ctx) 68 throws RemoteException 69 { 70 super.setEntityContext(ctx); 71 72 try { 73 size = ((Long )new InitialContext().lookup("java:comp/env/size")).longValue(); 74 } 75 catch (Exception e) { 76 throw new EJBException(e); 77 } 78 } 79 } 80 | Popular Tags |