A REST API module generates the artifacts related to a particular API such Events, Provider interfaces and so on.
Follow these steps to build Rhino support for each REST API.
Step 1: Create an API module
The first step is to use the SDK tool sdkadm to create an API module from a module-pack. The REST RA framework provides a set of module-packs for creating API modules.
Use the
sdkadm list-modules command to list available module-packs.
|
1 |
Create an API module Create an API module with the sdkadm create-module
|
---|---|
2 |
The name of the top-level module The top level module is group module, that encapsulates sub-modules for each of the constituent parts for your API. The suggested value is the directory name passed in the sdkadm top level module
The following questions prompt you for the names to use for each sub-module and for properties related to your new API. Don’t accept the default values; you need to provide suitable values for each of these questions. |
3 |
The name of the resource adaptor type module The resource adaptor type module generates a Resource Adaptor Type component that can be deployed in Rhino TAS - Telecom Application Server and is used by a REST resource adaptor. resource adaptor type module
|
4 |
The name of the API plugin module The API plugin module generates a library component that is used by a REST resource adaptor to implement your REST API. The API plugin library gets deployed in Rhino TAS - Telecom Application Server. plugin module
|
5 |
The name of the API module The API module contains the OpenAPI specification and an associated configuration file that defines your API. The other API modules depend on this API module. API module
|
6 |
The name of the sbbpart module The sbb-part module generates a Java library that contains an abstract superclass you can use to write an SBB Part component that can be used in a Rhino TAS - Telecom Application Server based application. The generated class includes all the event handlers and slee annotations you need for your own sbb-part. SBBPart module
|
7 |
The short name of the API, and the root java package for all generated java API properties
|
The create-module
command will then create your new REST API module.
Renaming ivy modules and updating dependencies.
Renaming symbolic property references in source files.
Checking "deps.properties" for missing values.
Done. New module(s) should now be available at: ~/work/unified-rest-ra-sdk/pingpong-rest-api
>
The generated modules for the PingPong API is:
~/work/unified-rest-ra-sdk$ ls -la pingpong-rest-api/
total 32
drwxr-xr-x 10 fwuser staff 320 2 Nov 16:24 .
drwxr-xr-x@ 16 fwuser staff 512 2 Nov 16:23 ..
-rw-r--r-- 1 fwuser staff 54 2 Nov 16:24 .sdk.root
-rw-r--r-- 1 fwuser staff 432 2 Nov 16:24 build.xml
-rw-r--r-- 1 fwuser staff 1604 2 Nov 16:24 ivy.xml
-rw-r--r-- 1 fwuser staff 183 2 Nov 16:24 module.properties
drwxr-xr-x 7 fwuser staff 224 2 Nov 16:24 pingpong-api
drwxr-xr-x 7 fwuser staff 224 2 Nov 16:24 pingpong-api-server
drwxr-xr-x 8 fwuser staff 256 2 Nov 16:24 pingpong-api-server-plugin
drwxr-xr-x 7 fwuser staff 224 2 Nov 16:24 pingpong-api-server-sbbpart
-
This sub-module holds the API specification and a properties file. The other sub-modules have an ivy dependency on this module.
-
Generates a RA type that includes events, provider interfaces and so on for an RA type that can be deployed in Rhino
-
Generates a library component the Unified REST RA uses to load and drive the API
-
Generates a Jar that contains a super-class that developers can extend to create an sbb-part for their application. The generated super-class includes all event handlers and slee-annotations required to deploy such an sbb-part in Rhino.
Learn about SBB Parts. Learn about JAIN SLEE (JSR 240). |
Step 2: Configure the API module
You only need to edit the following files in the API submodule.
-
the API specification file
-
the API properties file
All the required Java components and deployment descriptors are generated by the REST RA framework toolchain.
The generated REST API module contain a default (trivial) api.yaml that is a placeholder for your REST API specification. The generated properties file contains suitable default property values. For example the PingPong (server) API properties are:
# properties related to the package structure of the API
api.shortname = pingpong
# optional - a required license function
api.requiredLicenseFunction =
# packages
api.invokerPackage = com.exampleco.openapi.pingpong
api.apiPackage = com.exampleco.openapi.pingpong.api
api.modelPackage = com.exampleco.openapi.pingpong.model
api.implPackage = com.exampleco.openapi.pingpong.impl
# artifact names
api.server.ratype.artifactname = pingpong-api-server
api.server.plugin.artifactname = pingpong-api-server-plugin
api.server.sbbpart.artifactname = pingpong-api-server-sbbpart
Copy your own openapi specification into the API Module and customizes the API properties to specify information like package names, or artifact names and versions. The finished API Module can be checked into source control.
Optional License for your API
One of the properties in the Using this property is optional. The default value means the API does not require a license. |
Review the PingPong API openapi specification document. |
Step 3: Build the API module
When the API Module builds, it generates code using OpenAPI SLEE Generator and publishes artifacts including:
-
A SLEE RA Type deployable unit, which defines the application (SBB) interface to the REST RA.
-
A REST RA Plugin deployable unit, which provides the implementation used by the REST RA when sending or receiving HTTP messages.
-
A superclass jar for SBB Parts that may be used as a starting point for developing services.
At this point the developer can depend on these generated artifacts in their project, and write service code using the classes and methods from the generated RA Types.
To actually deploy the service and interact with real REST API clients or servers, the developer must also create their REST RA using a REST RA Module.
The developer repeats steps one, two and three as they update their API specification. |