Skip Headers

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

Previous | Next |

# Creating Session Broker and Client Sessions

A session broker may contain both server sessions and database sessions. Oracle recommends that you use the session broker with server sessions because server sessions are the most scalable session type.

Oracle recommends that you create server sessions using TopLink Workbench (see "Using TopLink Workbench").

After you create and configure a session broker with server sessions, you can acquire a client session from the session broker at run time to provide a dedicated connection to all the data sources managed by the session broker for each client. For more information, see "Acquiring a Client Session".

## Using TopLink Workbench

Before you create a session broker session, you must first create a sessions configuration (see "Creating a Sessions Configuration") and one or more server sessions ("Creating a Server Session"), or one or more database sessions ("Creating Database Sessions").

To create a new TopLink session broker, use this procedure:

1. Select the sessions configuration in the Navigator window in which you want to create a session broker.

2. Click Add Session Broker on the toolbar. The Create New Session Broker dialog box appears.

   You can also create a new session broker by right-clicking the sessions configuration in the Navigator window and selecting Add Session Broker from the context menu or by clicking Add Session Broker on the Sessions Configuration property sheet.

   Figure 76-4 Create New Session Broker Dialog Box

Use the following information to enter data in each field of the dialog box:

Field | Description
--- | ---
Name | Specify the name of the new session broker.
Use Server Platform | Check this field if you intend to deploy your application to a J2EE application server. If you check this field, you must configure the target application server by selecting a Platform.
Platform | This option is available only if you check Use Server Platform. Select the J2EE application server to which you will deploy your application. TopLink supports the following J2EE application servers: OC4J 10.1.3 OC4J 9.0.3Foot 1 WebLogic 8.1 WebLogic 7.0 WebLogic 6.1 websphere 5.1 websphere 5.0 websphere 4.0 Custom The server platform you select is the default server platform for all sessions you create in this sessions configuration. At the session level, you can override this selection or specify a custom server platform class (see "Configuring the Server Platform").
Select the sessions to Manage | Select sessions to be managed by this new session broker (from the list of available sessions) and click OK. Note: This field appears only if the configuration contains valid sessions.

Footnote 1 Includes support for both 9.0.3 and 9.0.4.

Continue with Chapter 77, "Configuring a Session".

## Using Java

Example 76-4 illustrates how you can create a session broker in Java code by instantiating a `SessionBroker` and registering the brokered sessions with it.

Because the session broker references other sessions, configure these sessions before instantiating the session broker. Add all required descriptors to the session, but do not initialize the descriptors or log the sessions. The session broker manages these issues when you instantiate it.

Example 76-4 Creating a Session Broker

    Project databaseProject = new MyDatabaseProject();
    Server databaseSession = databaseProject.createServerSession();

    Project eisProject = new MyEISProject();
    Server eisSession = eisProject.createServerSession();

    SessionBroker sessionBroker = new SessionBroker();
    sessionBroker.registerSession("myDatabase", databaseSession);
    sessionBroker.registerSession("myEIS", eisSession);

    sessionBroker.login();