EGL interfaces

EGL interfaces let you access an EGL service, a Web service (which may be written in EGL), or Java™ code.

The interface is an EGL part that includes a set of function descriptions. As shown in the following example, each function description has an ending semicolon (;) and includes only a function name, parameters, and return type:
   Interface HelloWorld type JavaObject
     {javaName = "HelloWorld", 
      packageName = "com.ibm.examples.helloWorld"}
     
     function sayHello(name String)
					  	returns (String);
   end
Instead of using an Interface part directly in your code, you create a variable that is based on that part. At run time, the variable refers to one of these:
You can use interfaces in these ways:
For services
You can use an interface of type BasicInterface to define the purpose of a service not yet written or to provide access to an existing service--
  • You can use interfaces to help you architect your organization's services.

    You can create an interface that describes the functionality that you want to have coded in an EGL service. After the interface is complete, you or others can code the service, which is said to implement the interface. The primary meaning is that the service contains every function described in the interface. The interface provides a kind of contract that the service must fulfill.

    This use of interfaces provides the following benefits:
    • Helps people in your organization to think clearly about what operations are needed in a service before service development begins
    • Allows developers to finish client applications while the service code is under development, as is possible when the client code interacts with variables that are based on Interface parts, not Service parts

    A service can implement multiple interfaces, and multiple services can implement the same interface.

  • Interfaces give developers access to your organization's services while shielding them from knowledge of the implementation.

    The runtime effect of declaring a variable of an Interface part is the same as the effect of declaring a variable of the related Service part; but use of the interface lets you avoid disclosing the logic inside the service. Keeping the logic away from others might be appropriate for competitive reasons (you may want to hide the source code from developers outside of your organization) or to reduce complexity (you may want developers -- whether in or out of your organization -- to focus on the functionality that the service provides rather than on the details of the implementation).

  • Interfaces let you access a Web service regardless of the language or location of the service implementation.

    Access of a Web service created outside of your organization requires that you have the service-specific Web Service Description Language (WSDL) definition, which details how to access the service.

    You use the WSDL definition as input to the EGL WSDL wizard, which creates a service-specific Interface part that will be the basis of a variable in your code.

When you are accessing a service by way of an interface, the interface must be bound to the location where the service implementation resides. This binding includes details on the protocol used to access the implementation.

The usual situation is that you specify the binding information in a variable that is declared in a special type of EGL library called a service binding library, which is described in Library part of type ServiceBindingLibrary. Another possibility is that an interface receives the binding in an assignment statement, as is possible when the interface or service on the right side of the assignment statement is declared in a services binding library or when that interface or service received a binding in a previous assignment statement. A third possibility is that an interface that is acting as a function parameter receives the binding by receiving an argument that already has a binding.

For Java code

You can use an EGL interface of type JavaObject to access some or all of the functionality that is available in a Java interface or class. In this usage, an EGL interface provides a view of the Java code.

The following benefits come from using EGL interfaces in this way:
  • Coding and maintenance of the EGL logic is easier because the complexity of the Java code is largely hidden in the underlying Java implementation
  • The number of programmers who can access Java code from EGL is maximized

An efficient strategy for your organization is to ask a developer who has expertise in both EGL and Java to create Interface parts for use by other EGL developers. For a list of interface parts that are provided for general use, see Interfaces of type JavaObject.

EGL provides a large set of interfaces to allow Web developers to access JSF user-interface controls at run time; for example, to change the color of a text box in response to a user's input. For an overview of that capability, see JSF component tree.

When you interact with the JSF component tree, you can ignore the fact that (as of EGL version 6.0.1), EGL interface technology does not allow you to instantiate a Java object from within your EGL code. For details on the issue, see Instantiation and EGL interfaces of type JavaObject.

EGL interfaces supplement two other Java-specific capabilities in EGL:
Java access functions
The Java access functions are EGL system functions that allow your generated Java code to access native Java objects and classes; specifically, to access the public methods, constructors, and fields of the native code.
EGL Java wrapper
An EGL Java wrapper is a set of Java classes that are generated for you and that act as an interface between the following executables:
  • A servlet or a hand-written Java program, on the one hand
  • A EGL-generated program or EJB session bean, on the other

Related concepts
Instantiation and EGL interfaces of type JavaObject
JSF component tree
Library part of type ServiceBindingLibrary

Related tasks
Creating an EGL Interface part
Creating an EGL Service part
Creating an Interface part from a Service part

Related reference
Best practices for services and related interfaces in EGL
EGL library ServiceLib
Interface part in EGL source format

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.