Skip Headers

Oracle TopLink Developer's Guide 10g Release 3 (10.1.3) B13593-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# PostAcquireExclusiveConnection Event Handler

TopLink raises this event after an exclusive connection is allocated to an isolated session after the user has logged in to the database with it.

If you are using Oracle Database proxy authentication (see "Oracle Database Proxy Authentication"), then you do not need to implement this session event handler.

If you are not using Oracle Database proxy authentication, then, as part of the isolated session life cycle, you must implement a `SessionEventListener` for `SessionEvent.PostAcquireExclusiveConnection`.

Note: You must add this session event listener to the server session from which you acquire your isolated client session. You cannot add them to the isolated client session itself. For more information, see "Configuring Session Event Listeners"

## Using Java

The `SessionEvent.PostAcquireExclusiveConnection` event listener is your opportunity to authenticate your user and interact with the underlying database platform: for example, to execute PL/SQL to create VPD packages and set VPD context information.

Example 80-1 illustrates a typical session event listener used to handle `postAcquireExclusiveConnection` events for an isolated session.

Example 80-1 Session Event Listener for an Isolated Session

    class VPDEventListener extends SessionEventAdaptor{
        public void postAcquireExclusiveConnection(SessionEvent event){
            ClientSession session = (ClientSession)event.getSession();
            // Get property set on the ConnectionPolicy prior to acquiring the connection
            String userLevel = session.getConnectionPolicy().getProperty("userLevel");
            // Make the Stored Procedure call for VPD to set up the Context Information
            session.executeNonSelectingSQL("StoreProcSetContextUser("+ userLevel + ")");
        }
    }

To get the required user credentials, use `ClientSession` method `getConnectionPolicy` to get the associated `ConnectionPolicy`, and then use `ConnectionPolicy` method `getProperty`. The `ConnectionPolicy` associated with the `ClientSession` should contain all required user credentials (see "Configuring Connection Policy").

After you implement the required `SessionEventListener`, add it to the parent server session from which you acquire your isolated client session. For more information, see "Configuring Session Event Listeners".