User: patriot1burke
  Date: 02/01/12 12:29:52

  Added:       src/main/org/jboss/test/deadlock/bean
                        StatelessSessionBean.java EnterpriseEntityBean.java
  Log:
  Added deadlock detection test to test new deadlock detection algorithm in 
QueuedEJBPessimisticLock
  
  Revision  Changes    Path
  1.1                  
jbosstest/src/main/org/jboss/test/deadlock/bean/StatelessSessionBean.java
  
  Index: StatelessSessionBean.java
  ===================================================================
  
  //Title:        Yo MAMA!
  //Version:
  //Copyright:    Copyright (c) 1999
  //Author:       Bill Burke
  //Description:  Your description
  
  package org.jboss.test.deadlock.bean;
  
  import java.rmi.*;
  import javax.ejb.*;
  import javax.naming.InitialContext;
  import javax.naming.Context;
  import org.jboss.test.deadlock.interfaces.EnterpriseEntityHome;
  import org.jboss.test.deadlock.interfaces.EnterpriseEntity;
  
  public class StatelessSessionBean implements SessionBean 
  {
    private SessionContext sessionContext;
  
     public void ejbCreate() throws RemoteException, CreateException 
     {
     }
     
     public void ejbActivate() throws RemoteException {
     }
     
     public void ejbPassivate() throws RemoteException {
     }
     
     public void ejbRemove() throws RemoteException {
     }
     
     public void setSessionContext(SessionContext context) throws RemoteException {
        sessionContext = context;
        //Exception e = new Exception("in set Session context");
        //e.printStackTrace();
     }
     
     
     public void callAB() throws RemoteException
     {
        try
        {
         System.out.println("callAB start");
         EnterpriseEntityHome home = (EnterpriseEntityHome)new 
InitialContext().lookup("nextgen.EnterpriseEntity");
         EnterpriseEntity A = home.findByPrimaryKey("A");
         EnterpriseEntity B = home.findByPrimaryKey("B");
         A.getOtherField();
         System.out.println("callAB is sleeping");
         Thread.sleep(10000);
         System.out.println("callAB woke up");
         B.getOtherField();
         System.out.println("callAB end");
        }
        catch (Exception ex)
        {
          ex.printStackTrace();
         throw new RemoteException("failed");
        }
     }
     
     public void callBA() throws RemoteException
     {
        try
        {
         System.out.println("callBA start");
         EnterpriseEntityHome home = (EnterpriseEntityHome)new 
InitialContext().lookup("nextgen.EnterpriseEntity");
         EnterpriseEntity B = home.findByPrimaryKey("B");
         EnterpriseEntity A = home.findByPrimaryKey("A");
         B.getOtherField();
         System.out.println("callBA is sleeping");
         Thread.sleep(10000);
         System.out.println("callBA woke up");
         A.getOtherField();
         System.out.println("callBA end");
        }
        catch (Exception ex)
        {
          ex.printStackTrace();
         throw new RemoteException("failed");
        }
     }
     
  }
  
  
  
  1.1                  
jbosstest/src/main/org/jboss/test/deadlock/bean/EnterpriseEntityBean.java
  
  Index: EnterpriseEntityBean.java
  ===================================================================
  
  //Title:        telkel
  //Version:      
  //Copyright:    Copyright (c) 1999
  //Author:       Marc Fleury
  //Company:      telkel
  //Description:  Your description
  
  package org.jboss.test.deadlock.bean;
  
  import java.rmi.*;
  import javax.ejb.*;
  
  import org.jboss.test.deadlock.interfaces.EnterpriseEntityHome;
  import org.jboss.test.deadlock.interfaces.EnterpriseEntity;
  
  public class EnterpriseEntityBean implements EntityBean 
  {
    private EntityContext entityContext;
    public String name;
    public int otherField = 0;
                                                              
  
    public String ejbCreate(String name) throws RemoteException, CreateException {
  
         this.name = name;
           return null;
    }
  
    public void ejbPostCreate(String name) throws RemoteException, CreateException {
  
           
           EJBObject ejbObject = entityContext.getEJBObject();
           
           if (ejbObject == null) {
                   System.out.println("******************************* NULL EJBOBJECT 
in ejbPostCreate");
           }
           else {
                        System.out.println("&&&&&&&&&&&&&&&& EJBObject found in 
ejbPostCreate id is "+ejbObject.getPrimaryKey());   
           }
  
    }
  
    public void ejbActivate() throws RemoteException {
    }
  
    public void ejbLoad() throws RemoteException {
    }
  
    public void ejbPassivate() throws RemoteException {
  
    }
  
    public void ejbRemove() throws RemoteException, RemoveException {
    }
  
    public void ejbStore() throws RemoteException {
          
    }
  
    public String callBusinessMethodA() {
  
       return "EntityBean.callBusinessMethodA() called, my primaryKey is "+
              entityContext.getPrimaryKey().toString();
    }
    
    public String callBusinessMethodB() {
  
       
         EJBObject ejbObject = entityContext.getEJBObject();
         
         if (ejbObject == null) 
                return "NULL EJBOBJECT";
         
         else 
                return ejbObject.toString();
    }
    
    
     public String callBusinessMethodB(String words) {
      
       
         EJBObject ejbObject = entityContext.getEJBObject();
         
         if (ejbObject == null) 
                return "NULL EJBOBJECT";
         
         else 
                return ejbObject.toString()+ " words "+words;
    
        }
    public void setOtherField(int value) {
        
      otherField = value;
    }
    
    public int getOtherField() {
       return otherField;
   }
    
    public EnterpriseEntity createEntity(String newName) throws RemoteException {
  
      EnterpriseEntity newBean;
      try{
                EJBObject ejbObject = entityContext.getEJBObject();
                if (ejbObject == null) 
                System.out.println("************************** NULL EJBOBJECT");
                else
          System.out.println("************************** OK EJBOBJECT");
                
                EnterpriseEntityHome home = 
(EnterpriseEntityHome)entityContext.getEJBObject().getEJBHome();
            newBean = (EnterpriseEntity)home.create(newName);
  
      
        }catch(Exception e)
      {
                e.printStackTrace();
          throw new RemoteException("create entity did not work check messages");   
      }
       
       return newBean;
    }
    
    public void setEntityContext(EntityContext context) throws RemoteException {
       entityContext = context;
    }
  
    public void unsetEntityContext() throws RemoteException {
      entityContext = null;
    }
  }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to