1 25 26 package org.objectweb.jonas.jtests.beans.applimet; 27 28 import java.rmi.RemoteException ; 29 import javax.ejb.CreateException ; 30 import javax.ejb.SessionBean ; 31 import javax.ejb.SessionContext ; 32 import javax.naming.Context ; 33 import javax.naming.InitialContext ; 34 import javax.naming.NamingException ; 35 import javax.rmi.PortableRemoteObject ; 36 import org.objectweb.jonas.common.Log; 37 import org.objectweb.util.monolog.api.Logger; 38 import org.objectweb.util.monolog.api.BasicLevel; 39 40 42 public class AppliSession implements SessionBean { 43 44 static protected Logger logger = null; 45 private MetHome th; 46 private Met tr; 47 48 SessionContext ejbContext; 49 50 public void ejbRemove() throws RemoteException { 51 logger.log(BasicLevel.DEBUG, ""); 52 try { 53 tr.remove(); 54 } catch (Exception e) { 55 logger.log(BasicLevel.ERROR, "Cannot remove Met:" + e); 56 throw new RemoteException ("Cannot remove Met:" + e); 57 } 58 } 59 60 public void ejbCreate() throws CreateException { 61 logger.log(BasicLevel.DEBUG, ""); 62 try{ 63 Context ctx = new InitialContext (); 64 Object objref = ctx.lookup(MetHome.JNDI_NAME); 65 th = (MetHome) PortableRemoteObject.narrow(objref, MetHome.class); 66 tr = th.create(); 67 } catch(Exception e) { 68 logger.log(BasicLevel.ERROR, "Cannot create Met:" + e); 69 throw new CreateException ("Cannot create Met:" + e); 70 } 71 } 72 73 public void methodeApplicative() throws RemoteException { 74 logger.log(BasicLevel.DEBUG, ""); 75 try { 76 tr.methode1(); 77 } catch (Exception e) { 78 logger.log(BasicLevel.ERROR, "Cannot call Met:" + e); 79 throw new RemoteException ("Cannot call Met:" + e); 80 } 81 } 82 83 public void noTxMethod() throws RemoteException { 84 logger.log(BasicLevel.DEBUG, ""); 85 try { 86 ejbContext.getRollbackOnly(); 87 throw new RemoteException ("Should get IllegalStateException"); 88 } catch (IllegalStateException e) { 89 } 90 } 91 92 public void ejbActivate() { 93 logger.log(BasicLevel.DEBUG, ""); 94 } 95 96 public void ejbPassivate() { 97 logger.log(BasicLevel.DEBUG, ""); 98 } 99 100 public void setSessionContext(javax.ejb.SessionContext ctx) { 101 if (logger == null) { 102 logger = Log.getLogger(Log.JONAS_TESTS_PREFIX); 103 } 104 logger.log(BasicLevel.DEBUG, ""); 105 ejbContext = ctx; 106 } 107 108 public void unsetSessionContext() { 109 logger.log(BasicLevel.DEBUG, ""); 110 } 111 } 112 | Popular Tags |