fish.payara.microprofile.config.spi.InjectedPayaraConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of payara-micro Show documentation
Show all versions of payara-micro Show documentation
Micro Distribution of the Payara Project for IBM JDK
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package fish.payara.microprofile.config.spi;
import java.io.Serializable;
import java.util.Optional;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.spi.ConfigSource;
/**
*
* @author Steve Millidge
*/
public class InjectedPayaraConfig implements Config, Serializable {
private transient Config delegate;
private String appName;
public InjectedPayaraConfig(Config delegate, String appName) {
this.delegate = delegate;
this.appName = appName;
}
@Override
public T getValue(String propertyName, Class propertyType) {
ensureDelegate();
return delegate.getValue(propertyName, propertyType);
}
@Override
public Optional getOptionalValue(String propertyName, Class propertyType) {
ensureDelegate();
return delegate.getOptionalValue(propertyName, propertyType);
}
@Override
public Iterable getPropertyNames() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Iterable getConfigSources() {
ensureDelegate();
return delegate.getConfigSources();
}
private void ensureDelegate() {
if (delegate == null) {
delegate = (PayaraConfig) ((ConfigProviderResolverImpl)ConfigProviderResolverImpl.instance()).getNamedConfig(appName);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy