Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EDT:ServiceInvocationGenerationAndRuntime

General Information

Currently service invocations are only supported in JavaScript generation. Conceptually an invocation is a call statement targeting either a service or a proxy function. For service invocation a proxy function is defined as a function with an @EGLService or @REST annotation.

Plugin Details

org.eclipse.edt.mof.eglx.services:

provides the mof model support. It contains the a factory that returns Java representation of the IR parts used for the Call Statement and Function part used to drive the generator plugin org.eclipse.edt.gen.javascript.templates.eglx.services.

  • During compilation call statements and function parts are evaluated.
    • If the call statement targets an REST service proxy function (it has an REST or EGLService annotation) the IR created is an service call statment IR.
    • If the function has an REST or EGLService annotation the IR created is a service Function.

org.eclipse.edt.gen.javascript.templates.eglx.services:

Generates the code needed for service invocations. There are 2 entry points in the generator:

  • The function part: 2 are Java methods are generated.
    • The first is the named method this is generated so if other code does a simple function call there is a generated target method. The body of this method is a function invocation to the 2nd function referred to as the proxy function.
    • The proxy function contains the code to make the service invocation. The code for an EGLService invocation is slightly different than the code for a REST invocation. To handle this we actually generate the annotation on the function.
      • The generated code calls a runtime function so generate the runtime function name.
      • Generated to handle the @Resource on the function.
      • Generate the request configuration ie url, format, and encoding
      • Generate the response format
      • Generate annotation specific code
        • For REST generate the resource parameter
        • For EGLService generate the service name and function name
      • create an array of in argument
      • create an array of signatures for the in arguments
      • create an array that represents the parameter names
      • create an array that represents the signature and type of the returned arguments
      • create a callback delegate
      • create an error delegate
  • The call statement. This has 2 path depending if the call statement target is a Service or if it's a proxy function.
    • Target - proxy function: This code creates a function invocation statement. The target of the invocation is the generated proxy javascript function and it passes the arguments specified in the call plus the variable specified in the using expression.
    • Target - service. The code generated for an EGLService proxy function is generated in line where the call statement is defined. This is accomplished by creating an EGLService annotation, populating it and then generating it. If no using clause is specified an HttpProxy is created. So the invocation is a dedicated service.
org.eclipse.edt.runtime.javascript:

contains the JavaScript runtime support for service invocations.

  • eglx.rest.RestRuntime contains the runtime code that is directly called by the generated code. There is a function invoked for EGLService's and a function for REST. There is also a function that consolidates the generated using clause or @Resource expression, request configuration, and response configuration object into a single IHttp type object used to invoke the service.
  • eglx.rest.RestRuntime calls eglx.services.ServiceRT passing the service invocation. This runtime performs operations to consolidate the request into an XMLHttpRequest object. It calls the service passing a response handler function to call when the async response is returned
  • The response handler function checks the return for error then decodes the json, xml, or none into the specified returned arguments
  • and finally either calls the callback delegate or the error callback delegate. The http object is passed to the delegate functions as the last parameter. This gives the handler the complete encoded request and raw response. Including headers.

Testing

The Test suite is located in the IBM CVS.

  • EGL services - org.eclipse.edt.tests.services/egl.rest
  • 3rd party REST services - org.eclipse.edt.tests.services/thirdparty.rest/
  • 3rd party SOAP servies - org.eclipse.edt.tests.services/thirdparty.soap. We technically don't support SOAP services, but a SOAP service is an HTTPRequest using a POST where the data is in a specific XML format. This project is a model of how to invoke SOAP services using REST POST with XML.

Back to the top