org.demoiselle.jee.configuration.ConfigurationInterceptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of demoiselle-configuration Show documentation
Show all versions of demoiselle-configuration Show documentation
Demoiselle Configuration habilita os projetos a usarem configurações em arquivos .properties, .xml ou variáveis de ambiente.
package org.demoiselle.jee.configuration;
import javax.annotation.Priority;
import javax.enterprise.context.Dependent;
import javax.enterprise.inject.spi.CDI;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
import org.demoiselle.jee.configuration.annotation.Configuration;
/**
*
* Intercepts annotated class with {@link Configuration} and delegates processing to the class {@link ConfigurationLoader}
*
*/
@Dependent
@Configuration
@Interceptor
@Priority(Interceptor.Priority.APPLICATION)
public class ConfigurationInterceptor {
@AroundInvoke
public Object constructConfiguration(final InvocationContext ic) throws Exception {
final ConfigurationLoader configurationLoader = CDI.current().select(ConfigurationLoader.class).get();
final Class> baseClass = ic.getMethod().getDeclaringClass();
configurationLoader.load(ic.getTarget(), baseClass, Boolean.TRUE);
return ic.proceed();
}
}