User: salborini
  Date: 00/10/09 11:12:27

  Added:       src/main/org/jboss/test/lock/bean EnterpriseEntityBean.java
  Log:
  New test for locking
  
  Revision  Changes    Path
  1.1                  
jbosstest/src/main/org/jboss/test/lock/bean/EnterpriseEntityBean.java
  
  Index: EnterpriseEntityBean.java
  ===================================================================
  package org.jboss.test.lock.bean;
  
  import java.rmi.*;
  import javax.ejb.*;
  
  import org.jboss.test.lock.interfaces.EnterpriseEntityHome;
  import org.jboss.test.lock.interfaces.EnterpriseEntity;
  
  public class EnterpriseEntityBean implements EntityBean {
        private EntityContext entityContext;
        public String name;
        public String field;
        public EnterpriseEntity nextEntity;
        
        public String ejbCreate(String name) throws RemoteException, CreateException {
                this.name = name;
                return null;
        }
        
        public void ejbPostCreate(String name) throws RemoteException, CreateException 
{
        }
        
        
        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 void setField(String field) {
                this.field = field;
        }
        
        public String getField() {
                return field;
        }
  
        
        public void setAndCopyField(String field) throws RemoteException {
                
                setField(field);
                nextEntity.setField(field);
        }
        
        
        public void setNextEntity(String beanName) throws RemoteException {
                
                System.out.println("EntityBean.createEntity() called");
                
                try {
                        EJBObject ejbObject = entityContext.getEJBObject();
                        EnterpriseEntityHome home = 
(EnterpriseEntityHome)entityContext.getEJBObject().getEJBHome();
                        
                        try {
                                nextEntity = 
(EnterpriseEntity)home.findByPrimaryKey(beanName);
                        } catch (FinderException e) {
                                nextEntity = (EnterpriseEntity)home.create(beanName);
                        }
                
                } catch(Exception e) {
                        e.printStackTrace();
                        throw new RemoteException("create entity did not work check 
messages");   
                }
        }
        
        public void setEntityContext(EntityContext context) throws RemoteException {
                entityContext = context;
        }
        
        public void unsetEntityContext() throws RemoteException {
                entityContext = null;
        }
  }
  
  
  

Reply via email to