com.attachmate.UPG.SessionLoader
Class SessionLoader

com.attachmate.UPG.SessionLoader.SessionLoader

public class SessionLoader

Initializes the specified host session. This object is usually used an a Singleton. Only one instance per application. By following this design pattern you can reduce memory usage and increase screen object instantiation.

Version:
3.1

Constructor Summary
SessionLoader()
           
 
Method Summary
 java.lang.String getConfigurationIPAddress()
          Gets the Server Address to be used by all subsequent calls to requestScreen()
 int getTerminalType()
          Gets the default Screen Type to be used for retrieving Screen Objects.
 IScreenUPG requestScreen(java.lang.String User, java.lang.String Password, java.lang.String WebView)
          Gets a Screen object for the specified WebView, instantiated with the specified user and password, as well as the configuration specified by the WebView.
 IScreenUPG requestScreenEx(java.lang.String User, java.lang.String Password, java.lang.String ScreenData, int internalUse)
          Gets a Screen object, instantiated with the specified user and password, as well as the configuration specified by the XML Data.
 void setConfigurationIPAddress(java.lang.String Server)
          Sets a Server Address to be used by all subsequent calls to requestScreen()
 void setResourceManagerOptions(int ir, int ri, java.lang.String rsa)
          Specifies the initial number of terminal or session IDs that are allocated to the application from e-Vantage ID Manager, as well as the increment in which additional IDs will be obtained when all allocated IDs are already in use.
 void setTerminalType(int Type)
          Sets a default Screen Type to be used for retrieving Screen Objects.
 void Shutdown()
          Ensures that all IDs defined with a Lease Timeout (from e-Vantage ID Manager) are properly retained by the SDK for future use, once your application no longer requires them.
 

Constructor Detail

SessionLoader

public SessionLoader()
Method Detail

getConfigurationIPAddress

public java.lang.String getConfigurationIPAddress()
Gets the Server Address to be used by all subsequent calls to requestScreen()
See Also:

getTerminalType

public int getTerminalType()
Gets the default Screen Type to be used for retrieving Screen Objects. when using requestScreen(). If setTerminalType was not called 0 will be returned.
Parameters:
Type - A valid Screen Type. Valid Types: T27 = 100 UTS = 105 3270 = 110 5250 = 115 VT = 120 ALC = 125

requestScreen

public IScreenUPG requestScreen(java.lang.String User,
                                java.lang.String Password,
                                java.lang.String WebView)
                         throws SessionException
Gets a Screen object for the specified WebView, instantiated with the specified user and password, as well as the configuration specified by the WebView.
Parameters:
User - A valid user name defined in the Management and Control Server. The user must have Management console access permission.
Password - The password assigned to the user specified with the User parameter.
WebView - A valid WebView defined in HAS.
Throws:
SessionException - Returned if the requested session could not be loaded.
Examples:
Java:

 SessionLoader sl = new SessionLoader();
 
 //The following is only applicable if you are using ID Manager to obtain IDs.
 sl.setResourceManagerOptions(75,25,"");
 //End of ID Manager-specific code.
 
 ScreenUts m_ScreenObj;
 try {
     m_ScreenObj = (ScreenUts) sl.requestScreen("User","Password","WebView");
 }
 catch (SessionException se){
   System.out.println(se.getMessage());
 }
 if(m_screenObj.Open())
   System.out.println("Connected!");
 else
   System.out.println("Host Connection Failed!");
 m_screenObj.Closed();

ASP (VBScript):

 dim loaderObj 
 
 'The following is only applicable if you are using ID Manager to obtain IDs.
 loaderObj.setResourceManagerOptions(75,25,"")
 'End of ID Manager-specific code.
 
 On error resume next
 set loaderObj = Server.CreateObject("SessionLoader.SessionLoader") 
 set Session("screenObj") = loaderObj.requestScreen("User","Password","WebView") 
 If Session("screenObj").Open = True Then 
     Session("Session("sreenObj")").waitHostQuiet 1000,5000
     Response.write (Session("screenObj").gettext) 
     Session("screenObj").Close 
 else 
     Response.write("Open of WebView failed!") 
 End if

C++:

 …
 void Screen::start(void)
 {
    TRY
    {
       //The following is only applicable if you are using ID Manager to obtain IDs.
       m_SessLoader.setResourceManagerOptions(75,25,"");
       //End of ID Manager-specific code.
 
       CLSID clsid;
       HRESULT hr = ::CLSIDFromProgID(L"SessionLoader.SessionLoader", &clsid);
       if (FAILED(hr))
       {
          AfxThrowOleException(hr);
       }
       if (m_sessLoader.CreateDispatch(clsid))
       {
          TRY
          {
             IDispatch *lpScreenDisp = m_sessLoader.requestScreen("User","Password","WebView");
             if (lpScreenDisp)
             {
                this->m_screenObj.AttachDispatch(lpScreenDisp);
                if (!this->m_screenObj.Open())
                {
                   AfxMessageBox("open failed");
                   return ;
                }
                …
                //Start programming here.
                //Be sure to close the connection when you are done.
                   this->m_screenObj.Close();
             }
          }
          CATCH_ALL(e)
          {
             char buff[1024];
             e->GetErrorMessage(buff,1024,NULL);
             AfxMessageBox(buff);
             this->m_screenObj.Close();
          }
          END_CATCH_ALL
       }
    }
    CATCH_ALL(e)
    {
       AfxMessageBox("Error:  Failed to create 'SessionLoader.SessionLoader' object");
       return;
    }
    END_CATCH_ALL
 }

requestScreenEx

public IScreenUPG requestScreenEx(java.lang.String User,
                                  java.lang.String Password,
                                  java.lang.String ScreenData,
                                  int internalUse)
                           throws SessionException
Gets a Screen object, instantiated with the specified user and password, as well as the configuration specified by the XML Data. See XML Parameters for examples and a complete list of Parameters for each connection type.

Parameters:
User. -  
Password. -  
XMLData - A valid WebView defined in HAS.
reserved. - Set to zero.
Throws:
SessionException - Returned if the requested session could not be loaded.
Examples:
Java:

 SessionLoader sl = new SessionLoader();
 
 //The following is only applicable if you are using ID Manager to obtain IDs.
 sl.setResourceManagerOptions(75,25,"");
 //End of ID Manager-specific code.
 
 ScreenUts m_ScreenObj;
 String XMLData = "Specific to terminal Type";
 try {
     m_ScreenObj = (ScreenUts) sl.requestScreenEx("User","Password","XMLData","Reserved");
 }
 catch (SessionException se){
   System.out.println(se.getMessage());
 }
 if(m_screenObj.Open())
   System.out.println("Connected!");
 else
   System.out.println("Host Connection Failed!");
 m_screenObj.Closed();

ASP (VBScript):

 dim loaderObj 
 
 'The following is only applicable if you are using ID Manager to obtain IDs.
 loaderObj.setResourceManagerOptions(75,25,"")
 'End of ID Manager-specific code.
 
 set XMLData = "Specific to terminal Type"
 On error resume next
 set loaderObj = Server.CreateObject("SessionLoader.SessionLoader") 
 set Session("screenObj") = loaderObj.requestScreenEx("User","Password","XMLData","Reserved") 
 If Session("screenObj").Open = True Then 
     Session("Session("sreenObj")").waitHostQuiet 1000,5000
     Response.write (Session("screenObj").gettext) 
     Session("screenObj").Close 
 else 
     Response.write("Open of WebView failed!") 
 End if

C++:

 …
 void Screen::start(void)
 {
    TRY
    {
       //The following is only applicable if you are using ID Manager to obtain IDs.
       m_SessLoader.setResourceManagerOptions(75,25,"");
       //End of ID Manager-specific code.
 
       CLSID clsid;
       HRESULT hr = ::CLSIDFromProgID(L"SessionLoader.SessionLoader", &clsid);
       if (FAILED(hr))
       {
          AfxThrowOleException(hr);
       }
       if (m_sessLoader.CreateDispatch(clsid))
       {
          TRY
          {
			   char XMLData[256];
			   memset(XMLData,0,sizeof(XMLData));
			   memcpy(XMLData,"Specific to terminal Type");
             IDispatch *lpScreenDisp = m_sessLoader.requestScreenEx("User","Password","XMLData","Reserved");
             if (lpScreenDisp)
             {
                this->m_screenObj.AttachDispatch(lpScreenDisp);
                if (!this->m_screenObj.Open())
                {
                   AfxMessageBox("open failed");
                   return ;
                }
                …
                //Start programming here.
                //Be sure to close the connection when you are done.
                   this->m_screenObj.Close();
             }
          }
          CATCH_ALL(e)
          {
             char buff[1024];
             e->GetErrorMessage(buff,1024,NULL);
             AfxMessageBox(buff);
             this->m_screenObj.Close();
          }
          END_CATCH_ALL
       }
    }
    CATCH_ALL(e)
    {
       AfxMessageBox("Error:  Failed to create 'SessionLoader.SessionLoader' object");
       return;
    }
    END_CATCH_ALL
 }

setConfigurationIPAddress

public void setConfigurationIPAddress(java.lang.String Server)
Sets a Server Address to be used by all subsequent calls to requestScreen()
Parameters:
Server - either a DNS name or IP address followed by a colon and then the TCP port of the server (e.g. “Mermit:8015”). All subsequent configuration requests will be sent to this server address and TCP port. The getConfigurationIPAddress method will return either the default MCS server (“localhost:80”) or the last server address/hostname set by the developer. Server (HAS).
See Also:

setResourceManagerOptions

public void setResourceManagerOptions(int ir,
                                      int ri,
                                      java.lang.String rsa)
Specifies the initial number of terminal or session IDs that are allocated to the application from e-Vantage ID Manager, as well as the increment in which additional IDs will be obtained when all allocated IDs are already in use. If you do not use this method to specify these values, the default values of 5 (initial reserve) and 5 (reserve increment) are used.

In addition to allowing you to request a larger number of IDs, you can also use this method to limit the number of IDs in use. For example, if your application requires only one ID, you can use this method to specify an initial reserve of 1, with a reserve increment of 1.

This method is only applicable when using e-Vantage ID Manager with e-Vantage HAS Management; if e-Vantage ID Manager is not installed, this method is ignored.
Note: e-Vantage ID Manager is only used for connecting to UTS or T 27 host sessions, which require a unique ID; 3270, 5250, and VT host sessions do not require a unique ID.
Parameters:
ir - The initial number of IDs that the application will request from e-Vantage ID Manager.
ri - The increment in which additional IDs will be requested from e-Vantage ID Manager when all allocated IDs are already in use.
rsa - The ID Manager Address, if a remote ID Manager is used.
Examples:
Java:

sl.setResourceManagerOptions(75,25,"");

ASP (VBScript):

loaderObj.setResourceManagerOptions(75,25,"")

C++:

m_sessLoader.setResourceManagerOptions(75,25,"");

setTerminalType

public void setTerminalType(int Type)
Sets a default Screen Type to be used for retrieving Screen Objects. when using requestScreen(). If this method is not called all Screen Type will be checked
Parameters:
Type - A valid Screen Type. Valid Types: T27 = 100 UTS = 105 3270 = 110 5250 = 115 VT = 120 ALC = 125

Shutdown

public void Shutdown()
Ensures that all IDs defined with a Lease Timeout (from e-Vantage ID Manager) are properly retained by the SDK for future use, once your application no longer requires them. (IDs that do not have a Lease Timeout defined are freed automatically when the application closes.) You must call this method when your application terminates if you are using leased IDs.

This method is only applicable when using e-Vantage ID Manager with e-Vantage HAS, and only for IDs with a Lease Timeout defined. If e-Vantage ID Manager is not installed, or the ID does not have a Lease Timeout defined, this method is ignored.
Important! You must call this method when your application terminates, if the IDs have a Lease Timeout value defined. Failure to do so may cause these IDs to become unusable by your application or by e-Vantage ID Manager.
Examples:
Java:

sl.Shutdown();

ASP (VBScript):

loaderObj.Shutdown

C++:

m_sessLoader.Shutdown();