Source code: org/ahlner/Log4J2DB/beans/LogEventBean.java
1 /* $Id: LogEventBean.java,v 1.20 2003/07/19 11:59:16 phah Exp $
2 * Project: log4j2db.
3 *
4 * This Software is published under General Public License.
5 * See terms of licence at gnu.org
6 */
7
8
9 package org.ahlner.Log4J2DB.beans;
10
11 import java.util.Collection;
12 import java.util.Vector;
13 import javax.ejb.CreateException;
14 import javax.ejb.EntityBean;
15 import javax.ejb.FinderException;
16
17 /**
18 * @ejb.bean name="LogEvent"
19 * type="CMP"
20 * cmp-version = "2.x"
21 * description="LogEventBean"
22 * view-type = "both"
23 * jndi-name = "ejb/LogEvent"
24 * local-jndi-name = "LogEventLocal"
25 *
26 * @ejb.finder signature="Collection findAll()"
27 * query = "SELECT OBJECT(a) FROM LogEvent AS a WHERE a.eventid IS NOT NULL"
28 *
29 * @ejb.finder signature = "Collection findByParams(java.lang.String hostname, java.lang.String logger, java.lang.String priority, java.lang.Float fromTime, java.lang.Float toTime)"
30 * query = "SELECT OBJECT(a) FROM LogEvent a WHERE a.hostName=?1 AND a.logger = ?2 AND a.priority = ?3 AND a.timeStamp BETWEEN ?4 AND ?5"
31 *
32 * @ejb.finder signature = "Collection findByParams(java.lang.String hostname, java.lang.String priority, java.lang.Float fromTime, java.lang.Float toTime)"
33 * query = "SELECT OBJECT(a) FROM LogEvent a WHERE a.hostName=?1 AND a.priority = ?2 AND a.timeStamp BETWEEN ?3 AND ?4"
34
35 *
36 * @ejb.facade view-type = "remote"
37 * @ejb.util generate = "physical"
38 *
39 * @ejb.persistence table-name="LOG4JEVENTS"
40 * @ejb.pk class = "org.ahlner.Log4J2DB.beans.LogEventPK"
41 * @ejb.value-object match = "*"
42 * @ejb.transaction type = "Required"
43 * @jboss.create-table create="true"
44 * @jboss.table-name table-name="LOG4JEVENTS"
45 */
46 public abstract class LogEventBean implements EntityBean
47 {
48 /**
49 * @ejb.interface-method
50 * @return LogEventData
51 */
52 public abstract org.ahlner.Log4J2DB.beans.LogEventData getData();
53 /**
54 * @ejb.interface-method
55 * @return LogEventValue
56 */
57 public abstract org.ahlner.Log4J2DB.beans.LogEventValue getLogEventValue();
58 /**
59 * @ejb.create-method
60 */
61 public Object ejbCreate(String hostname, String logger, Float timeStamp, String priority, String message) throws CreateException
62 {
63 try
64 {
65 setEventid(LogEventUtil.generateGUID(this));
66 setHostName(hostname);
67 setLogger(logger);
68 setTimeStamp(timeStamp);
69 setPriority(priority);
70 setMessage(message);
71 return null;
72 } catch (Exception e) { throw new CreateException(e.getMessage());}
73 }
74 public void ejbPostCreate(String hostname, String logger, Float timeStamp, String priority, String message) throws CreateException
75 {
76 }
77 /**
78 * @ejb.interface-method
79 * @ejb.pk-field
80 * @ejb.persistence column-name = "eventid"
81 * @return String
82 */
83 public abstract String getEventid();
84 /**
85 * @ejb.interface-method
86 * @ejb.persistence
87 * @return String
88 */
89 public abstract String getLogger();
90 /**
91 * @ejb.interface-method
92 * @ejb.persistent-field
93 * @return String
94 */
95 public abstract String getMessage();
96 /**
97 * @ejb.interface-method
98 * @ejb.persistence
99 * @return String
100 */
101 public abstract String getPriority();
102 /**
103 * @ejb.interface-method
104 * @ejb.persistence
105 * @return String
106 */
107 public abstract Float getTimeStamp();
108 /**
109 * @ejb.interface-method
110 * @ejb.persistence
111 * @return String
112 */
113 public abstract String getHostName();
114 /**
115 * Sets the mEventid.
116 * @param mEventid The mEventid to set
117 */
118 public abstract void setEventid(String mEventid);
119 /**
120 * Sets the mLogger.
121 * @param mLogger The mLogger to set
122 */
123 public abstract void setLogger(String mLogger);
124 /**
125 * Sets the mMessage.
126 * @param mMessage The mMessage to set
127 */
128 public abstract void setMessage(String mMessage);
129 /**
130 * Sets the mPriority.
131 * @param mPriority The mPriority to set
132 */
133 public abstract void setPriority(String mPriority);
134 /**
135 * Sets the mTimeStamp.
136 * @param mTimeStamp The mTimeStamp to set
137 */
138 public abstract void setTimeStamp(Float mTimeStamp);
139 /**
140 * Sets the mHostName.
141 * @param mHostName The mHostName to set
142 */
143 public abstract void setHostName(String mHostName);
144 /**
145 * @ejb.home-method
146 *
147 */
148 public String ejbHomeGetEventCount()
149 {
150 try {
151 return String.valueOf(ejbSelectAll().size());
152 } catch (FinderException e)
153 {
154 return "-1";
155 }
156 }
157 /**
158 * @ejb.select query = "SELECT OBJECT(a) FROM LogEvent AS a WHERE a.eventid IS NOT NULL"
159 * @return Collection
160 */
161 public abstract Collection ejbSelectAll() throws FinderException;
162 /**
163 * @ejb.select query="SELECT OBJECT(a) FROM LogEvent AS a WHERE a.timeStamp >= ?1"
164 * @return Collection
165 */
166 public abstract Collection ejbSelectFromTime(Float from) throws FinderException;
167 /**
168 * @ejb.select query="SELECT OBJECT(a) FROM LogEvent AS a WHERE a.timeStamp <= ?1"
169 * @return Collection
170 */
171 public abstract Collection ejbSelectToTime(Float to) throws FinderException;
172 /**
173 * @ejb.select query="SELECT OBJECT(a) FROM LogEvent AS a WHERE a.logger = ?1"
174 * @return Collection
175 */
176 public abstract Collection ejbSelectLogger(String logger) throws FinderException;
177 /**
178 * @ejb.select query="SELECT OBJECT(a) FROM LogEvent AS a WHERE a.message = ?1"
179 * @return Collection
180 */
181 public abstract Collection ejbSelectMessage(String message) throws FinderException;
182 /**
183 * @ejb.select query="SELECT OBJECT(a) FROM LogEvent AS a WHERE a.hostName = ?1"
184 *
185 */
186 public abstract Collection ejbSelectHostname(String hostname) throws FinderException;
187 /**
188 * @ejb.select query="SELECT DISTINCT a.priority FROM LogEvent AS a"
189 * @return Collection
190 */
191 public abstract Collection ejbSelectPriorities() throws FinderException;
192 /**
193 * @ejb.select query="SELECT DISTINCT a.logger FROM LogEvent AS a"
194 * @return Collection
195 * @throws FinderException
196 */
197 public abstract Collection ejbSelectLoggers() throws FinderException;
198 /**
199 * @ejb.select query="SELECT DISTINCT a.hostName FROM LogEvent AS a"
200 * @return Collection
201 * @throws FinderException
202 */
203 public abstract Collection ejbSelectHosts() throws FinderException;
204 /**
205 * @param hostname
206 * @param fromTime
207 * @param toTime
208 * @param priority
209 * @param message
210 * @return
211 * @throws FinderException
212 */
213 /**
214 * @ejb.home-method
215 * @deprecated
216 *
217 */
218 public Collection ejbHomeGetByParams(String hostname, Float fromTime, Float toTime, String priority, String message) throws FinderException
219 {
220 Vector all = new Vector(ejbSelectAll());
221 if (null!=hostname) all.retainAll(ejbSelectHostname(hostname));
222 if (null!=fromTime) all.retainAll(ejbSelectFromTime(fromTime));
223 if (null!=toTime) all.retainAll(ejbSelectToTime(toTime));
224 if (null!=message) all.retainAll((ejbSelectMessage(message)));
225 return all;
226 }
227 /**
228 * @ejb.home-method
229 */
230 public Collection ejbHomeGetPriorities() throws FinderException
231 {
232 return ejbSelectPriorities();
233 }
234 /**
235 * @ejb.home-method
236 */
237 public Collection ejbHomeGetLoggers() throws FinderException
238 {
239 return ejbSelectLoggers();
240 }
241 /**
242 * @ejb.home-method
243 */
244 public Collection ejbHomeGetHosts() throws FinderException
245 {
246 return ejbSelectHosts();
247 }
248 }
249 /*
250 * $Log: LogEventBean.java,v $
251 * Revision 1.20 2003/07/19 11:59:16 phah
252 * some deprecated xdoclet tags changed
253 *
254 * Revision 1.19 2003/05/04 17:45:33 phah
255 * new finder added
256 *
257 * Revision 1.18 2003/04/12 09:08:45 phah
258 * transactional behavior improved
259 *
260 * Revision 1.17 2003/04/11 20:57:06 phah
261 * sequencer removed
262 *
263 * Revision 1.16 2003/04/06 19:46:55 phah
264 * new fnder method added
265 *
266 * Revision 1.15 2003/04/04 20:07:01 phah
267 * made util helper classes work
268 *
269 * Revision 1.14 2003/04/04 16:31:29 phah
270 * made remote session fascade work
271 *
272 * Revision 1.13 2003/04/03 21:33:34 phah
273 * bugfixes
274 *
275 * Revision 1.12 2003/04/03 21:04:02 phah
276 * new xdoclet version introduced
277 *
278 * Revision 1.7 2003/04/03 18:06:18 phah
279 * some home getters added
280 *
281 * Revision 1.6 2003/03/27 21:30:29 phah
282 * implementations on cmp
283 *
284 * Revision 1.5 2003/03/24 22:28:41 phah
285 * little improvements
286 *
287 * Revision 1.4 2003/03/24 20:50:19 phah
288 * CVS comments added
289 *
290 */