Interface RESTHandler


  • public interface RESTHandler

    This SPI allows other bundles to register themselves as listeners for a certain URL sub-root, which is defined by specifying an OSGi property with key = RESTHandler.PROPERTY_REST_HANDLER_ROOT and value = URL.

    The registered URL will be attached to the core REST Handler framework context root, which is /ibm/api.

    As an example: if a bundle has an OSGi component implementing the RESTHandler interface and with a RESTHandler.PROPERTY_REST_HANDLER_ROOT=/myCustomRoot, then that OSGi component will be called everytime a new HTTPs request comes into:

    https://<hostname>:<https_port>/ibm/api/myCustomRoot

    The feature that controls the REST Handler framework is "restHandler-1.0", but it is protected, therefore it must be enabled by another feature (ie: by the feature that contains the bundle that implements RESTHandler interface).

    • Field Detail

      • PROPERTY_REST_HANDLER_ROOT

        static final java.lang.String PROPERTY_REST_HANDLER_ROOT
        OSGi property used to define the sub-root that this rest handler listens to, starting with a slash.
        • Required property.
        • Multiple instances of this property may be specified in the same handler.
        • Variables may be defined for any segment of these URLs, enclosed by {}.
        See Also:
        Constant Field Values
      • PROPERTY_REST_HANDLER_CONTEXT_ROOT

        static final java.lang.String PROPERTY_REST_HANDLER_CONTEXT_ROOT
        OSGi property used to define the context root that this rest handler contributes to, starting with a slash.
        • Optional property.
        • Multiple instances of this property may be specified in the same handler.
        See Also:
        Constant Field Values
      • PROPERTY_REST_HANDLER_DEFAULT_CONTEXT_ROOT

        static final java.lang.String PROPERTY_REST_HANDLER_DEFAULT_CONTEXT_ROOT
        The value of the default context root.
        See Also:
        Constant Field Values
      • PROPERTY_REST_HANDLER_CUSTOM_SECURITY

        static final java.lang.String PROPERTY_REST_HANDLER_CUSTOM_SECURITY
        OSGi property used to specify whether or not this RESTHandler will implement its own authorization code.
        • Optional property.
        • Possible values are "true" or "false" and default is "false".
        See Also:
        Constant Field Values
      • PROPERTY_REST_HANDLER_CUSTOM_ROUTING

        static final java.lang.String PROPERTY_REST_HANDLER_CUSTOM_ROUTING
        OSGi property used to specify whether or not this RESTHandler will implement its own routing code.
        • Optional property.
        • Possible values are "true" or "false" and default is "false".
        See Also:
        Constant Field Values
      • PROPERTY_REST_HANDLER_CUSTOM_CORS

        static final java.lang.String PROPERTY_REST_HANDLER_CUSTOM_CORS
        OSGi property used to specify whether or not this RESTHandler will implement its own Cross Origin Resource Sharing code.
        • Optional property.
        • Possible values are "true" or "false" and default is "false".
        See Also:
        Constant Field Values
      • PROPERTY_REST_HANDLER_HIDDEN_API

        static final java.lang.String PROPERTY_REST_HANDLER_HIDDEN_API
        OSGi property used to specify whether or not this RESTHandler should be hidden from the top-level ibm/api query of available APIs.
        • Optional property.
        • Possible values are "true" or "false" and default is "false".
        See Also:
        Constant Field Values
    • Method Detail

      • handleRequest

        void handleRequest​(RESTRequest request,
                           RESTResponse response)
                    throws java.io.IOException
        This method gets called for every URL request that came in through the RESTHandlerContainer and matched the registered paths of this handler.
        Parameters:
        request - encapsulates the artifacts for the HTTP request
        response - encapsulates the artifacts for the HTTP response
        Throws:
        java.io.IOException - if an I/O exception occurred.