1 25 26 package org.objectweb.jonas.jtests.beans.relation.omb; 27 28 import javax.ejb.CreateException ; 29 import javax.ejb.EJBException ; 30 import javax.ejb.FinderException ; 31 import javax.ejb.SessionBean ; 32 import javax.ejb.SessionContext ; 33 import javax.naming.Context ; 34 import javax.naming.InitialContext ; 35 import javax.naming.NamingException ; 36 import javax.rmi.PortableRemoteObject ; 37 38 import org.objectweb.jonas.common.Log; 39 import org.objectweb.util.monolog.api.BasicLevel; 40 import org.objectweb.util.monolog.api.Logger; 41 42 43 46 public class FrontSFR implements SessionBean { 47 48 static private Logger logger = null; 49 SessionContext ejbContext; 50 private AHomeLocal ahl = null; 51 private BHomeLocal bhl = null; 52 53 57 58 public void setSessionContext(SessionContext ctx) { 59 if (logger == null) { 60 logger = Log.getLogger("org.objectweb.jonas_tests"); 61 } 62 logger.log(BasicLevel.DEBUG, ""); 63 ejbContext = ctx; 64 try { 65 Context ictx = new InitialContext (); 66 ahl = (AHomeLocal) ictx.lookup("java:comp/env/ejb/a"); 67 bhl = (BHomeLocal) ictx.lookup("java:comp/env/ejb/b"); 68 } catch (NamingException e) { 69 throw new EJBException ("Impossible to fetch the ", e); 70 } 71 } 72 73 74 public void ejbRemove() { 75 logger.log(BasicLevel.DEBUG, ""); 76 } 77 78 79 public void ejbCreate() throws CreateException { 80 logger.log(BasicLevel.DEBUG, ""); 81 } 82 83 public void ejbCreate(String pka, String pkb) throws CreateException { 84 logger.log(BasicLevel.DEBUG, ""); 85 try { 86 ALocal al = ahl.create(pka); 87 BLocal bl = bhl.create(pkb); 88 al.getB().add(bl); 89 bhl.findByName(pkb, al.getId()); 90 } catch (Exception e) { 91 throw new CreateException ("ejbCreate failed " + e); 92 } 93 } 94 95 public void ejbPassivate() { 96 logger.log(BasicLevel.DEBUG, ""); 97 } 98 99 public void ejbActivate() { 100 logger.log(BasicLevel.DEBUG, ""); 101 } 102 103 107 110 public void method1() { 111 logger.log(BasicLevel.DEBUG, ""); 112 } 113 114 117 public void method2(java.lang.String s) { 118 logger.log(BasicLevel.DEBUG, ""); 119 } 120 121 125 public void testRemove1() { 126 logger.log(BasicLevel.DEBUG, ""); 127 ALocal ax9; 128 try { 129 ax9 = ahl.create("ax9"); 130 ax9.remove(); 131 } catch (Exception e) { 132 throw new EJBException ("Initial state creation problem: " + e); 133 } 134 try { 135 ax9.getId(); 136 throw new EJBException ("entity was not deleted, expected EJBException"); 137 } catch (EJBException e) { 138 } catch (Exception e) { 140 throw new EJBException ("Caught unexpected exception: " + e); 141 } 142 } 143 144 148 public void testSetCmrWithDeleted() { 149 logger.log(BasicLevel.DEBUG, ""); 150 BLocal b0; 151 try { 152 b0 = bhl.findByPrimaryKey("b0"); 153 } catch (Exception e) { 154 throw new EJBException ("Initial state creation problem: " + e); 155 } 156 try { 157 b0.testSetCmrWithDeleted(); 158 } catch (Exception e) { 159 throw new EJBException ("Caugth unexpected exception: " + e); 160 } 161 } 162 163 167 public void testSetCmrWithWrongType() { 168 logger.log(BasicLevel.DEBUG, ""); 169 ALocal a0; 170 try { 171 a0 = ahl.findByPrimaryKey("a0"); 172 } catch (FinderException e) { 173 throw new EJBException ("Initial state creation problem: " + e); 174 } 175 try { 176 a0.getB().add(a0); 177 } catch (IllegalArgumentException e) { 178 return; 180 } catch (Exception e) { 181 throw new EJBException ("Caugth unexpected exception: " + e); 182 } 183 throw new EJBException ("Expected IllegalArgumentException"); 184 } 185 } 186 187 | Popular Tags |