1 22 package org.jboss.test.cmp2.cmrtree.ejb; 23 24 import java.util.Collection ; 25 import org.jboss.logging.Logger; 26 27 import javax.ejb.SessionBean ; 28 import javax.ejb.SessionContext ; 29 import javax.ejb.CreateException ; 30 31 42 public class FacadeSessionBean 43 implements SessionBean 44 { 45 private static Logger log = Logger.getLogger(FacadeSessionBean.class); 46 47 SessionContext ctx; 48 49 51 55 public void setup() throws Exception 56 { 57 final long startTime = System.currentTimeMillis(); 58 log.debug("SETUP>"); 59 60 ALocal a = AUtil.getLocalHome().create(1, "A", "1.A"); 61 BLocal b1 = BUtil.getLocalHome().create(1, "B1", "1.B1"); 62 b1.setAMinorId("A"); 63 64 BLocal b2 = BUtil.getLocalHome().create(1, "B2", "1.B2"); 65 b2.setParent(b1); 66 67 log.debug("SETUP> done in " + (System.currentTimeMillis() - startTime) + " ms."); 68 } 69 70 74 public void test(long sleep) throws Exception 75 { 76 final long startTime = System.currentTimeMillis(); 77 log.debug("RUN>"); 78 79 AUtil.getLocalHome().remove(new APK(1, "A")); 80 81 log.debug("RUN> done in " + (System.currentTimeMillis() - startTime) + " ms."); 82 } 83 84 88 public void tearDown() throws Exception 89 { 90 final long startTime = System.currentTimeMillis(); 91 log.debug("TEAR DOWN>"); 92 93 log.debug("TEAR DOWN> done in " + (System.currentTimeMillis() - startTime) + " ms."); 94 } 95 96 100 public void setup2() throws Exception 101 { 102 final long startTime = System.currentTimeMillis(); 103 log.debug("SETUP2>"); 104 105 ALocal a = AUtil.getLocalHome().create(1, "A", "1.A"); 106 BLocal b1 = BUtil.getLocalHome().create(1, "B1", "some name"); 107 b1.setA(a); 108 109 log.debug("SETUP2> done in " + (System.currentTimeMillis() - startTime) + " ms."); 110 } 111 112 116 public void setBNameToNull() throws Exception 117 { 118 ALocal a = AUtil.getLocalHome().findByPrimaryKey(new APK(1, "A")); 119 Collection bs = a.getB(); 120 if(bs.size() != 1) 121 { 122 throw new IllegalStateException ("Expected only one B but got " + bs); 123 } 124 125 BLocal b = (BLocal)bs.iterator().next(); 126 b.setName(null); 127 } 128 129 133 public String getBName() throws Exception 134 { 135 BLocal b = BUtil.getLocalHome().findByPrimaryKey(new BPK(1, "B1")); 136 return b.getName(); 137 } 138 139 141 145 public void ejbCreate() throws CreateException 146 { 147 } 148 149 public void ejbActivate() 150 { 151 } 152 153 public void ejbPassivate() 154 { 155 } 156 157 public void ejbRemove() 158 { 159 } 160 161 public void setSessionContext(SessionContext ctx) 162 { 163 this.ctx = ctx; 164 } 165 } 166 | Popular Tags |