Skip to content

Dev: Creating new REST endpoints for access Windup graph data

Ondrej Zizka edited this page Feb 27, 2017 · 1 revision

Rest end point in Web Support Addon

Process

  1. Create an interface in web-support/api
    • This should extend the FurnaceRESTGraphAPI
    • NOTE: This interface provides several pieces of data to each REST endpoint implementation

1b. (optional) Create an required DTOs in the web-support/api module as well. NOTE: It is generally a good idea to annotate the class with @JsonIgnoreProperties({"handler", "delegate"}) in order to prevent jackson from inadvertently serializing proxy related fields.

  1. Create an implementation of this interface in web-support/impl

    • This should extend AbstractGraphResource as that provides a base set of functionality
  2. Add a reference to your new service to RestApplicationFurnace in the services war

    • Inject the service. For example:

        @Inject @FromFurnace
        private DependenciesReportResource dependenciesReportResource;
      
    • Add a reference to it to the "getSingletons()" method

  3. That's it! Your service should now be available to Windup at /services/rest-furnace/

Known Limitations

There is one limitation for return types of Rest End point method:

  • It requires to be known to windup-web-services, so use only Java Types like java.lang.Object, Collections in the API interface. Do not expose Windup Types otherwise it could end up with java.lang.TypeNotPresentException even a Type is dependency in provided scope.

  • DTO types in web-support/api need to be annotated with @JsonIgnoreProperties({"handler", "delegate"}), otherwise Jackson will serialize proxy related fields. Serializing proxy related fields can result in either duplicated data or crashes due to cycles in the data.