Managing AppServer Connections

The ServiceAdapter of the SmartComponent Library uses an instance of a class implementing the IAppServerServiceManager to manage the AppServer connection.

Consultingwerk provides two default implementations of this Interface. The SessionServiceManager is the default IAppServerServiceManager implementation and does not connect to an AppServer at all and does always return the ABL SESSION handle so that the ServiceAdapter will call into the ServiceInterface using the local session.

The AppServerServiceManager serves as a wrapper to adecomm/as-utils.w – which is Progress’ default method of managing AppServer connections (also used in the ADM2 framework). as-utils.w manages AppServer connections based on a file called appsrvtt.d which is managed using the ProTools utility “Service Parameter Maintenance”.

Service Parameter Maintenance


Sample appsrvtt.d file contents
"Default" "localhost" "" yes no "" "smartcomponents" "A" "" ""
"Local" "localhost" "" no no "" "smartcomponents" "A" "" ""
"oe115demo" "" "" yes no "" "" "A" "" ""
"sports2000partition" "localhost" "" no no "" "Sports2000" "A" "" ""


Both the Service Parameter Maintenance and as-utils.w use the concept of AppServer partitions to be able to manage multiple connections to different AppServers (for different parts of the application).


In the SmartComponent Library we are using a customized version of adecomm/as-utils.w that throws errors to the caller and does not display error messages. In order to use this, please ensure that src/adecomm/as-utils.w is found in the propath using the relative name adecomm/as-utils.w.

Initializing the IAppServerServiceManager


The default SessionServiceManager is always loaded when the framework is started (by the static constructor of the FrameworkSettings class. If you want to use the AppServerServiceManager you need to assign the following when the application is started (start.p):

Assigning the AppServerServiceManager property of the FrameworkSettings class
FrameworkSettings:AppServerServiceManager = NEW AppServerServiceManager () .

Setting up the default AppServer Partition to use


The AppServerServiceManager allows to set a default partition which is used whenever the calls to the  ServiceAdapter are made with no partition name provided (empty string or ?).


/* Define a default partition for AppServer calls */
CAST (FrameworkSettings:AppServerServiceManager,
      AppServerServiceManager):DefaultPartition = „MyDefaultPartition" .

Implementing custom IAppServerServiceManager classes


When the SmartComponent Library is used together with an existing framework and that framework already has a method of connecting to the AppServer, it may be desirable to share that connection. In this case, customers can implement custom variants of the IAppServerServiceManager and register it as described above.


It’s up to a developers requirements if or if not the partition parameter to the methods is actually used or not. In most applications it is enough to use only a single AppServer partition at all.

Sample code for connecting to an AppServer


The following code from the reference client startup procedure (Consultingwerk\Windows\Framework\Reference\start.p) demos how to initialize the AppServer connection.


/* Use AppServerServiceManager when no DB is connected or -param contains AppServerConnect*/
IF NUM-DBS = 0 OR ListHelper:CanDo (SESSION:PARAM, "AppServerConnect":U) THEN DO:
    FrameworkSettings:AppServerServiceManager = NEW AppServerServiceManager () .
    /* Default Partition from -param? */
    oParamDictionary = ListHelper:AlternatingListToDictionary (SESSION:PARAM, ",":U, "=":U) .
    IF oParamDictionary:ContainsKey ("defaultPartition":U) THEN
        cDefaultPartition = oParamDictionary:GetValue ("defaultPartition":U) . 
    /* Default Partition from .applicationsettings file */
    ELSE IF VALID-OBJECT (oConfigurationProvider) THEN
        cDefaultPartition = oConfigurationProvider:GetValue ("defaultPartition":U, cDefaultPartition) .
        cDefaultPartition = cDefaultPartition .
    /* Defining the default partition for AppServer calls */
    CAST (FrameworkSettings:AppServerServiceManager,
          AppServerServiceManager):DefaultPartition = cDefaultPartition .
    /* Attempt to connect to the AppServer during startup, quit when failed */
        FrameworkSettings:AppServerServiceManager:ConnectService (cDefaultPartition) .
        CATCH err AS Progress.Lang.Error:
            Consultingwerk.Util.ErrorHelper:ShowErrorMessage (err) .
            QUIT .
        END CATCH .
    END .
    /* When connecting to the AppServer, we need the context serializer */
    FrameworkSettings:ServiceContainer:AddService (Progress.Lang.Class:GetClass ("Consultingwerk.Framework.Server.SessionContextSerializer":U),
                                                   NEW Consultingwerk.Framework.Server.SessionContextSerializer ()) .         


Using the reference code, the client connects to the AppServer when no database is connected or the –param parameter contains (comma delimited) the value AppServer connect. –param may also define the default partition, so a sample –param value may be:

-param AppServerConnect,DefaultPartition=sportspartition