ExternalType parts map EGL to external language elements.
The ExternalType part can have any of three stereotypes:
- JavaObject, for accessing Java™ code;
for details, see External type for Java code
- JavaScriptObject, for accessing JavaScript™ code;
for details, see External type for JavaScript code
- HostProgram, for accessing host programs on IBM® i;
for details, see Accessing IBM i programs as Web services
An ExternalType part has the following characteristics:
- The EGL mapping that the ExternalType provides is generalized
to include fields and constructors.
- ExternalType parts cannot directly access code. You must provide
prototypes so that EGL can perform type checking.
- An ExternalType definition reserves no storage. You must declare
a variable that is based on the part.
- Many concepts used with the ExternalType part come from object-oriented
languages, such as Java and C#.
- ExternalType parts can be used to create arrays of function pointers
for event handling. EGL text reports typically use ExternalType parts
for this purpose. See EGL text reports.
- ExternalType functions:
- Create a variable that is based on the ExternalType and append
the variable name to the name of the method using dot syntax externalTypeVariable.methodName().
- If the function is marked static, invoke
the function with the name of the ExternalType part and dot syntax
(typeName.methodName()).
- You can map an ExternalType part to a Java class
that implements the java.io.Serializable interface, but the ExternalType
part must extend the predefined Serializable ExternalType.
An ExternalType part consists of the following components:
- Variable declarations
- These provide access to public variables in the external language
element.
- Function prototypes
- These represent method invocations or function calls in the external
type.
- Constructor prototypes
- These define the syntax for constructing a variable of this external
type using an EGL new statement.
For more information, see the
Introduction to ExternalType parts.
Syntax

- typeName
- The name that you assign to the part type. Use this name in the
statement that creates a variable of this type.
- externalType
- The extends clause refers to another
ExternalType definition that contains function and or variable prototypes
that this type inherits.
- stereotype
- One of the following kinds: JavaObject, JavaScriptObject, or HostProgram.
- variableDeclaration
- This prototype declaration represents a variable in the external
type. No storage is assigned, so you cannot use initializers with
these declarations. Use EGL syntax and base the variable on EGL primitive
types that correspond to Java types.
For more information, see EGL primitives and Java.
- static
- This keyword indicates that the specified function or variable
exists apart from a variable based on the external type, and that
you can reference it using the syntax typeName.functionName().
- functionPrototype
- This prototype declaration represents a function in the external
type. Do not include any actual code in this declaration, but specify
parameters and return values by using EGL syntax. Primitive types
that you pass as parameters must include the in modifier.
- parameters
- These are the parameters that EGL needs to create a variable of
this type using the new statement. Use typeName for
the part name in the new statement; see new operator
Example
The following example
shows an ExternalType part with function prototypes:
ExternalType TaxModule type JavaObject
// Define public variables
adjustedGrossIncome FLOAT;
companyName STRING;
// Define function prototype
function calculateTax (adjIncome FLOAT in) returns (FLOAT);
// Define constructor prototype
constructor (taxAuthority STRING);
end
// Invoke the above constructor in new expression
myTaxModule TaxModule = new TaxModule("NC") {
adjustedGrossIncome = 60135.00,
companyName = "CompanyB" };
myTax = myTaxModule.calculateTax (myIncome);
Compatibility
Table 1. Compatibility
considerations for ExternalType partsPlatform |
Issue |
COBOL generation |
ExternalType parts are not supported. |