KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > entity > ejb > UnsetEntityContextBean


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.entity.ejb;
23
24 import javax.ejb.CreateException JavaDoc;
25 import javax.ejb.EntityBean JavaDoc;
26 import javax.ejb.EntityContext JavaDoc;
27 import javax.ejb.RemoveException JavaDoc;
28
29 import org.jboss.logging.Logger;
30
31 /**
32  * A bean to test whether unsetEntityContext is called.
33  *
34  * @author <a HREF="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
35  * @version $Revision: 38303 $
36  */

37 public class UnsetEntityContextBean implements EntityBean JavaDoc
38 {
39    private static final Logger log = Logger.getLogger(UnsetEntityContextBean.class);
40
41    private static int setEntityContextCounter = 0;
42    private static int unsetEntityContextCounter = 0;
43    
44    private EntityContext JavaDoc entityContext;
45
46    private String JavaDoc name;
47
48    public void setEntityContext(EntityContext JavaDoc context)
49    {
50       log.info("setEntityContext - " + name);
51       ++setEntityContextCounter;
52       entityContext = context;
53    }
54    
55    public void unsetEntityContext()
56    {
57       log.info("unsetEntityContext - " + name);
58       ++unsetEntityContextCounter;
59       entityContext = null;
60    }
61    
62    public String JavaDoc getName()
63    {
64       log.info("getName");
65       return name;
66    }
67
68    public String JavaDoc ejbCreate(String JavaDoc name)
69       throws CreateException JavaDoc
70    {
71       log.info("ejbCreate - " + name);
72       this.name = name;
73       return name;
74    }
75     
76    public void ejbPostCreate(String JavaDoc name)
77       throws CreateException JavaDoc
78    {
79       log.info("ejbPostCreate - " + name);
80    }
81
82    public String JavaDoc ejbFindByPrimaryKey(String JavaDoc name)
83    {
84       log.info("ejbFindByPrimaryKey - " + name);
85       return name;
86    }
87     
88    public void ejbActivate()
89    {
90       log.info("ejbActivate - " + name);
91    }
92     
93    public void ejbLoad()
94    {
95       log.info("ejbLoad - " + name);
96    }
97     
98    public void ejbPassivate()
99    {
100       log.info("ejbPassivate - " + name);
101    }
102     
103    public void ejbRemove()
104       throws RemoveException JavaDoc
105    {
106       log.info("ejbRemove - " + name);
107    }
108     
109    public void ejbStore()
110    {
111       log.info("ejbStore - " + name);
112    }
113
114    public int ejbHomeGetSetEntityContextCallCounter()
115    {
116       return setEntityContextCounter;
117    }
118
119    public int ejbHomeGetUnsetEntityContextCallCounter()
120    {
121       return unsetEntityContextCounter;
122    }
123    
124    public void ejbHomeClearSetEntityContextCallCounter()
125    {
126       log.info("ejbHomeClearSetEntityContextCallCounter - " + name);
127       setEntityContextCounter = 0;
128    }
129    
130    public void ejbHomeClearUnsetEntityContextCallCounter()
131    {
132       log.info("ejbHomeClearUnsetEntityContextCallCounter - " + name);
133       unsetEntityContextCounter = 0;
134    }
135    
136 }
137
Popular Tags