com.ibm.mfp.adapter.api

Interface AdaptersAPI



  • public interface AdaptersAPI
    API to retrieve information about the current adapter and send REST requests to other adapters. This API is accessible using the Jax-RS Context annotation, for example by defining a member varaible:
     
     Context
     private AdaptersAPI adaptersApi;
     }
     
     
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      org.apache.http.client.methods.HttpUriRequest createJavascriptAdapterRequest(java.lang.String adapter, java.lang.String procedure, java.lang.Object[] args)
      Helper method to create request to a JS adapter (via REST)
      org.apache.http.HttpResponse executeAdapterRequest(org.apache.http.client.methods.HttpUriRequest request)
      Sends HTTP request to another REST or Javascript adapter.
      java.lang.String getAdapterName()
      Returns the name of the current adapter
      java.lang.Object getJaxRsApplication(java.lang.Class applicationClass)
      Returns the Jax-RS application class of the current adapter, casted to the given class.
      JSONObject getResponseAsJSON(org.apache.http.HttpResponse response)
      Reads the response to JSON.
    • Method Detail

      • executeAdapterRequest

        org.apache.http.HttpResponse executeAdapterRequest(org.apache.http.client.methods.HttpUriRequest request)
                                                           throws java.io.IOException
        Sends HTTP request to another REST or Javascript adapter.
        Parameters:
        request - - Apache HttpUriRequest to be sent to the adapter. The URI of this request must not be absolute. It must be relative to the "/adapters" endpoint. For example: "/myadapter/getStories"
        Returns:
        The response (standard HttpResponse)
        Throws:
        java.io.IOException
        MFPServerOAuthException
      • getResponseAsJSON

        JSONObject getResponseAsJSON(org.apache.http.HttpResponse response)
                                     throws java.io.IOException
        Reads the response to JSON. It assumes that the response contains a JSON content.
        Parameters:
        response - - The response to be read
        Returns:
        A JSON object with the response content
        Throws:
        java.io.IOException
      • createJavascriptAdapterRequest

        org.apache.http.client.methods.HttpUriRequest createJavascriptAdapterRequest(java.lang.String adapter,
                                                                                   java.lang.String procedure,
                                                                                   java.lang.Object[] args)
        Helper method to create request to a JS adapter (via REST)
        Parameters:
        adapter - - The adapter name
        procedure - - The procedure name
        args - - Arguments to be passed (Optional)
        Returns:
        the request for javascript adapter invocation
      • getAdapterName

        java.lang.String getAdapterName()
        Returns the name of the current adapter
        Returns:
        name of the adapter
      • getJaxRsApplication

        java.lang.Object getJaxRsApplication(java.lang.Class applicationClass)
        Returns the Jax-RS application class of the current adapter, casted to the given class. The applicationClass argument must not be null, and must also be assignable from the adapter's application class.
        Returns:
        application instance
        Throws:
        java.lang.IllegalArgumentException - if applicationClass is null or not applicable


© Copyright IBM Corp. 2006, 2015. All Rights Reserved.