Commit 0a281eaa2e89e8c185be951ca8a1a6879f78f923

Authored by Cleverson Sacramento
1 parent 58085403
Exists in master

Considerando as duas formas de definir a prioridade

impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AnnotatedMethodProcessor.java
... ... @@ -41,6 +41,7 @@ import java.lang.reflect.InvocationTargetException;
41 41 import javax.enterprise.inject.spi.AnnotatedMethod;
42 42 import javax.enterprise.inject.spi.BeanManager;
43 43  
  44 +import br.gov.frameworkdemoiselle.annotation.Priority;
44 45 import br.gov.frameworkdemoiselle.exception.ApplicationException;
45 46 import br.gov.frameworkdemoiselle.message.SeverityType;
46 47  
... ... @@ -61,7 +62,16 @@ public abstract class AnnotatedMethodProcessor<T> extends AbstractProcessor<T> i
61 62 return (AnnotatedMethod<T>) getAnnotatedCallable();
62 63 }
63 64  
64   - abstract protected Integer getPriority(AnnotatedMethod<T> annotatedMethod);
  65 + protected Integer getPriority(AnnotatedMethod<T> annotatedMethod) {
  66 + Integer priority = Priority.MIN_PRIORITY;
  67 +
  68 + Priority annotation = annotatedMethod.getAnnotation(Priority.class);
  69 + if (annotation != null) {
  70 + priority = annotation.value();
  71 + }
  72 +
  73 + return priority;
  74 + }
65 75  
66 76 public int compareTo(final AnnotatedMethodProcessor<T> other) {
67 77 Integer orderThis = getPriority(getAnnotatedMethod());
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/ShutdownProcessor.java
... ... @@ -39,6 +39,7 @@ package br.gov.frameworkdemoiselle.internal.processor;
39 39 import javax.enterprise.inject.spi.AnnotatedMethod;
40 40 import javax.enterprise.inject.spi.BeanManager;
41 41  
  42 +import br.gov.frameworkdemoiselle.annotation.Priority;
42 43 import br.gov.frameworkdemoiselle.annotation.Shutdown;
43 44  
44 45 /**
... ... @@ -54,7 +55,13 @@ public class ShutdownProcessor&lt;T&gt; extends AnnotatedMethodProcessor&lt;T&gt; {
54 55  
55 56 @SuppressWarnings("deprecation")
56 57 protected Integer getPriority(AnnotatedMethod<T> annotatedMethod) {
57   - Shutdown annotation = annotatedMethod.getAnnotation(Shutdown.class);
58   - return annotation.priority();
  58 + Integer priority = super.getPriority(annotatedMethod);
  59 +
  60 + if (!annotatedMethod.isAnnotationPresent(Priority.class)) {
  61 + Shutdown annotation = annotatedMethod.getAnnotation(Shutdown.class);
  62 + priority = annotation.priority();
  63 + }
  64 +
  65 + return priority;
59 66 }
60 67 }
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/StartupProcessor.java
... ... @@ -39,6 +39,7 @@ package br.gov.frameworkdemoiselle.internal.processor;
39 39 import javax.enterprise.inject.spi.AnnotatedMethod;
40 40 import javax.enterprise.inject.spi.BeanManager;
41 41  
  42 +import br.gov.frameworkdemoiselle.annotation.Priority;
42 43 import br.gov.frameworkdemoiselle.annotation.Startup;
43 44  
44 45 /**
... ... @@ -54,7 +55,13 @@ public class StartupProcessor&lt;T&gt; extends AnnotatedMethodProcessor&lt;T&gt; {
54 55  
55 56 @SuppressWarnings("deprecation")
56 57 protected Integer getPriority(AnnotatedMethod<T> annotatedMethod) {
57   - Startup annotation = annotatedMethod.getAnnotation(Startup.class);
58   - return annotation.priority();
  58 + Integer priority = super.getPriority(annotatedMethod);
  59 +
  60 + if (!annotatedMethod.isAnnotationPresent(Priority.class)) {
  61 + Startup annotation = annotatedMethod.getAnnotation(Startup.class);
  62 + priority = annotation.priority();
  63 + }
  64 +
  65 + return priority;
59 66 }
60 67 }
... ...