com.jslsolucoes.auth.ee.extension.AuthCdiExtension Maven / Gradle / Ivy
package com.jslsolucoes.auth.ee.extension;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import javax.enterprise.inject.spi.WithAnnotations;
import javax.ws.rs.Path;
import org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jslsolucoes.auth.ee.Private;
public class AuthCdiExtension implements Extension {
private static final Logger logger = LoggerFactory.getLogger(AuthCdiExtension.class);
public AuthCdiExtension() {
}
public void processAnnotatedType(
@Observes @WithAnnotations(Path.class) ProcessAnnotatedType processAnnotatedType) {
AnnotatedType annotatedType = processAnnotatedType.getAnnotatedType();
logger.debug("Processing type {} for add private annotation", annotatedType);
AnnotatedTypeBuilder builder = new AnnotatedTypeBuilder().readFromType(annotatedType);
for (AnnotatedMethod super T> annotatedMethod : annotatedType.getMethods()) {
if (!annotatedMethod.isAnnotationPresent(Private.class)) {
logger.debug("Adding private annotation to {}",annotatedMethod);
builder.addToMethod(annotatedMethod, new PrivateAnnotationLiteral());
} else {
logger.debug("Private annotation already defined", annotatedType);
}
}
processAnnotatedType.setAnnotatedType(builder.create());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy