Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Introduction

The Interface Generator is a command-line tool that can be used to generate an interface for the public members of a class. Public members are methods, properties and events with the PUBLIC-keyword. Also included in the generated interface are the public members of base-classes, temp-tables and datasets (DEFINE-statement or include-file if available) as well as the Using-statements.

Requirements

The Interface Generator is implemented using the scl-gen-interface batch script. This batch script is located in the Consultingwerk/Studio/bin folder of the SmartComponent Library and should be added to the Windows PATH.

The Interface Generator is further leveraging Apache ANT and PCT. We expect that an ANT installation with PCT.jar in the lib folder is accessible using the Windows PATH as well.

The Interface Generator needs to make certain assumptions about the development environment. The generator can only be used on the command line from within in a sub folder of a Progress Developer Studio (PDSOE) project. The generator will search the directory tree upwards from the current directory and will fail if no .propath utility (default PDSOE configuration) is found. The .propath file is required to gather information about the Progress Developer Studio project structure.

The Interface Generator is partly implemented in ABL - so a Progress runtime must be located. When no DLC environment variable is set, the generator will seek for a supported Progress version in the Windows registry.

Using the Interface Generator

The tool should be invoked as an ANT task or a batch script (similar to scl-sng).

Arguments:

  • Class Name

  • Interface Name (with or without Package)

  • Annotation Name (optional)

When the Class name provided is a short class name (no package name provided), the current directory is assumed for the package.

When the Interface name is passed without a package, the package of the class is used

When an annotation name is passed (e.g., Interface), only public members that are annotated with that annotation are generated to the Interface

Script name: scl-gen-interface

Batch file should be in Consultingwerk\Studio\Bin so that we do not need to add additional folders to the PATH

An example of the class that generates an interface for it:

Code Block
BLOCK-LEVEL ON ERROR UNDO, THROW.

USING Progress.Lang.*.

CLASS Demo.InterfaceGenerator.AnnotatedClass:

  @InterfaceAnnotation.
  METHOD PUBLIC VOID Hello (pcName AS CHARACTER):

       	MESSAGE "Hello":U pcName
            VIEW-AS ALERT-BOX.

  END METHOD.

  METHOD PUBLIC VOID Bye (pcName AS CHARACTER):

        MESSAGE "Bye,":U pcName
            VIEW-AS ALERT-BOX.

  END METHOD.

  METHOD PRIVATE VOID HelloWorld ():

Example with given annotation

In Proenv enter:

Code Block
scl-gen-interface Demo.InterfaceGenerator.AnnotatedClass Demo.InterfaceGenerator.IGeneratedInterface InterfaceAnnotation

This generates:

Code Block
USING Progress.Lang.* FROM PROPATH .

INTERFACE Demo.InterfaceGenerator.IGeneratedInterface:  
  
    METHOD PUBLIC VOID Hello (pcName AS CHARACTER).

END INTERFACE.

Example without annotation

In Proenv enter:

Code Block
scl-gen-interface Demo.InterfaceGenerator.AnnotatedClass Demo.InterfaceGenerator.IGeneratedInterfaceIgnoreAnnotation

This generates:

Code Block
USING Progress.Lang.* FROM PROPATH .

INTERFACE Demo.InterfaceGenerator.IGeneratedInterfaceIgnoreAnnotation:  

    METHOD PUBLIC VOID Hello (pcName AS CHARACTER).

    METHOD PUBLIC VOID Bye (pcName AS CHARACTER).

END INTERFACE.

The private method is ignored, it would also be ignored if it had an annotation.