Logging In and Establishing a Process Session

Use the VWSession class to instantiate and initialize a VWSession object, establishing a Process session. You must have a VWSession object before you can perform any other Process operations.

To instantiate a VWSession object, use the constructor VWSession(user_name, password, router_URL; where user_name and password (authenticated via LDAP) are the credentials for a Process Engine user, and router_URL is the URL of the Web server router used also for Java™ Remote Method Invocation (RMI).

For performance reasons, you should minimize the number of Process sessions you create. Optimally, use a single session for as many operations as feasible (such as, calling a work performer, updating a step, and querying the user inbox).

The following example uses the Session Helper sample class to establish a Process session and then log off the session:

import filenet.vw.api.*;

/**
* This sample class illustrates how to make use of the VWSession object.
*
*/
public class SessionHelper extends Object
{
    // declare variables
    private String      m_userName = null;
    private String      m_password = null;
    private String      m_routerPath = null;
    private Logger      m_logger = null;
    private VWSession   m_vwSession = null;

    /**
     * Constructor - performs initialization
     *
     @param user a string containing the user name
     @param pw a string containing the password
     @param router a string containing the router path
     @param logger a Logger object.
     */
  public SessionHelper(String user, String pw, String router, Logger logger)
  {
      m_userName = user;
      m_password = pw;
      m_routerPath = router;
      m_logger = logger;
  }

    /**
     * Creates a logon session
     *
     @return a VWSession

     */
    public VWSession logon()
    {
        try
        {
            // instead of using the user information that was passed in,
            // we could display a login dialog and allow the user to enter
            // the necessary information.


      // Establish a login session.

      m_vwSession = new VWSession(m_userName, m_password, m_routerPath);
    }
    catch (Exception ex)
    {
        if (m_logger != null)
            m_logger.log(ex);
            else
          ex.printStackTrace();
    }

        return m_vwSession;
    }

    /**
     * Logs off the session
     *
     */
    public void logoff()
    {
        try
        {
      // logoff the session

      if (m_vwSession != null)
          m_vwSession.logoff();
    }
    catch (Exception ex)
    {
        if (m_logger != null)
            m_logger.log(ex);
            else
          ex.printStackTrace();
    }
    finally
    {
        m_vwSession = null;
    }
    }

 }