FileDocCategorySizeDatePackage
SessionEventManager.javaAPI DocGlassfish v2 API26213Tue May 22 16:54:52 BST 2007oracle.toplink.essentials.sessions

SessionEventManager

public class SessionEventManager extends Object implements Serializable, Cloneable

Purpose: Used to support session events. To register for events notification an event listener must be registered with the session.

see
Session#getEventManager()
see
SessionEvent

Fields Summary
protected Vector
listeners
protected Session
session
Constructors Summary
public SessionEventManager()
INTERNAL: Default constructor.

        this.listeners = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance();
    
public SessionEventManager(Session session)
PUBLIC: Create a new session event manager for a session

        this.listeners = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance();
        this.session = session;
    
Methods Summary
public voidaddListener(oracle.toplink.essentials.sessions.SessionEventListener listener)
PUBLIC: Add the event listener to the session. The listner will receive all events raised by this session. Also unit of works acquire from this session will inherit the listenrs.

        getListeners().addElement(listener);
    
public java.lang.Objectclone()
INTERNAL:

        try {
            return super.clone();
        } catch (Exception e) {
            return null;
        }
    
public oracle.toplink.essentials.sessions.SessionEventManagerclone(oracle.toplink.essentials.sessions.Session newSession)
INTERNAL:

        SessionEventManager newManager = (SessionEventManager)clone();
        newManager.setSession(newSession);
        Vector newListeners = (Vector)(this.getListeners().clone());
        newManager.setListeners(newListeners);
        return newManager;
    
protected voidendOperationProfile()
INTERNAL: End call

        if (getSession().isInProfile()) {
            getSession().getProfiler().endOperationProfile(SessionProfiler.SessionEvent);
        }
    
public java.util.VectorgetListeners()
PUBLIC: The event listners will receive all events raised by this session. Also unit of works acquire from this session will inherit the listenrs.

        return listeners;
    
public oracle.toplink.essentials.sessions.SessiongetSession()
INTERNAL: Get the session for this session event manager

        return session;
    
public booleanhasListeners()
PUBLIC: Check if there are any event listeners.

        return !getListeners().isEmpty();
    
public voidmissingDescriptor(java.lang.Class missingClass)
INTERNAL: Raised for missing descriptors for lazy registration.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.MissingDescriptor, getSession());
        event.setResult(missingClass);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).missingDescriptor(event);
        }
        endOperationProfile();
    
public voidmoreRowsDetected(oracle.toplink.essentials.internal.databaseaccess.DatabaseCall call)
INTERNAL: Raised for stored proc output parameters.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.MoreRowsDetected, getSession());
        event.setResult(call);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).moreRowsDetected(event);
        }
        endOperationProfile();
    
public voidnoRowsModified(oracle.toplink.essentials.queryframework.ModifyQuery query, java.lang.Object object)
INTERNAL: Raised for stored proc output parameters.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.NoRowsModified, getSession());
        event.setQuery(query);
        event.setResult(object);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).noRowsModified(event);
        }
        endOperationProfile();
    
public voidoutputParametersDetected(oracle.toplink.essentials.internal.sessions.AbstractRecord outputRow, oracle.toplink.essentials.internal.databaseaccess.DatasourceCall call)
INTERNAL: Raised for stored proc output parameters.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.OutputParametersDetected, getSession());
        event.setResult(outputRow);
        event.setProperty("call", call);
        event.setQuery(call.getQuery());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).outputParametersDetected(event);
        }
        endOperationProfile();
    
public voidpostAcquireClientSession()
INTERNAL: Post acquire client session.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostAcquireClientSession, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postAcquireClientSession(event);
        }
        endOperationProfile();
    
public voidpostAcquireConnection(oracle.toplink.essentials.internal.databaseaccess.Accessor accessor)
INTERNAL: Raised after acquire a connection from a connection pool.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostAcquireConnection, getSession());
        event.setResult(accessor);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postAcquireConnection(event);
        }
        endOperationProfile();
    
public voidpostAcquireExclusiveConnection(oracle.toplink.essentials.threetier.ClientSession clientSession, oracle.toplink.essentials.internal.databaseaccess.Accessor accessor)
INTERNAL: Raised after acquire a connection from a connection pool.

        if (!hasListeners()) {
            return;
        }

        SessionEvent event = new SessionEvent(SessionEvent.PostAcquireExclusiveConnection, clientSession);
        event.setResult(accessor);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postAcquireExclusiveConnection(event);
        }
    
public voidpostAcquireUnitOfWork()
INTERNAL: Post acquire unit of work.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostAcquireUnitOfWork, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postAcquireUnitOfWork(event);
        }
        endOperationProfile();
    
public voidpostBeginTransaction()
INTERNAL: Post begin transaction.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostBeginTransaction, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postBeginTransaction(event);
        }
        endOperationProfile();
    
public voidpostCalculateUnitOfWorkChangeSet(oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet changeSet)
INTERNAL: Post calculate UnitOfWork Change Set.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostCalculateUnitOfWorkChangeSet, getSession());
        event.setProperty("UnitOfWorkChangeSet", changeSet);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postCalculateUnitOfWorkChangeSet(event);
        }
        endOperationProfile();
    
public voidpostCommitTransaction()
INTERNAL: Post commit transaction.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostCommitTransaction, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postCommitTransaction(event);
        }
        endOperationProfile();
    
public voidpostCommitUnitOfWork()
INTERNAL: Post commit unit of work.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostCommitUnitOfWork, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postCommitUnitOfWork(event);
        }
        endOperationProfile();
    
public voidpostConnect(oracle.toplink.essentials.internal.databaseaccess.Accessor accessor)
INTERNAL: Raised after connecting.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostConnect, getSession());
        event.setResult(accessor);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postConnect(event);
        }
        endOperationProfile();
    
public voidpostDistributedMergeUnitOfWorkChangeSet(oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet changeSet)
INTERNAL: Pre execute query.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostDistributedMergeUnitOfWorkChangeSet, getSession());
        event.setProperty("UnitOfWorkChangeSet", changeSet);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postDistributedMergeUnitOfWorkChangeSet(event);
        }
        endOperationProfile();
    
public voidpostExecuteQuery(oracle.toplink.essentials.queryframework.DatabaseQuery query, java.lang.Object result)
INTERNAL: Post execute query.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostExecuteQuery, getSession());
        event.setQuery(query);
        event.setResult(result);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postExecuteQuery(event);
        }
        endOperationProfile();
    
public voidpostLogin(oracle.toplink.essentials.sessions.Session session)
INTERNAL: post login to the session.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostLogin, session);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postLogin(event);
        }
        endOperationProfile();
    
public voidpostMergeUnitOfWorkChangeSet(oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet changeSet)
INTERNAL: Pre execute query.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostMergeUnitOfWorkChangeSet, getSession());
        event.setProperty("UnitOfWorkChangeSet", changeSet);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postMergeUnitOfWorkChangeSet(event);
        }
        endOperationProfile();
    
public voidpostReleaseClientSession()
INTERNAL: Post release client session.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostReleaseClientSession, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postReleaseClientSession(event);
        }
        endOperationProfile();
    
public voidpostReleaseUnitOfWork()
INTERNAL: Post release unit of work.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostReleaseUnitOfWork, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postReleaseUnitOfWork(event);
        }
        endOperationProfile();
    
public voidpostResumeUnitOfWork()
INTERNAL: Post resume unit of work.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostResumeUnitOfWork, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postResumeUnitOfWork(event);
        }
        endOperationProfile();
    
public voidpostRollbackTransaction()
INTERNAL: Post rollback transaction.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PostRollbackTransaction, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).postRollbackTransaction(event);
        }
        endOperationProfile();
    
public voidpreBeginTransaction()
INTERNAL: Pre begin transaction.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreBeginTransaction, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preBeginTransaction(event);
        }
        endOperationProfile();
    
public voidpreCalculateUnitOfWorkChangeSet()
INTERNAL: Pre calculate UnitOfWork Change Set.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreCalculateUnitOfWorkChangeSet, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preCalculateUnitOfWorkChangeSet(event);
        }
        endOperationProfile();
    
public voidpreCommitTransaction()
INTERNAL: Pre commit transaction.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreCommitTransaction, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preCommitTransaction(event);
        }
        endOperationProfile();
    
public voidpreCommitUnitOfWork()
INTERNAL: Pre commit unit of work.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreCommitUnitOfWork, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preCommitUnitOfWork(event);
        }
        endOperationProfile();
    
public voidpreDistributedMergeUnitOfWorkChangeSet(oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet changeSet)
INTERNAL: Pre merge Distributed UnitOfWorkChangeSet

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreDistributedMergeUnitOfWorkChangeSet, getSession());
        event.setProperty("UnitOfWorkChangeSet", changeSet);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preDistributedMergeUnitOfWorkChangeSet(event);
        }
        endOperationProfile();
    
public voidpreExecuteQuery(oracle.toplink.essentials.queryframework.DatabaseQuery query)
INTERNAL: Pre execute query.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreExecuteQuery, getSession());
        event.setQuery(query);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preExecuteQuery(event);
        }
        endOperationProfile();
    
public voidpreLogin(oracle.toplink.essentials.sessions.Session session)
INTERNAL: Pre login to the session.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreLogin, session);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preLogin(event);
        }
        endOperationProfile();
    
public voidpreMergeUnitOfWorkChangeSet(oracle.toplink.essentials.internal.sessions.UnitOfWorkChangeSet changeSet)
INTERNAL: Pre merge UnitOfWorkChangeSet

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreMergeUnitOfWorkChangeSet, getSession());
        event.setProperty("UnitOfWorkChangeSet", changeSet);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preMergeUnitOfWorkChangeSet(event);
        }
        endOperationProfile();
    
public voidpreReleaseClientSession()
INTERNAL: Pre release client session.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreReleaseClientSession, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preReleaseClientSession(event);
        }
        endOperationProfile();
    
public voidpreReleaseConnection(oracle.toplink.essentials.internal.databaseaccess.Accessor accessor)
INTERNAL: Raised before release a connection to a connection pool.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreReleaseConnection, getSession());
        event.setResult(accessor);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preReleaseConnection(event);
        }
        endOperationProfile();
    
public voidpreReleaseExclusiveConnection(oracle.toplink.essentials.threetier.ClientSession clientSession, oracle.toplink.essentials.internal.databaseaccess.Accessor accessor)
INTERNAL: This event is fired just before a Client Session, with isolated data, releases its Exclusive Connection

        if (!hasListeners()) {
            return;
        }

        SessionEvent event = new SessionEvent(SessionEvent.PreReleaseExclusiveConnection, clientSession);
        event.setResult(accessor);
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preReleaseExclusiveConnection(event);
        }
    
public voidpreReleaseUnitOfWork()
INTERNAL: Pre release unit of work.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreReleaseUnitOfWork, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preReleaseUnitOfWork(event);
        }
        endOperationProfile();
    
public voidpreRollbackTransaction()
INTERNAL: Pre rollback transaction.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PreRollbackTransaction, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).preRollbackTransaction(event);
        }
        endOperationProfile();
    
public voidprepareUnitOfWork()
INTERNAL: Prepare unit of work.

        if (!hasListeners()) {
            return;
        }
        startOperationProfile();
        SessionEvent event = new SessionEvent(SessionEvent.PrepareUnitOfWork, getSession());
        for (Enumeration listenerEnum = getListeners().elements(); listenerEnum.hasMoreElements();) {
            ((SessionEventListener)listenerEnum.nextElement()).prepareUnitOfWork(event);
        }
        endOperationProfile();
    
public voidremoveListener(oracle.toplink.essentials.sessions.SessionEventListener listener)
PUBLIC: Remove the event listener from the session.

        getListeners().removeElement(listener);
    
protected voidsetListeners(java.util.Vector listeners)
The event listners will receive all events raised by this session. Also unit of works acquire from this session will inherit the listenrs.

        this.listeners = listeners;
    
public voidsetSession(oracle.toplink.essentials.sessions.Session session)
INTERNAL: Set the session for this session event manager

        this.session = session;
    
protected voidstartOperationProfile()
INTERNAL: Start call

        if (getSession().isInProfile()) {
            getSession().getProfiler().startOperationProfile(SessionProfiler.SessionEvent);
        }