4 Connecting to AIS

This chapter describes the method used by ADF applications to connect to the AIS Server and contains the following topics:

4.1 Creating a Connection to AIS Server

An ADF application's bounded task flow includes handshakeId as one of its four required input parameters. The application data control uses this handshakeId parameter to determine whether the ADF application is running locally on JDeveloper's Integrated WebLogic Server (WLS) or executing inside the JDEADFContainer.

The following example shows the standard code you should add to your data control class to connect to the AIS Server:

Example 4-1 AIS connection code for Address Book Data Control Class

public class AddressBookDC
{
    // Session variables.
    private E1UserSessionBean userBean;
    private LoginEnvironment loginEnv;
    private boolean runningInJDEADFContainer = true;
    
    // Hard coded connection values.
    private static final String AIS_SERVER = "http://host:port";
    private static final String USER_NAME = "username";
    private static final String PASSWORD = "password";
    private static final String ROLE = "role";
    private static final String ENVIRONMENT = "environment";
    private static final String DEVICE = "E1ADFApps";
    
    public AddressBookDC()
    {
        String handshakeId = (String) ADFContext.getCurrent().getPageFlowScope().get("handshakeId");
        if (handshakeId == null || (handshakeId != null && handshakeId.length() == 0))
        {
            runningInJDEADFContainer = false;
            userBean = new E1UserSessionBean(AIS_SERVER, USER_NAME, PASSWORD, ENVIRONMENT, ROLE, DEVICE);
        }
        else
        {
            // Only initialize application About properties when running in the JDEADFContainer.
            E1AdfUtils.intializeAppInstance("/com/oracle/e1/E01012/");
        }
 
        loginEnv = E1AdfUtils.getLoginEnvironment(userBean);
 
        if (loginEnv != null)
        {
            // Specify all AIS capabilities required by data control.
            List<String> reqCapabilities = loginEnv.getRequiredCapabilities();
            reqCapabilities.add("processingOption");
            
            retrievePOValues();
        }
    }
}

When the ADF application is running locally, the handshakeId input parameter will be null. As a result, the ADF application creates a direct connection to the AIS Server using hard coded AIS credentials and the E1UserSessionBean class included in E1UserSession.jar. E1AdfUtils will then use the E1UserSessionBean connection to create a LoginEnvironment object, which will be used in all subsequent service requests to the AIS Server.

Note:

You must initialize the AIS credential constants with values specific to your AIS server when testing on JDeveloper's Integrated WLS. Before deploying the ADF application to an ADF Server, you should remove these hard coded values from the data control class, so connection issues can be identified at runtime.

When an ADF application launches from an EnterpriseOne menu and executes within the JDEADFContainer, a valid handshakeId value is passed to the application's bounded task flow as an input parameter. The data control will then inherit the LoginEnvironment object maintained by the JDEADFContainer, which was created after the user signed into EnterpriseOne and a connection was established between JAS, AIS, and JDEADFContainer.