Configuration class

import io.airlift.configuration.Config;
import io.airlift.configuration.ConfigDescription;
import io.airlift.configuration.ConfigSecuritySensitive;
import io.airlift.units.Duration;
import io.airlift.units.MaxDuration;
import io.airlift.units.MinDuration;
 
import javax.validation.constraints.NotNull;
 
public class ExampleConfig
{
    private String secret;
    private Duration timeout = Duration.succinctDuration(10, TimeUnit.SECONDS);
 
    public String getSecret()
    {
        return secret;
    }
 
    @Config("secret")
    @ConfigDescription("Secret required to access the data source")
    @ConfigSecuritySensitive
    public ExampleConfig setSecret(String secret)
    {
        this.secret = secret;
        return this;
    }
 
    @NotNull
    @MaxDuration("10m")
    @MinDuration("1ms")
    public Duration getTimeout()
    {
        return timeout;
    }
 
    @Config("timeout")
    public ExampleConfig setTimeout(Duration timeout)
    {
        this.timeout = timeout;
        return this;
    }
}

Π­Ρ‚ΠΎΡ‚ класс Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±Ρ‹Ρ‚ΡŒ связан (bound) с ΠΌΠΎΠ΄ΡƒΠ»Π΅ΠΌ Guice:

import com.google.inject.Binder;
import com.google.inject.Module;
 
import static io.airlift.configuration.ConfigBinder.configBinder;
 
public class ExampleModule
        implements Module
{
    public ExampleModule()
    {
    }
 
    @Override
    public void configure(Binder binder)
    {
        configBinder(binder).bindConfig(ExampleConfig.class);
    }
}

ПослС этого ΠΌΠΎΠ΄ΡƒΠ»ΡŒ Π½Π°Π΄ΠΎ Π½Π°Π΄ΠΎ ΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Π² connector factory ΠΏΡ€ΠΈ создании Π½ΠΎΠ²ΠΎΠ³ΠΎ экзСмпляра ΠΊΠΎΠ½Π½Π΅ΠΊΡ‚ΠΎΡ€Π°:

@Override
public Connector create(String connectorName, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(config, "config is null");
    Bootstrap app = new Bootstrap(new ExampleModule());
    Injector injector = app
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(config)
            .initialize();
 
    return injector.getInstance(ExampleConnector.class);
}