1 25 26 package org.objectweb.jonas.jtests.beans.sequence; 27 28 import java.rmi.RemoteException ; 29 30 import javax.ejb.CreateException ; 31 import javax.ejb.EJBException ; 32 import javax.ejb.EntityBean ; 33 import javax.ejb.EntityContext ; 34 import javax.ejb.FinderException ; 35 import javax.ejb.RemoveException ; 36 import javax.naming.Context ; 37 import javax.naming.InitialContext ; 38 import javax.naming.NamingException ; 39 import javax.rmi.PortableRemoteObject ; 40 41 42 public abstract class WoEC2 implements EntityBean { 43 44 protected EntityContext entityContext; 45 private SequenceSesHome sequenceHome; 46 47 52 public Integer ejbCreate(String assId, int qty) throws CreateException { 53 setQty(qty); 54 setAssId(assId); 55 try { 56 SequenceSes sequence = sequenceHome.create(); 57 setId(new Integer (sequence.nextKey("workorder"))); 58 } catch (RemoteException e) { 59 throw new CreateException ("Error on sequence:" + e); 60 } catch (FinderException e) { 61 throw new CreateException ("Error on sequence:" + e); 62 } 63 return null; 64 } 65 66 public void ejbPostCreate(String assemblyId, int origQty) throws CreateException { 67 } 68 69 public void ejbRemove() throws RemoveException {} 70 71 public void ejbActivate() { 72 } 73 74 public void ejbPassivate() { 75 } 76 77 public void ejbLoad() { 78 } 79 80 public void ejbStore() { 81 } 82 83 public void unsetEntityContext() { 84 entityContext = null; 85 } 86 87 public void setEntityContext(EntityContext entityContext) { 88 89 Context context = null; 90 91 try { 92 context = new InitialContext (); 93 } catch( Exception e ) { 94 e.printStackTrace(System.err); 95 96 throw new EJBException (e); 97 } 98 this.entityContext = entityContext; 99 100 try { 101 sequenceHome = 102 (SequenceSesHome) PortableRemoteObject.narrow( context.lookup("java:comp/env/ejb/SequenceSes"), 103 SequenceSesHome.class); 104 } catch( NamingException e ) { 105 e.printStackTrace(); 106 throw new EJBException ("Failure looking up home " + e); 107 } 108 } 109 110 public abstract Integer getId() ; 111 112 public abstract void setId(Integer id) ; 113 114 public abstract int getQty() ; 115 116 public abstract void setQty(int qty) ; 117 118 public abstract String getAssId() ; 119 120 public abstract void setAssId(String assId) ; 121 122 } 123 124 125 126 | Popular Tags |