KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > lock > bean > EnterpriseEntityBean


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.lock.bean;
23
24 import java.rmi.*;
25 import javax.ejb.*;
26
27 import org.jboss.test.lock.interfaces.EnterpriseEntityHome;
28 import org.jboss.test.lock.interfaces.EnterpriseEntity;
29
30 public class EnterpriseEntityBean
31    implements EntityBean
32 {
33    static org.jboss.logging.Logger log =
34       org.jboss.logging.Logger.getLogger(EnterpriseEntityBean.class);
35
36    private EntityContext entityContext;
37
38    public String JavaDoc name;
39    public String JavaDoc field;
40    public EnterpriseEntity nextEntity;
41    public String JavaDoc lastEntity = "UNKNOWN!!!!";
42
43    public String JavaDoc ejbCreate(final String JavaDoc name)
44       throws RemoteException, CreateException
45    {
46       this.name = name;
47       return null;
48    }
49
50    public void ejbPostCreate(String JavaDoc name)
51       throws RemoteException, CreateException
52    {
53       // empty
54
}
55
56    public void ejbActivate() throws RemoteException
57    {
58       // empty
59
}
60
61    public void ejbLoad() throws RemoteException
62    {
63       // empty
64
}
65
66    public void ejbPassivate() throws RemoteException
67    {
68       // empty
69
}
70
71    public void ejbRemove() throws RemoteException, RemoveException
72    {
73       // empty
74
}
75
76    public void ejbStore() throws RemoteException
77    {
78       // empty
79
}
80
81    public void setField(String JavaDoc field) throws RemoteException
82    {
83       //log.debug("Bean "+name+", setField("+field+") called");
84
this.field = field;
85    }
86
87    public String JavaDoc getField() throws RemoteException
88    {
89       return field;
90    }
91
92    public void setAndCopyField(String JavaDoc field) throws RemoteException
93    {
94       //log.debug("Bean "+name+", setAndCopyField("+field+") called");
95

96       log.debug("setAndCopyField");
97       setField(field);
98       if (nextEntity == null)
99       {
100          log.error("nextEntity is null!!!!!!!!, lastEntity: " + lastEntity);
101       }
102       nextEntity.setField(field);
103    }
104
105    public void setNextEntity(String JavaDoc beanName) throws RemoteException
106    {
107       try
108       {
109          log.debug("setNextEntity: " + beanName);
110          EJBObject ejbObject = entityContext.getEJBObject();
111          EnterpriseEntityHome home = (EnterpriseEntityHome) ejbObject.getEJBHome();
112          try
113          {
114             nextEntity = home.findByPrimaryKey(beanName);
115          }
116          catch (FinderException e)
117          {
118             nextEntity = home.create(beanName);
119          }
120          lastEntity = beanName;
121       }
122       catch (Exception JavaDoc e)
123       {
124          log.debug("failed", e);
125          throw new RemoteException
126             ("create entity did not work check messages");
127       }
128    }
129
130    public void setEntityContext(EntityContext context)
131       throws RemoteException
132    {
133       entityContext = context;
134    }
135
136    public void unsetEntityContext() throws RemoteException
137    {
138       entityContext = null;
139    }
140
141    public void sleep(long time) throws InterruptedException JavaDoc
142    {
143       Thread.sleep(time);
144    }
145 }
146
Popular Tags