Appserver call using classes

Hi All,

I have defined the following class for calling an appserver. In the method "RunOnAppserver" I may call different external procedures which may have different parameters. How do I generalise this method so as to accomodate the different parameters used for different calls.

METHOD public VOID RunOnAppserver(fname AS character):
IF l-connected then
RUN VALUE(fname) ON SERVER h-appservhd1.
END METHOD.
Could someone advise?

Thanks
Joel


The following is the complete class.

class mast.appserver:
DEFINE private VARIABLE h-appservhd1 AS handle NO-UNDO.
DEFINE PUBLIC VARIABLE l-connected AS logical NO-UNDO.
CONSTRUCTOR public appserver():
CREATE SERVER h-appservhd1.
END METHOD.
METHOD private void connect(parameters AS character ):
l-connected = h-appservhd1:connect( parameters ). /*"-S 3090 -H 10.101.0.26 -App asbroker1"*/
END METHOD.
METHOD public VOID RunOnAppserver(fname AS character):
IF l-connected then
RUN VALUE(fname) ON SERVER h-appservhd1.
END METHOD.
DESTRUCTOR PUBLIC appserver():
h-appservhd1:DISCONNECT().
DELETE OBJECT h-appservhd1.
END METHOD.
END class.
 

GregTomkins

Active Member
I am not personally P4GL OO-aware - sadly, my employer is seemingly permanently trapped back in v9 - but my guess is you can only do this using a dynamic call, aka. the CALL object. This is a little bit like reflection in Java. I am curious if any of the v10 cognescenti have a better answer...
 
I am not personally P4GL OO-aware - sadly, my employer is seemingly permanently trapped back in v9 - but my guess is you can only do this using a dynamic call, aka. the CALL object. This is a little bit like reflection in Java. I am curious if any of the v10 cognescenti have a better answer...

Thanks much Greg. Will try this and let you know.
 

tamhas

ProgressTalk.com Sponsor
Dynamic call is not relevant since it is not yet possible to run a class on the AppServer directly. One needs to run a facade procedure that runs the class, if anything.
 

tamhas

ProgressTalk.com Sponsor
I understand that ... I was just responding to the message about dynamic call.

The answer to your original question is probably "you can't do that". But, there are other ways you can accomplish the same thing. Suppose, for example, that you were to put the name of the procedure and the list of arguments in a temp-table. Then, you could have a single facade procedure on the AppServer that accepted this temp-table as the only parameter and parsed it to run the desired procedure. That would still leave you having to have a big CASE statement in the facade procedure, though.

If this were something more unified, e.g., conceptually, if everything were on the same platform you would be calling an overloaded method with a varying number of parameters, then you could create the class with the overloaded methods and run it as a part of start up in the AppServer or even instantiate it in the facade procedure if you didn't mind the overhead, then you could have a fairly simple CASE statement based on the number of parameters and compose a method call from the temp-table.

You could use a delimited string instead of a temp-table, but that has its own standards. The temp-table could even have multiple fields of different types per row to hold parameters in their native form, along with a flag to indicate which was the type of that row. This would avoid having to stringify all the parameters.
 

rstanciu

Member
oops :(

data-type

A CHARACTER expression indicating the data type of the parameter and evaluating to one of the following:
"CHARACTER"
"DATASET-HANDLE"
"DATE"
"DATETIME"
"DATETIME-TZ"
"DECIMAL"
"HANDLE"
"INT64"
"INTEGER"
"LOGICAL"
"LONGCHAR"
"MEMPTR"
"RAW"
"ROWID"
"TABLE-HANDLE"


You can use the DYNAMIC CALL !?!

DEFINE VARIABLE hCall AS HANDLE.
CREATE CALL hCall.
/*invoke hello.p nonpersistently */
hCall:CALL-NAME = "hello.p".
/*sets CALL-TYPE to the default/*
hCall:CALL-TYPE = PROCEDURE-CALL-TYPE.
hCall:NUM-PARAMETERS = 1.
hCall:SET-PARAMETER( 1, "CHARACTER", "INPUT", "HELLO WORLD").
hCall:INVOKE.
/* clean up */
DELETE OBJECT hCall.
 
Top