1 25 26 package org.objectweb.jonas.jtests.beans.relation.remon; 27 28 import javax.ejb.CreateException ; 29 import javax.ejb.DuplicateKeyException ; 30 import javax.ejb.EJBException ; 31 import javax.ejb.EntityContext ; 32 import javax.ejb.FinderException ; 33 import javax.ejb.RemoveException ; 34 import javax.naming.Context ; 35 import javax.naming.InitialContext ; 36 import javax.naming.NamingException ; 37 import javax.rmi.PortableRemoteObject ; 38 39 import org.objectweb.jonas.common.Log; 40 import org.objectweb.util.monolog.api.BasicLevel; 41 import org.objectweb.util.monolog.api.Logger; 42 43 46 public abstract class MainEC2 implements javax.ejb.EntityBean { 47 48 private AttributeHome attrhome = null; 49 50 public abstract String getId(); 54 public abstract void setId(String id); 55 public abstract String getPf1(); 56 public abstract void setPf1(String pf1); 57 58 public abstract Attribute getAttr(); 59 public abstract void setAttr(Attribute a); 60 61 65 static protected Logger logger = null; 66 EntityContext ejbContext; 67 68 76 public String ejbCreate(String id, String pf1, String att) throws CreateException , DuplicateKeyException { 77 logger.log(BasicLevel.DEBUG, ""); 78 79 setId(id); 81 setPf1(pf1); 82 83 return null; 85 } 86 87 91 public void ejbPostCreate(String id, String pf1, String aname) throws CreateException { 92 logger.log(BasicLevel.DEBUG, "id=" + id); 93 Attribute attr = attrhome.create(aname); 94 setAttr(attr); 95 } 96 97 107 public void setEntityContext(EntityContext ctx) { 108 if (logger == null) 109 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 110 logger.log(BasicLevel.DEBUG, ""); 111 ejbContext = ctx; 112 try { 113 Context ictx = new InitialContext (); 114 attrhome = (AttributeHome) PortableRemoteObject.narrow(ictx.lookup("java:comp/env/ejb/attribute"), AttributeHome.class); 115 } catch (NamingException e) { 116 throw new EJBException ("Impossible to get AttributeHome:", e); 117 } 118 } 119 120 131 public void unsetEntityContext() { 132 logger.log(BasicLevel.DEBUG, ""); 133 ejbContext = null; 134 } 135 136 149 public void ejbRemove() throws RemoveException { 150 logger.log(BasicLevel.DEBUG, ""); 151 getAttr().remove(); 152 } 153 154 162 public void ejbLoad() { 163 logger.log(BasicLevel.DEBUG, ""); 164 } 165 166 174 public void ejbStore() { 175 logger.log(BasicLevel.DEBUG, ""); 176 } 177 178 182 public void ejbPassivate() { 183 logger.log(BasicLevel.DEBUG, ""); 184 } 185 186 191 public void ejbActivate() { 192 logger.log(BasicLevel.DEBUG, ""); 193 } 194 195 } 196 | Popular Tags |