use of org.apache.deltaspike.core.api.config.Configuration in project component-runtime by Talend.
the class Generator method generatedServerConfiguration.
private static void generatedServerConfiguration(final File generatedDir) throws MalformedURLException {
final File file = new File(generatedDir, "generated_server-configuration.adoc");
try (final PrintStream stream = new PrintStream(new WriteIfDifferentStream(file))) {
stream.println("");
stream.println("NOTE: the configuration is read from system properties, environment variables, ....");
stream.println("");
stream.println("[role=\"table-striped table-hover table-ordered\",options=\"header,autowidth\"]");
stream.println("|====");
stream.println("|Key|Description|Default");
final File api = jarLocation(ComponentServerConfiguration.class);
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
final AnnotationFinder finder = new AnnotationFinder(api.isDirectory() ? new FileArchive(loader, api) : new JarArchive(loader, api.toURI().toURL()));
finder.findAnnotatedClasses(Configuration.class).stream().flatMap(c -> Stream.of(c.getMethods())).map(method -> {
final ConfigProperty configProperty = method.getAnnotation(ConfigProperty.class);
final String name = method.getDeclaringClass().getAnnotation(Configuration.class).prefix() + method.getAnnotation(ConfigProperty.class).name();
return "|" + name + "|" + method.getAnnotation(Documentation.class).value() + "|" + (ConfigProperty.NULL.equalsIgnoreCase(configProperty.defaultValue()) ? "-" : configProperty.defaultValue());
}).sorted().forEach(stream::println);
stream.println("|====");
stream.println();
}
}
use of org.apache.deltaspike.core.api.config.Configuration in project deltaspike by apache.
the class ProxyConfigurationLifecycle method create.
@Override
public Object create(final Bean bean, final CreationalContext creationalContext) {
// TODO: support partialbean binding? can make sense for virtual properties + would integrate with jcache
// we'd need to add @PartialBeanBinding on a bean created from ConfigurationHandler
// detection can just be a loadClass of this API
// for now: waiting for user request for it
final Configuration configuration = api[0].getAnnotation(Configuration.class);
final long cacheFor = configuration.cacheFor();
return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), api, new ConfigurationHandler(cacheFor <= 0 ? -1 : configuration.cacheUnit().toMillis(cacheFor), configuration.prefix()));
}
Aggregations