com.h3c.sdn.adm.rsdoc

## Class SelfRegisteringRSDocProvider

- java.lang.Object
- - com.h3c.sdn.adm.rsdoc.SelfRegisteringRSDocProvider

- All Implemented Interfaces:
    RSDocProvider

      public abstract class SelfRegisteringRSDocProvider
      extends Object
      implements RSDocProvider

  Self-registering implementation of the `RSDocProvider`, which extracts the required Swagger Resource Listings and API Declaration JSON documents from the enclosing JAR file.

  By convention, `resource.json` will be used for resource listing and the rest of the `*.json` files will be used as API declarations. Base names of the files will be used as the API name.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SelfRegisteringRSDocProvider(String name, String path, ClassLoader loader)` Creates a new documentation provider.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `bindRSDocRegistry(RSDocRegistry s)` Hook for self-registering when RSDocRegistry service becomes available.
    `InputStream` | `declaration(String resource)` Gets the REST API documentation for the specified service name.
    `String` | `name()` Gets the REST API provider name.
    `InputStream` | `resources()` Gets the root document for the REST API services offered by this provider.
    `protected void` | `stop()` Unregisters self when deactivated.
    `protected void` | `unbindRSDocRegistry(RSDocRegistry s)` Hook for withdrawing RSDocRegistry service.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SelfRegisteringRSDocProvider

          protected SelfRegisteringRSDocProvider(String name,
                                      String path,
                                      ClassLoader loader)

      Creates a new documentation provider. This provider will scan the specified path for the various Swagger artifacts and use them as the source of data.
      Parameters:
        `name` - name of the REST API documentation provider
        `path` - path to the Swagger Resource Listing and API Declaration JSON resources
        `loader` - class loader to be used for locating resources

  - ### Method Detail

    - #### bindRSDocRegistry

          protected void bindRSDocRegistry(RSDocRegistry s)

      Hook for self-registering when RSDocRegistry service becomes available.
      Parameters:
        `s` - newly advertised registry service

    - #### unbindRSDocRegistry

          protected void unbindRSDocRegistry(RSDocRegistry s)

      Hook for withdrawing RSDocRegistry service.
      Parameters:
        `s` - registry service being revoked

    - #### stop

          @Deactivate
          protected void stop()

      Unregisters self when deactivated.

    - #### name

          public String name()

      Description copied from interface: `RSDocProvider`
      Gets the REST API provider name.
      Specified by:
        `name` in interface `RSDocProvider`
      Returns:
        name of the provider

    - #### resources

          public InputStream resources()

      Description copied from interface: `RSDocProvider`
      Gets the root document for the REST API services offered by this provider. Contents are expected to conform to the Swagger Resource Listing specification.

      https://github.com/wordnik/swagger-core/wiki/Resource-Listing

      Specified by:
        `resources` in interface `RSDocProvider`
      Returns:
        JSON root document stream

    - #### declaration

          public InputStream declaration(String resource)

      Description copied from interface: `RSDocProvider`
      Gets the REST API documentation for the specified service name. Contents are expected to conform to the Swagger API Declaration specification.

      https://github.com/wordnik/swagger-core/wiki/API-Declaration

      Specified by:
        `declaration` in interface `RSDocProvider`
      Parameters:
        `resource` - REST API resource name
      Returns:
        JSON document stream

Copyright © 2014. All Rights Reserved.