Class SessionFactoryImpl

  • All Implemented Interfaces:
    SessionFactory

    public class SessionFactoryImpl
    extends java.lang.Object
    implements SessionFactory
    This class implements methods for creating local Session.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SessionFactoryImpl

        public SessionFactoryImpl()
    • Method Detail

      • createSession

        public 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);
                }
         
        Specified by:
        createSession in interface SessionFactory
        Returns:
        The Session object.
        Throws:
        DIException - if an error occurs while creating Session.
      • createSession

        public 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);
                }
         
        Specified by:
        createSession in interface SessionFactory
        Parameters:
        aUserName - the username for authentication.
        aPassword - the password for authentication.
        Returns:
        The Session object.
        Throws:
        DIException - if an error occurs while creating Session.