1 6 package org.jfox.ejb; 7 8 import org.jfox.ioc.util.ObjectUUID; 9 10 15 16 public class EJBObjectIDGenerator { 17 private String ejbName; 18 private String homeInterf; 19 private String remoteInterf; 20 private ObjectUUID homeUUID; 21 22 23 private EJBObjectIDGenerator(String ejbName, String homeIntef, String remoteInterf) { 24 this.ejbName = ejbName; 25 this.homeInterf = homeIntef; 26 this.remoteInterf = remoteInterf; 27 this.homeUUID = ObjectUUID.randomUUID(); 28 } 29 30 34 public static EJBObjectIDGenerator newInstance(String ejbName, String homeInterf, String remoteInterf) { 35 return new EJBObjectIDGenerator(ejbName, homeInterf, remoteInterf); 36 } 37 38 public EJBObjectId getHomeObjectId() { 39 return new EJBObjectId(ejbName, homeInterf, remoteInterf, homeUUID, true); 40 } 41 42 public EJBObjectId nextBeanObjectId() { 43 return new EJBObjectId(ejbName, homeInterf, remoteInterf, ObjectUUID.randomUUID(), false); 44 } 45 46 public static void main(String [] args) throws Exception { 47 EJBObjectIDGenerator oig = EJBObjectIDGenerator.newInstance("ejb/test", "org.jfox.TestHome", "org.jfox.Test"); 48 System.out.println(oig.getHomeObjectId()); 49 System.out.println(oig.nextBeanObjectId()); 50 oig = EJBObjectIDGenerator.newInstance("ejb/test", "org.jfox.TestHome", "org.jfox.Test"); 51 System.out.println(oig.getHomeObjectId()); 52 System.out.println(oig.nextBeanObjectId()); 53 54 } 55 } 56 | Popular Tags |