1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
|
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021 IBM Corporation. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.sessions;
import java.util.*;
import org.eclipse.persistence.queries.*;
/**
* <p><b>Purpose</b>: Encapsulate the information provided with session events.
* This is used as the argument to any event raised by the session.
* To register for events notification an event listener must be registered with the session.
*
* @see SessionEventManager#addListener(SessionEventListener)
* @see Session#getEventManager()
* @see SessionEventListener
*/
public class SessionEvent extends EventObject {
/** Some events may have a query associated with them (pre/postExecuteQuery). */
protected DatabaseQuery query;
/** Some events may have a call associated with them (pre/postExecuteCall). */
protected Call call;
/** Some events may have a result associated with them (pre/postExecuteQuery). */
protected Object result;
/** The session or unit of work raising the event. */
protected Session session;
/** The code of the event being raised. This is an integer constant value as defined below. */
protected int eventCode;
/** Additional properties may be added. */
protected Hashtable properties;
public static final int PreExecuteQuery = 1;
public static final int PostExecuteQuery = 2;
public static final int PreBeginTransaction = 3;
public static final int PostBeginTransaction = 4;
public static final int PreCommitTransaction = 5;
public static final int PostCommitTransaction = 6;
public static final int PreRollbackTransaction = 7;
public static final int PostRollbackTransaction = 8;
public static final int PreExecuteCall = 36;
public static final int PostExecuteCall = 37;
// Unit of work events, only raised on unit of work.
public static final int PostAcquireUnitOfWork = 9;
public static final int PreCommitUnitOfWork = 10;
public static final int PostCommitUnitOfWork = 11;
public static final int PreReleaseUnitOfWork = 12;
public static final int PostReleaseUnitOfWork = 13;
public static final int PrepareUnitOfWork = 14;
public static final int PostResumeUnitOfWork = 15;
// Three-tier events, only raised on server/client session.
public static final int PostAcquireClientSession = 16;
public static final int PreReleaseClientSession = 17;
public static final int PostReleaseClientSession = 18;
public static final int PostAcquireConnection = 22;
public static final int PostAcquireExclusiveConnection = 33;
public static final int PreReleaseConnection = 23;
public static final int PreReleaseExclusiveConnection = 34;
// Database access events.
public static final int OutputParametersDetected = 19;
public static final int MoreRowsDetected = 20;
public static final int PostConnect = 21;
// Login events
public static final int PreLogin = 24;
public static final int PostLogin = 25;
public static final int PreLogout = 40;
public static final int PostLogout = 41;
public static final int PreMergeUnitOfWorkChangeSet = 26;
public static final int PreDistributedMergeUnitOfWorkChangeSet = 27;
public static final int PostMergeUnitOfWorkChangeSet = 28;
public static final int PostDistributedMergeUnitOfWorkChangeSet = 29;
//ChangeSet Events
public static final int PreCalculateUnitOfWorkChangeSet = 30;
public static final int PostCalculateUnitOfWorkChangeSet = 31;
public static final int MissingDescriptor = 32;
public static final int NoRowsModified = 35;
// last event value for this class as of Jan 26th, 2004 is 41
/**
* INTERNAL:
* Create the event.
*/
public SessionEvent(int eventCode, Session session) {
super(session);
this.session = session;
this.eventCode = eventCode;
}
/**
* PUBLIC:
* The code of the session event being raised.
* This is an integer constant value from this class.
*/
public int getEventCode() {
return eventCode;
}
/**
* PUBLIC:
* Additional properties may be added to the event.
*/
public Hashtable getProperties() {
if (properties == null) {
properties = new Hashtable(2);
}
return properties;
}
/**
* PUBLIC:
* Additional properties may be added to the event.
*/
public Object getProperty(String name) {
return getProperties().get(name);
}
/**
* PUBLIC:
* Some events may have a call associated with them (pre/postExecuteCall).
*/
public Call getCall() {
return call;
}
/**
* PUBLIC:
* Some events may have a query associated with them (pre/postExecuteQuery).
*/
public DatabaseQuery getQuery() {
return query;
}
/**
* PUBLIC:
* Some events may have a result associated with them (pre/postExecuteQuery).
*/
public Object getResult() {
return result;
}
/**
* PUBLIC:
* The session in which the event is raised.
*/
public Session getSession() {
return session;
}
/**
* INTERNAL:
* The code of the session event being raised.
* This is an integer constant value from this class.
*/
public void setEventCode(int eventCode) {
this.eventCode = eventCode;
}
/**
* INTERNAL:
* Additional properties may be added to the event.
*/
public void setProperties(Hashtable properties) {
this.properties = properties;
}
/**
* INTERNAL:
* Additional properties may be added to the event.
*/
public void setProperty(String name, Object value) {
getProperties().put(name, value);
}
/**
* INTERNAL:
* Some events may have a call associated with them (pre/postExecuteCall).
*/
public void setCall(Call call) {
this.call = call;
}
/**
* INTERNAL:
* Some events may have a query associated with them (pre/postExecuteQuery).
*/
public void setQuery(DatabaseQuery query) {
this.query = query;
}
/**
* INTERNAL:
* Some events may have a result associated with them (pre/postExecuteQuery).
*/
public void setResult(Object result) {
this.result = result;
}
/**
* INTERNAL:
* The session in which the event is raised.
*/
public void setSession(Session session) {
this.session = session;
}
}
|