All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.demoiselle.jee.configuration.ConfigurationInterceptor Maven / Gradle / Ivy

Go to download

Demoiselle Configuration habilita os projetos a usarem configurações em arquivos .properties, .xml ou variáveis de ambiente.

There is a newer version: 3.0.4
Show newest version
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();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy