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
 

Session Acquisition Overview

Oracle recommends that you export session instances from TopLink Workbench to one or more uniquely named sessions.xml files and then use the session manager to load sessions from these sessions.xml files.

The TopLink session manager enables developers to build a series of sessions that are maintained under a single entity. The session manager is a static utility class that loads TopLink sessions from the sessions.xml file, caches the sessions by name in memory, and provides a single access point for TopLink sessions. The session manager supports the following session types:

See Chapter 75, "Understanding TopLink Sessions" for detailed information on these available sessions.

The session manager has two main functions: it creates instances of the sessions; it ensures that only a single instance of each named session exists for any instance of a session manager.

This is particularly useful for EJB applications in that EJB can acquire the session manager and acquire the desired session from it.

Understanding the Session Manager

When a client application requires a session, it requests the session from the TopLink session manager. The two main functions of the session manager are to instantiate TopLink sessions for the server, and to hold the sessions for the life of the application. The session manager instantiates database sessions, server sessions, or session brokers based on the configuration information in the sessions.xml file.

The session manager instantiates sessions as follows:

  • The client application requests a session by name.

  • The session manager looks up the session name in the sessions.xml file. If the session name exists, the session manager instantiates the specified session; otherwise, it throws an exception.

  • After instantiation, the session remains viable until the application is shut down.

Multiple Sessions

Oracle does not recommend instantiating a session and passing it around as a global entity.

Oracle recommends that you acquire sessions from the session manager and perform all persistence operations using the unit of work acquired from the session.

Note that in the case of a server session or a session broker that contains server sessions, after you acquire the session you will acquire a client session from it. From a given server session (or session broker that contains server sessions), you can acquire as many client sessions as you have clients.

Each client can easily manage concurrent access and referential constraints by acquiring a unit of work from its client session and performing all persistence operations using the unit of work.