Implement Gateway and GatewayConfiguration
Gateway and GatewayConfiguration are the foundation of every agent implementation. They define how the agent connects to your gateway and how it reads configuration values at startup.
Prerequisites
- Java development environment configured
- Agent SDK dependency added to your project
- Familiarity with Java interfaces and class extension
Key concepts
| Term | Description |
|---|---|
Gateway | Base class your implementation must extend. Represents the gateway connection. |
GatewayConfiguration | Base class for holding all configuration values needed to connect to your gateway. |
GatewayConfigurationFactory | Interface that parses configuration values from the docker-compose.yml file into your GatewayConfiguration subclass. |
GatewayFactory | Interface that creates instances of your Gateway subclass. |
Create a project
Create a project and implement the interfaces declared here. This library includes the data model that the API Control Plane uses, as well as interfaces for all the handlers for the environment capabilities your gateway supports, such as component discovery and API metrics.
Extend Gateway and GatewayConfiguration
-
Create a subclass of
Gatewayfor your gateway type. -
Create a subclass of
GatewayConfiguration. Add all fields required to establish connectivity to your gateway, for example, a hostname, username, and password. -
Implement
GatewayConfigurationFactoryusing yourGatewayConfigurationsubclass. TheparseConfigurationmethod receives properties from thedocker-compose.ymlfile at agent startup and populates your configuration fields. -
Implement
GatewayFactoryusing yourGatewaysubclass.
How configuration values flow
When you register a gateway in API Control Plane, the values you enter during registration are written into an automatically generated docker-compose.yml file. For example, if your GatewayConfiguration has a password field, a user entering examplePass during registration results in gateway.password=examplePass in the compose file.
At agent startup, GatewayConfigurationFactory::parseConfiguration reads those properties and populates your GatewayConfiguration instance.
Add every field your agent needs to connect to your gateway to your GatewayConfiguration subclass before you define the Platform Type properties in API Control Plane.