com.ibm.di.api.local
Interface SessionFactory

All Known Implementing Classes:
SessionFactoryImpl

public interface SessionFactory

This interface provides methods for creating a Session.


Method Summary
 Session createSession()
          Creates a session object.
 Session createSession(java.lang.String aUserName, java.lang.String aPassword)
          Creates a session object with the specified username and password.
 

Method Detail

createSession

Session createSession()
                      throws DIException
Creates a session object.

Example:

 var session = APIEngine.getLocalSession();
 var runningConfigs = session.getConfigInstances();
 

Example:

        var session = (new com.ibm.di.api.local.impl.SessionFactoryImpl).createSession();
        var serverInfo = session.getServerInfo();
        if (serverInfo == null) {
        throw new Exception("Server version information is not available!");
        }
 
        var serverVersion = serverInfo.getServerVersion();
        if (serverVersion.startsWith("7.1")) { 
        // TDI 7.1 specific code
        }
        else if (serverVersion.startsWith("7.0")) {
        // TDI 7.0 specific code
        }
        else if (serverVersion.startsWith("6.1")) {
        // TDI 6.1 specific code
        }
        else {
        throw new Exception("Unsupported TDI server version: " + serverVersion);
        }
 

Returns:
The Session object.
Throws:
DIException - if an error occurs while creating Session.

createSession

Session createSession(java.lang.String aUserName,
                      java.lang.String aPassword)
                      throws DIException
Creates a session object with the specified username and password.

Example:

 var session = APIEngine.getLocalSession("username", "password");
 var runningConfigs = session.getConfigInstances();
 

Example:

        var nick = "Username";
        var pass = "Difficult password"
 
//Notecustom authentication must be enabled
        var session = (new com.ibm.di.api.local.impl.SessionFactoryImpl).createSession(nick , pass);
        var serverInfo = session.getServerInfo();
        if (serverInfo == null) {
        throw new Exception("Server version information is not available!");
        }
 
        var serverVersion = serverInfo.getServerVersion();
        if (serverVersion.startsWith("7.1")) { 
        // TDI 7.1 specific code
        }
        else if (serverVersion.startsWith("7.0")) {
        // TDI 7.0 specific code
        }
        else if (serverVersion.startsWith("6.1")) {
        // TDI 6.1 specific code
        }
        else {
        throw new Exception("Unsupported TDI server version: " + serverVersion);
        }
 

Parameters:
aUserName - the username for authentication.
aPassword - the password for authentication.
Returns:
The Session object.
Throws:
DIException - if an error occurs while creating Session.