Examples of EJBThreads


Examples of org.jboss.test.threading.interfaces.EJBThreads

       
            InitialContext ic = new InitialContext();
       
            EJBThreadsHome testHome = (EJBThreadsHome) ic.lookup("threads");
       
            EJBThreads ejbTest;
            while(runMe)
            {
         
               ejbTest = null;
         
               try {
           
                  ejbTest = testHome.findByPrimaryKey("test1");
               }
               catch (Exception e)
               {
                  // Bean wasn't found create it
                  try {
                     ejbTest = testHome.create("test1");
                  }
         
                  catch (Exception e2)
                  {
                     log.debug("****Create exception: " + e2);
                  }
               }
         
               if (ejbTest != null) try {
           
                  // get a random value between 1 and 100
                  int value = random.nextInt(100);
           
                  // 10% removal
                  if (value <10) {
                     ejbTest.remove();
                  }
                  // 35% normal
                  else if (value<45) {
                     ejbTest.test();
                  }
                  // 15% business exception
                  else if (value<60) {
                     ejbTest.testBusinessException();
                  }
                  // 15 % runtime excpetion
                  else if (value <75) {
                     ejbTest.testRuntimeException();
                  }
                  // 15 % nonTransactional
                  else if (value <90) {
                     ejbTest.testNonTransactional();
                  }
                  // 10% timeout
                  else {
                     ejbTest.testTimeOut();
                  }
           
                  synchronized (this) {
                     //Thread.currentThread().yield();
                     this.wait(wait);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.