KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > ejb > BaseEntityBean


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14 package org.ejbca.core.ejb;
15
16
17 import javax.ejb.EntityBean JavaDoc;
18 import javax.ejb.EntityContext JavaDoc;
19
20 import org.apache.log4j.Logger;
21
22
23 /**
24  * Base class for entity beans implementing required methods and helpers.
25  *
26  * @version $Id: BaseEntityBean.java,v 1.2 2006/08/05 09:59:37 anatom Exp $
27  */

28 public class BaseEntityBean implements EntityBean JavaDoc {
29
30     /** Log4j instance for actual implementation class */
31     public transient Logger log;
32     protected EntityContext JavaDoc ctx;
33
34     /**
35      * Creates a new BaseEntityBean object.
36      */

37     public BaseEntityBean() {
38         super();
39         log = Logger.getLogger(this.getClass());
40     }
41
42     /**
43      * Logs a message with priority DEBUG
44      *
45      * @param msg Message
46      */

47     public void debug(String JavaDoc msg) {
48         log.debug(msg);
49     }
50
51     /**
52      * Logs a message and an exception with priority DEBUG
53      *
54      * @param msg Message
55      * @param t Exception
56      */

57     public void debug(String JavaDoc msg, Throwable JavaDoc t) {
58         log.debug(msg, t);
59     }
60
61     /**
62      * Logs a message with priority INFO
63      *
64      * @param msg Message
65      */

66     public void info(String JavaDoc msg) {
67         log.info(msg);
68     }
69
70     /**
71      * Logs a message and an exception with priority INFO
72      *
73      * @param msg Message
74      * @param t Exception
75      */

76     public void info(String JavaDoc msg, Throwable JavaDoc t) {
77         log.info(msg, t);
78     }
79
80     /**
81      * Logs a message with priority WARN
82      *
83      * @param msg Message
84      */

85     public void warn(String JavaDoc msg) {
86         log.warn(msg);
87     }
88
89     /**
90      * Logs a message and an exception with priority WARN
91      *
92      * @param msg Message
93      * @param t Exception
94      */

95     public void warn(String JavaDoc msg, Throwable JavaDoc t) {
96         log.warn(msg, t);
97     }
98
99     /**
100      * Logs a message with priority ERROR
101      *
102      * @param msg Message
103      */

104     public void error(String JavaDoc msg) {
105         log.error(msg);
106     }
107
108     /**
109      * Logs a message and an exception with priority ERROR
110      *
111      * @param msg Message
112      * @param t Exception
113      */

114     public void error(String JavaDoc msg, Throwable JavaDoc t) {
115         log.error(msg, t);
116     }
117
118     /**
119      * Sets current entity context
120      *
121      * @param ctx current entity context
122      */

123     public void setEntityContext(EntityContext JavaDoc ctx) {
124         this.ctx = ctx;
125     }
126
127     /**
128      * Removes (nulls) current entity context
129      */

130     public void unsetEntityContext() {
131         this.ctx = null;
132     }
133
134     /**
135      * Activates bean, does nothing for base entity.
136      */

137     public void ejbActivate() {
138         // Not implemented.
139
}
140
141     /**
142      * Passivates bean, does nothing for base entity.
143      */

144     public void ejbPassivate() {
145         // Not implemented.
146
}
147
148     /**
149      * Loads bean, does nothing for base entity.
150      */

151     public void ejbLoad() {
152         // Not implemented.
153
}
154
155     /**
156      * Stores bean, does nothing for base entity.
157      */

158     public void ejbStore() {
159         // Not implemented.
160
}
161
162     /**
163      * Removes bean, does nothing for base entity.
164      */

165     public void ejbRemove() {
166         // Not implemented.
167
}
168
169     /**
170      * Helper method to retrieve the locator
171      * @return
172      */

173     protected ServiceLocator getLocator() {
174         return ServiceLocator.getInstance();
175     }
176 }
177
Popular Tags