-
Notifications
You must be signed in to change notification settings - Fork 5
Core components
This part of the documentation covers all the pivotal technologies on which is build the OAP.
The chapter covers OAP’s Inversion of Control (IoC) container.
An OAP IoC container manages one or more services. To declare service the oap-module
config is used, it can be .yaml
or .conf
format.
Let's see how to declare a simple service.
Create the next java class:
package io.xenoss.examples;
public class DBService {
private String dbUrl;
private String username;
private String password;
public DBService(String dbUrl, String username, String password) {
this.dbUrl = dbUrl;
this.username = username;
this.password = password;
}
...
}
Then we need to create oap-module
config with the definition of the service above:
For oap-module.yaml
name: repositories
services:
dbService:
implementation: io.xenoss.examples.DBService
name: db_service
parameters:
dbUrl: jdbc:mysql://localhost:3306/testDb
username: admin
password: admin123
For oap-module.conf
name = repositories
services {
dbService {
implementation = io.xenoss.examples.DBService
name = db_service
parameters {
dbUrl = jdbc:mysql://localhost:3306/testDb
username = admin
password = admin123
}
}
The above service definition has two mandatory attributes implementation
and parameters
. The parameters
are the named parameters from the constructor and order is not important. Whereas the name
attribute is optional and is used to refer to this service as a dependency in the other services (more details in the next section).