001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: CallbackLogger.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger;
025:
026: import java.io.Serializable;
027: import java.text.MessageFormat;
028:
029: import javax.persistence.DiscriminatorValue;
030: import javax.persistence.Entity;
031: import javax.persistence.EnumType;
032: import javax.persistence.Enumerated;
033: import javax.persistence.GeneratedValue;
034: import javax.persistence.GenerationType;
035: import javax.persistence.Id;
036: import javax.persistence.Inheritance;
037: import javax.persistence.InheritanceType;
038: import javax.persistence.NamedQueries;
039: import javax.persistence.NamedQuery;
040: import javax.persistence.Table;
041: import javax.persistence.TableGenerator;
042:
043: /**
044: * Used to log the callback events.
045: * @author Gisele Pinheiro Souza
046: * @author Eduardo Studzinski Estima de Castro
047: *
048: */
049: @Entity
050: @Table(name="CALLBACKLOGGER")
051: @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
052: @DiscriminatorValue("Type")
053: @TableGenerator(name="MANAGER_SEQ",allocationSize=1)
054: @NamedQueries({@NamedQuery(name="findAll",query="SELECT e FROM CallbackLogger e "),@NamedQuery(name="findLifecycleEvent",query="SELECT e FROM CallbackLogger e WHERE e.className = :className AND" + " e.callbackEvent= :event"),@NamedQuery(name="findLifecycleEventByClass",query="SELECT e FROM CallbackLogger e WHERE e.className = :className"),@NamedQuery(name="findLifecycleEventByCallbackMethod",query="SELECT e FROM CallbackLogger e " + "WHERE e.className = :className AND e.callbackClassName= :callbackClassName AND e.callbackEvent= :event")})
055: public class CallbackLogger implements Serializable {
056:
057: /**
058: * Class ID.
059: */
060: private static final long serialVersionUID = 5508063145575159629L;
061:
062: /**
063: * The logger identifier.
064: */
065: private int id;
066:
067: /**
068: * The class for which the callback method was called.
069: */
070: private String className;
071:
072: /**
073: * The callback event.
074: */
075: private CallbackType callbackEvent;
076:
077: /**
078: * The time in milliseconds when the callback event was called.
079: */
080: private long insertionDate;
081:
082: /**
083: * The class that contains the method callback.
084: */
085: private String callbackClassName;
086:
087: /**
088: * Gets the name of the class that has the callback method.
089: * @return the class name.
090: */
091: public String getCallbackClassName() {
092: return callbackClassName;
093: }
094:
095: /**
096: * Sets the cname of the class that has the callback method.
097: * @param callbackClassName the class name.
098: */
099: public void setCallbackClassName(final String callbackClassName) {
100: this .callbackClassName = callbackClassName;
101: }
102:
103: /**
104: * Gets the callback event type.
105: * @return the callback event type.
106: */
107: @Enumerated(EnumType.STRING)
108: public CallbackType getCallbackEvent() {
109: return callbackEvent;
110: }
111:
112: /**
113: * Sets the callback event type.
114: * @param callbackEvent the callback event.
115: */
116: public void setCallbackEvent(final CallbackType callbackEvent) {
117: this .callbackEvent = callbackEvent;
118: }
119:
120: /**
121: * Gets the name of the class that was intercepted by the callback method.
122: * @return the class name.
123: */
124: public String getClassName() {
125: return className;
126: }
127:
128: /**
129: * Sets the name of the class that was intercepted by the callback method.
130: * @param className the class name.
131: */
132: public void setClassName(final String className) {
133: this .className = className;
134: }
135:
136: /**
137: * Gets the entity identifier.
138: * @return the identifier.
139: */
140: @Id
141: @GeneratedValue(strategy=GenerationType.TABLE,generator="MANAGER_SEQ")
142: public int getId() {
143: return id;
144: }
145:
146: /**
147: * Sets the entity identifier.
148: * @param id the identifier.
149: */
150: public void setId(final int id) {
151: this .id = id;
152: }
153:
154: /**
155: * Gets the time in millisencodes in which the entity was inserted in the database.
156: * @return the time.
157: */
158: public long getInsertionDate() {
159: return insertionDate;
160: }
161:
162: /**
163: * Gets the time in millisencodes in which the entity is inserted in the database.
164: * @param insertionDate the date.
165: */
166: public void setInsertionDate(final long insertionDate) {
167: this .insertionDate = insertionDate;
168: }
169:
170: /**
171: * String representation of the object.
172: * @return object representation
173: */
174: @SuppressWarnings("boxing")
175: @Override
176: public String toString() {
177: return MessageFormat
178: .format(
179: "{0}, ID = {1}, ClassName = {2}, CallbackClassName = {3}, CallbackEvent = {4}, Date = {5}",
180: CallbackLogger.class.getName(), id, className,
181: callbackClassName, callbackEvent, insertionDate);
182: }
183: }
|