KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > sessions > SessionEvent


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.sessions;
23
24 import java.util.*;
25 import oracle.toplink.essentials.queryframework.*;
26
27 /**
28  * <p><b>Purpose</b>: Encapsulate the information provided with session events.
29  * This is used as the argument to any event raised by the session.
30  * To register for events notification an event listener must be registered with the session.
31  *
32  * @see SessionEventManager#addListener(SessionEventListener)
33  * @see Session#getEventManager()
34  * @see SessionEventListener
35  */

36 public class SessionEvent extends EventObject {
37
38     /** Some events may have a query associated with them (pre/postExecuteQuery). */
39     protected DatabaseQuery query;
40
41     /** Some events may have a result associated with them (pre/postExecuteQuery). */
42     protected Object JavaDoc result;
43
44     /** The session or unit of work raising the event. */
45     protected Session session;
46
47     /** The code of the event being raised. This is an integer constant value as defined below. */
48     protected int eventCode;
49
50     /** Additional properties may be added. */
51     protected Hashtable properties;
52     public static final int PreExecuteQuery = 1;
53     public static final int PostExecuteQuery = 2;
54     public static final int PreBeginTransaction = 3;
55     public static final int PostBeginTransaction = 4;
56     public static final int PreCommitTransaction = 5;
57     public static final int PostCommitTransaction = 6;
58     public static final int PreRollbackTransaction = 7;
59     public static final int PostRollbackTransaction = 8;
60
61     // Unit of work events, only raised on unit of work.
62
public static final int PostAcquireUnitOfWork = 9;
63     public static final int PreCommitUnitOfWork = 10;
64     public static final int PostCommitUnitOfWork = 11;
65     public static final int PreReleaseUnitOfWork = 12;
66     public static final int PostReleaseUnitOfWork = 13;
67     public static final int PrepareUnitOfWork = 14;
68     public static final int PostResumeUnitOfWork = 15;
69
70     // Three-tier events, only raised on server/client session.
71
public static final int PostAcquireClientSession = 16;
72     public static final int PreReleaseClientSession = 17;
73     public static final int PostReleaseClientSession = 18;
74     public static final int PostAcquireConnection = 22;
75     public static final int PostAcquireExclusiveConnection = 33;
76     public static final int PreReleaseConnection = 23;
77     public static final int PreReleaseExclusiveConnection = 34;
78
79     // Database access events.
80
public static final int OutputParametersDetected = 19;
81     public static final int MoreRowsDetected = 20;
82     public static final int PostConnect = 21;
83
84     // Login events
85
public static final int PreLogin = 24;
86     public static final int PostLogin = 25;
87     public static final int PreMergeUnitOfWorkChangeSet = 26;
88     public static final int PreDistributedMergeUnitOfWorkChangeSet = 27;
89     public static final int PostMergeUnitOfWorkChangeSet = 28;
90     public static final int PostDistributedMergeUnitOfWorkChangeSet = 29;
91
92     //ChangeSet Events
93
public static final int PreCalculateUnitOfWorkChangeSet = 30;
94     public static final int PostCalculateUnitOfWorkChangeSet = 31;
95     public static final int MissingDescriptor = 32;
96     public static final int NoRowsModified = 35;
97
98     // last event value for this class as of Jan 26th, 2004 is 35
99

100     /**
101      * INTERNAL:
102      * Create the event.
103      */

104     public SessionEvent(int eventCode, Session session) {
105         super(session);
106         this.session = session;
107         this.eventCode = eventCode;
108     }
109
110     /**
111      * PUBLIC:
112      * The code of the session event being raised.
113      * This is an integer constant value from this class.
114      */

115     public int getEventCode() {
116         return eventCode;
117     }
118
119     /**
120      * PUBLIC:
121      * Additional properties may be added to the event.
122      */

123     public Hashtable getProperties() {
124         if (properties == null) {
125             properties = new Hashtable(2);
126         }
127         return properties;
128     }
129
130     /**
131      * PUBLIC:
132      * Additional properties may be added to the event.
133      */

134     public Object JavaDoc getProperty(String JavaDoc name) {
135         return getProperties().get(name);
136     }
137
138     /**
139      * PUBLIC:
140      * Some events may have a query associated with them (pre/postExecuteQuery).
141      */

142     public DatabaseQuery getQuery() {
143         return query;
144     }
145
146     /**
147      * PUBLIC:
148      * Some events may have a result associated with them (pre/postExecuteQuery).
149      */

150     public Object JavaDoc getResult() {
151         return result;
152     }
153
154     /**
155      * PUBLIC:
156      * The session in which the event is raised.
157      */

158     public Session getSession() {
159         return session;
160     }
161
162     /**
163      * INTERNAL:
164      * The code of the session event being raised.
165      * This is an integer constant value from this class.
166      */

167     public void setEventCode(int eventCode) {
168         this.eventCode = eventCode;
169     }
170
171     /**
172      * INTERNAL:
173      * Additional properties may be added to the event.
174      */

175     public void setProperties(Hashtable properties) {
176         this.properties = properties;
177     }
178
179     /**
180      * INTERNAL:
181      * Additional properties may be added to the event.
182      */

183     public void setProperty(String JavaDoc name, Object JavaDoc value) {
184         getProperties().put(name, value);
185     }
186
187     /**
188      * INTERNAL:
189      * Some events may have a query associated with them (pre/postExecuteQuery).
190      */

191     public void setQuery(DatabaseQuery query) {
192         this.query = query;
193     }
194
195     /**
196      * INTERNAL:
197      * Some events may have a result associated with them (pre/postExecuteQuery).
198      */

199     public void setResult(Object JavaDoc result) {
200         this.result = result;
201     }
202
203     /**
204      * INTERNAL:
205      * The session in which the event is raised.
206      */

207     public void setSession(Session session) {
208         this.session = session;
209     }
210 }
211
Popular Tags