diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AnnotatedMethodProcessor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AnnotatedMethodProcessor.java index 2117359..788588e 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AnnotatedMethodProcessor.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AnnotatedMethodProcessor.java @@ -41,6 +41,7 @@ import java.lang.reflect.InvocationTargetException; import javax.enterprise.inject.spi.AnnotatedMethod; import javax.enterprise.inject.spi.BeanManager; +import br.gov.frameworkdemoiselle.annotation.Priority; import br.gov.frameworkdemoiselle.exception.ApplicationException; import br.gov.frameworkdemoiselle.message.SeverityType; @@ -61,7 +62,16 @@ public abstract class AnnotatedMethodProcessor extends AbstractProcessor i return (AnnotatedMethod) getAnnotatedCallable(); } - abstract protected Integer getPriority(AnnotatedMethod annotatedMethod); + protected Integer getPriority(AnnotatedMethod annotatedMethod) { + Integer priority = Priority.MIN_PRIORITY; + + Priority annotation = annotatedMethod.getAnnotation(Priority.class); + if (annotation != null) { + priority = annotation.value(); + } + + return priority; + } public int compareTo(final AnnotatedMethodProcessor other) { Integer orderThis = getPriority(getAnnotatedMethod()); diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/ShutdownProcessor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/ShutdownProcessor.java index 6a1500a..b40713c 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/ShutdownProcessor.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/ShutdownProcessor.java @@ -39,6 +39,7 @@ package br.gov.frameworkdemoiselle.internal.processor; import javax.enterprise.inject.spi.AnnotatedMethod; import javax.enterprise.inject.spi.BeanManager; +import br.gov.frameworkdemoiselle.annotation.Priority; import br.gov.frameworkdemoiselle.annotation.Shutdown; /** @@ -54,7 +55,13 @@ public class ShutdownProcessor extends AnnotatedMethodProcessor { @SuppressWarnings("deprecation") protected Integer getPriority(AnnotatedMethod annotatedMethod) { - Shutdown annotation = annotatedMethod.getAnnotation(Shutdown.class); - return annotation.priority(); + Integer priority = super.getPriority(annotatedMethod); + + if (!annotatedMethod.isAnnotationPresent(Priority.class)) { + Shutdown annotation = annotatedMethod.getAnnotation(Shutdown.class); + priority = annotation.priority(); + } + + return priority; } } diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/StartupProcessor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/StartupProcessor.java index 823bbc7..96cc555 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/StartupProcessor.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/StartupProcessor.java @@ -39,6 +39,7 @@ package br.gov.frameworkdemoiselle.internal.processor; import javax.enterprise.inject.spi.AnnotatedMethod; import javax.enterprise.inject.spi.BeanManager; +import br.gov.frameworkdemoiselle.annotation.Priority; import br.gov.frameworkdemoiselle.annotation.Startup; /** @@ -54,7 +55,13 @@ public class StartupProcessor extends AnnotatedMethodProcessor { @SuppressWarnings("deprecation") protected Integer getPriority(AnnotatedMethod annotatedMethod) { - Startup annotation = annotatedMethod.getAnnotation(Startup.class); - return annotation.priority(); + Integer priority = super.getPriority(annotatedMethod); + + if (!annotatedMethod.isAnnotationPresent(Priority.class)) { + Startup annotation = annotatedMethod.getAnnotation(Startup.class); + priority = annotation.priority(); + } + + return priority; } } -- libgit2 0.21.2