1 25 26 package org.objectweb.jonas.jtests.beans.ebasic; 27 28 import java.rmi.RemoteException ; 29 import javax.ejb.CreateException ; 30 import javax.ejb.EntityBean ; 31 import javax.ejb.EntityContext ; 32 import javax.ejb.RemoveException ; 33 34 import org.objectweb.jonas.common.Log; 35 import org.objectweb.util.monolog.api.BasicLevel; 36 import org.objectweb.util.monolog.api.Logger; 37 38 39 49 50 public abstract class SimpleEC2 implements EntityBean { 51 52 static protected Logger logger = null; 53 54 protected EntityContext entityContext; 55 56 57 public abstract int getInfo(); 59 public abstract void setInfo(int info); 60 61 public abstract int getNumTest(); 62 public abstract void setNumTest(int numtest); 63 64 public abstract String getTestName(); 65 public abstract void setTestName(String testname); 66 67 68 public void ejbActivate() { 69 logger.log(BasicLevel.DEBUG, ""); 70 } 71 72 public void ejbPassivate() { 73 logger.log(BasicLevel.DEBUG, ""); 74 } 75 76 public void ejbLoad() { 77 logger.log(BasicLevel.DEBUG, ""); 78 } 79 80 public void ejbStore() { 81 logger.log(BasicLevel.DEBUG, ""); 82 } 83 84 public void ejbRemove() throws RemoveException { 85 logger.log(BasicLevel.DEBUG, ""); 86 } 87 88 public void setEntityContext(EntityContext ctx) { 89 if (logger == null) 90 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 91 logger.log(BasicLevel.DEBUG, ""); 92 entityContext = ctx; 93 94 } 95 96 public void unsetEntityContext() { 97 logger.log(BasicLevel.DEBUG, ""); 98 } 99 100 public String ejbCreate(String name, int info, int num) throws CreateException { 101 logger.log(BasicLevel.DEBUG, "create"+info+","+name+","+num); 102 setInfo(info); 103 setNumTest(num); 104 setTestName(name); 105 return(null); 106 } 107 108 public void ejbPostCreate(String name, int info, int num) { 109 logger.log(BasicLevel.DEBUG, ""); 110 } 111 112 118 public boolean loopBack() throws RemoteException { 119 logger.log(BasicLevel.DEBUG, ""); 120 boolean pass = false; 121 Simple myref = (Simple) entityContext.getEJBObject(); 122 try { 123 myref.getNumTest(); 124 } catch (RemoteException e) { 125 logger.log(BasicLevel.DEBUG, "expected exception:" + e); 126 pass = true; 127 } 128 return pass; 129 } 130 131 137 public boolean loopBackTx() throws RemoteException { 138 logger.log(BasicLevel.DEBUG, ""); 139 boolean pass = false; 140 Simple myref = (Simple) entityContext.getEJBObject(); 141 try { 142 myref.getNumTest(); 143 } catch (RemoteException e) { 144 logger.log(BasicLevel.DEBUG, "expected exception:" + e); 145 pass = true; 146 } 147 return pass; 148 } 149 150 154 public void ejbHomeGlobalOpe() throws RemoteException { 155 logger.log(BasicLevel.DEBUG, ""); 156 if (entityContext == null) { 157 throw new RemoteException ("null entityContext"); 158 } 159 entityContext.getEJBHome(); 160 try { 162 entityContext.getEJBLocalHome(); 163 } catch (IllegalStateException e) { 164 } 165 entityContext.getCallerPrincipal(); 166 entityContext.getRollbackOnly(); 167 entityContext.isCallerInRole("role"); 168 entityContext.getTimerService(); 169 } 170 } 171 | Popular Tags |