1 25 26 package org.objectweb.jonas.jtests.beans.sequence; 27 28 29 import java.rmi.RemoteException ; 30 31 import javax.ejb.CreateException ; 32 import javax.ejb.EJBException ; 33 import javax.ejb.FinderException ; 34 import javax.ejb.RemoveException ; 35 import javax.ejb.SessionBean ; 36 import javax.ejb.SessionContext ; 37 import javax.naming.InitialContext ; 38 import javax.naming.NamingException ; 39 40 41 47 public class SequenceSesSL implements SessionBean { 48 49 private SessionContext sessionContext; 50 private SequenceHomeLocal sequenceHome; 51 52 public void ejbCreate() { 53 } 54 55 63 public int nextKey(String id) throws FinderException { 64 SequenceLocal sequence = null; 65 int ret = 0; 66 67 try { 68 sequence = sequenceHome.findByPrimaryKey(id); 69 ret = sequence.getUniqPk(); 70 } catch (EJBException e) { 71 e.printStackTrace(); 72 throw e; 73 } 74 System.out.println(">>>> Next PK: " + ret); 75 return ret; 76 } 77 78 public void ejbRemove() { 79 } 80 81 public void ejbActivate() { 82 } 83 84 public void ejbPassivate() { 85 } 86 87 public void setSessionContext(SessionContext sessionContext) { 88 89 this.sessionContext = sessionContext; 90 91 InitialContext initCtx = null; 92 try { 93 initCtx = new InitialContext (); 94 } catch( NamingException ne ) { 95 ne.printStackTrace(System.err); 96 throw new EJBException (ne); 97 } 98 99 try { 100 sequenceHome = (SequenceHomeLocal) initCtx.lookup("java:comp/env/ejb/SequenceHomeLocal"); 102 } catch( NamingException e ) { 103 e.printStackTrace(); 104 throw new EJBException (e); 105 } 106 107 } 108 } 109 110 | Popular Tags |