Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Configuring Session Event Listeners

As you perform persistence operations with a session, the session produces various events (see "Session Event Manager Events") that the TopLink runtime uses to coordinate its various components. You can configure a session with one or more session event listeners (see "Session Event Listeners") to customize session behavior and debug session operations. For example, session event listeners play an important role in the configuration of isolated sessions (see "Configuring Isolated Client Sessions").

Table 77-14 summarizes which sessions support event listeners.

Using TopLink Workbench

Session Event Listeners

To specify the event listener class in a session, use this procedure:

  1. Select a session in the Navigator. Its properties appear in the Editor.

  2. Click the Options tab. The Options tab appears.

    Figure 77-8 Options Tab, Event Listeners field

    Event Listeners

To add a new event listener, click Add, then select the event listener class for this session.

To remove an existing event listener, select the Event Listener and click Remove.

Using Java

Example 77-8 illustrates how to use Java to register a session event listener with a session. TopLink provides a SessionEventAdapter to simplify creating a SessionEventListener. The SessionEventAdapter provides a default implementation of all the methods of the SessionEventListener interface. You need only override the specific methods of interest. Typically, you would define session event listeners in a session customizer class (see "Configuring Customizer Class").

Example 77-8 Using the Session Event Adapter to Create a Session Event Listener

...
SessionEventAdapter myEventListener = new SessionEventAdapter() 
{
    // Listen for PostCommitUnitOfWork events
    public void postCommitUnitOfWork(SessionEvent event)
    {
        // Call the handler routine
        unitOfWorkCommitted();
    }
};
mySession.getEventManager().addListener(myEventListener);
...