Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aesteve/vertx-pojo-config

Simple Vert.x extension to map your JsonObject configuration to a standard Java bean
https://github.com/aesteve/vertx-pojo-config

configuration json mapping validation vertx

Last synced: 5 days ago
JSON representation

Simple Vert.x extension to map your JsonObject configuration to a standard Java bean

Awesome Lists containing this project

README

        

## Vertx-pojo-config

A very simple tool to map Vert.x's json configuration onto a typed configuration Java bean.

It uses Jackson's object mapper behind the hood.

### How to use it ?

Simply make your `Verticle` extend `TypedConfigurationVerticle` and declare the class of your configuration :

```java
class SimpleConf {

private String host;
private int port;

public String getHost() {
return host;
}

public void setHost(String host) {
this.host = host;
}

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}

}
```

```java
class SimpleConfigurationVerticle extends TypedConfigurationVerticle {

@Override
public Class getConfigClass() {
return SimpleConf.class;
}


}

```

Then, from within your verticle just call `getConfig()` to get the `SimpleConf` instance. The `config()` method will still be returning the `JsonObject` configuration.

### JSR 303 (Bean validation)

If an implementation of the JSR 303 (hibernate-validator for instance) within your classpath, then your configuration will be checked against a validator.
This means you can annotate your configuration with `@Email`, `@NotNull`, and stuff like that.