Skip Headers

# Loading a Session From an Alternative Session Configuration File

Previous

Next

If your session instances are contained in multiple, uniquely named session configuration files (`sessions.xml` files), then you must explicitly create an `XMLSessionConfigLoader` object initialized with the name of the `sessions.xml` file and pass that `XMLSessionConfigLoader` into the `SessionManager` method `getSession`, as Example: Loading a Session from an Alternative Configuration File illustrates.

The file path you specify is relative to the class loader root directory. Relative resource paths in Java must use the forward slash ( `/` ), not back slash ( `\ )`.

In this example, the session named `mysession` is loaded by the specified class loader from the first file in the application classpath named `toplink-sessions.xml`.

Loading a Session from an Alternative Configuration File

    /* XMLSessionConfigLoader loads the toplink-sessions.xml file */
    SessionManager manager = SessionManager.getManager();
    manager.getSession(
        new XMLSessionConfigLoader("toplink-sessions.xml"),
        "mysession",
        this.class.getClassLoader()
    );