1 4 package com.nightlabs.ipanema.idgenerator; 5 6 import java.rmi.RemoteException ; 7 8 import javax.ejb.CreateException ; 9 import javax.ejb.EJBException ; 10 import javax.ejb.SessionBean ; 11 import javax.jdo.PersistenceManager; 12 13 import com.nightlabs.ModuleException; 14 import com.nightlabs.ipanema.base.BaseSessionBeanImpl; 15 16 25 26 public abstract class IDGeneratorBean extends BaseSessionBeanImpl implements SessionBean 27 { 28 31 public void ejbCreate() throws CreateException 32 { 33 try 34 { 35 System.out.println("IDGeneratorBean created by " + this.getPrincipalString()); 36 } 37 catch (ModuleException e) 38 { 39 throw new CreateException (e.getMessage()); 40 } 41 } 42 47 public void ejbRemove() throws EJBException , RemoteException { } 48 49 58 public long generateIDLong(String key) 59 throws ModuleException 60 { 61 PersistenceManager pm; 62 pm = getPersistenceManager(); 63 try 64 { 65 return IDGeneratorAssistant.generateIDLong(pm, key); 66 } finally { 67 pm.close(); 68 } 69 } 70 71 80 public int generateIDInt(String key) 81 throws ModuleException 82 { 83 PersistenceManager pm = getPersistenceManager(); 84 try { 85 return IDGeneratorAssistant.generateIDInt(pm, key); 86 } finally { 87 pm.close(); 88 } 89 } 90 91 } | Popular Tags |