KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > entity > callbacklogger > CallbackLogger


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: CallbackLogger.java 783 2006-06-27 12:25:52Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger;
26
27 import java.io.Serializable JavaDoc;
28 import java.text.MessageFormat JavaDoc;
29
30 import javax.persistence.DiscriminatorValue;
31 import javax.persistence.Entity;
32 import javax.persistence.EnumType;
33 import javax.persistence.Enumerated;
34 import javax.persistence.GeneratedValue;
35 import javax.persistence.GenerationType;
36 import javax.persistence.Id;
37 import javax.persistence.Inheritance;
38 import javax.persistence.InheritanceType;
39 import javax.persistence.NamedQueries;
40 import javax.persistence.NamedQuery;
41 import javax.persistence.Table;
42 import javax.persistence.TableGenerator;
43
44 /**
45  * Used to log the callback events.
46  * @author Gisele Pinheiro Souza
47  * @author Eduardo Studzinski Estima de Castro
48  *
49  */

50 @Entity
51 @Table(name = "CALLBACKLOGGER")
52 @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
53 @DiscriminatorValue("Type")
54 @TableGenerator(name = "MANAGER_SEQ", allocationSize = 1)
55 @NamedQueries({
56         @NamedQuery(name = "findAll", query = "SELECT e FROM CallbackLogger e "),
57         @NamedQuery(name = "findLifecycleEvent", query = "SELECT e FROM CallbackLogger e WHERE e.className = :className AND"
58                 + " e.callbackEvent= :event"),
59         @NamedQuery(name = "findLifecycleEventByClass", query = "SELECT e FROM CallbackLogger e WHERE e.className = :className"),
60         @NamedQuery(name = "findLifecycleEventByCallbackMethod", query = "SELECT e FROM CallbackLogger e "
61                 + "WHERE e.className = :className AND e.callbackClassName= :callbackClassName AND e.callbackEvent= :event")})
62 public class CallbackLogger implements Serializable JavaDoc{
63
64     /**
65      * Class ID.
66      */

67     private static final long serialVersionUID = 5508063145575159629L;
68
69     /**
70      * The logger identifier.
71      */

72     private int id;
73
74     /**
75      * The class for which the callback method was called.
76      */

77     private String JavaDoc className;
78
79   /**
80      * The callback event.
81      */

82    private CallbackType callbackEvent;
83
84     /**
85      * The time in milliseconds when the callback event was called.
86      */

87     private long insertionDate;
88
89     /**
90      * The class that contains the method callback.
91      */

92     private String JavaDoc callbackClassName;
93
94     /**
95      * Gets the name of the class that has the callback method.
96      * @return the class name.
97      */

98     public String JavaDoc getCallbackClassName() {
99         return callbackClassName;
100     }
101
102     /**
103      * Sets the cname of the class that has the callback method.
104      * @param callbackClassName the class name.
105      */

106     public void setCallbackClassName(final String JavaDoc callbackClassName) {
107         this.callbackClassName = callbackClassName;
108     }
109
110     /**
111      * Gets the callback event type.
112      * @return the callback event type.
113      */

114     @Enumerated(EnumType.STRING)
115     public CallbackType getCallbackEvent() {
116          return callbackEvent;
117     }
118
119     /**
120      * Sets the callback event type.
121      * @param callbackEvent the callback event.
122      */

123     public void setCallbackEvent(final CallbackType callbackEvent) {
124         this.callbackEvent = callbackEvent;
125     }
126
127     /**
128      * Gets the name of the class that was intercepted by the callback method.
129      * @return the class name.
130      */

131     public String JavaDoc getClassName() {
132         return className;
133     }
134
135     /**
136      * Sets the name of the class that was intercepted by the callback method.
137      * @param className the class name.
138      */

139     public void setClassName(final String JavaDoc className) {
140         this.className = className;
141     }
142
143     /**
144      * Gets the entity identifier.
145      * @return the identifier.
146      */

147     @Id
148     @GeneratedValue(strategy = GenerationType.TABLE, generator = "MANAGER_SEQ")
149     public int getId() {
150         return id;
151     }
152
153     /**
154      * Sets the entity identifier.
155      * @param id the identifier.
156      */

157     public void setId(final int id) {
158         this.id = id;
159     }
160
161     /**
162      * Gets the time in millisencodes in which the entity was inserted in the database.
163      * @return the time.
164      */

165     public long getInsertionDate() {
166         return insertionDate;
167     }
168
169     /**
170      * Gets the time in millisencodes in which the entity is inserted in the database.
171      * @param insertionDate the date.
172      */

173     public void setInsertionDate(final long insertionDate) {
174         this.insertionDate = insertionDate;
175     }
176
177     /**
178      * String representation of the object.
179      * @return object representation
180      */

181     @SuppressWarnings JavaDoc("boxing")
182     @Override JavaDoc
183     public String JavaDoc toString(){
184         return MessageFormat.format("{0}, ID = {1}, ClassName = {2}, CallbackClassName = {3}, CallbackEvent = {4}, Date = {5}",
185                 CallbackLogger.class.getName(), id, className, callbackClassName, callbackEvent, insertionDate);
186     }
187 }
188
Popular Tags