Example: custom front call (Java)

Overloading the default standard.feInfo("feName") front call.

The Java API allows you to implement custom front calls for overloading existing default front call implementations, such as standard.feInfo("feName").

The Scenario class implements the FrontCallHandler interface providing a no-operation front call handler. To provide a custom implementation, either overload the getFrontCallHandler() method:

@Override
public FrontCallHandler getFrontCallHandler()
{
    return new MyFrontCallHandler(...);
}
Or overload the invoke() method:
@Override
public FrontCallEvent invoke(FrontCall frontCall)

Front call implementation for standard.feInfo("feName")

In this function, it shows how the default standard.feInfo("feName") front call can be overloaded.
  • The FrontCall parameter contains the front call request object for module name, function name, parameters, and expected number of return values. See details of the FrontCall class in the GGCDIR/doc/javadoc/ directory.

  • A front call can remain unprocessed by returning a FrontCallEvent.notProcessed(). In this case, the front call will be provided to the next front call handler. The last front call handler is the default front call handler provided by the GGC.

  • If an error is encountered, the front call chain stops and the error is returned to the DVM. Several errors can be returned like:
    • ggc.FrontCallAnswer.moduleNotFound()
    • ggc.FrontCallAnswer.functionNotFound()
    • ggc.FrontCallAnswer.stackError()
    • ggc.FrontCallAnswer.userError(errorMessge STRING)
  • In case of success, the front call can return values using the FrontCallEvent.Builder class. For example:
    return new
    FrontCallEvent.Builder(frontCall).success().returnValue("hello").returnValue("world").build();    
@Override
public FrontCallEvent invoke(frontCall frontCall)
{
    String moduleName = frontCall.moduleName();
    String functionName = frontCall.functionName();

    /* Ensure module name is "standard" */
    if (!moduleName.equals("standard")) {
        return FrontCallEvent.notProcessed();
    }

    /* Ensure function name is "feinfo" */
    if (!functionName.equals("feinfo")) {
        return FrontCallEvent.notProcessed();
    }

    // At least one parameter is required.
    List parameters = frontCall.getParameters();
    if (parameters.size() == 0) {
        return FrontCallEvent.stackError();
    }

    /* Only process "fename" and return "GGC-Custom" */
    switch (parameters.get(0).getValue()) {
    case "fename":
        return new FrontCallEvent.Builder(frontCall).success().returnValue("GGC-Custom").build();
    default:
        return FrontCallEvent.notProcessed();
    }
}