Search in sources :

Example 6 with Priority

use of javax.annotation.Priority in project jsr354-ri-bp by JavaMoney.

the class OSGIServiceComparator method getPriority.

/**
 * Checks the given type optionally annotated with a @Priority. If present the annotation's value is evaluated.
 * If no such annotation is present, a default priority {@code 1} is returned.
 *
 * @param type the type, not {@code null}.
 * @return a priority, by default 1.
 */
public static int getPriority(Class<?> type) {
    int prio = 1;
    Priority priority = type.getAnnotation(Priority.class);
    if (priority != null) {
        prio = priority.value();
    }
    return prio;
}
Also used : Priority(javax.annotation.Priority)

Example 7 with Priority

use of javax.annotation.Priority in project jsr354-ri-bp by JavaMoney.

the class PriorityAwareServiceProvider method compareServices.

public static int compareServices(Object o1, Object o2) {
    int prio1 = 0;
    int prio2 = 0;
    Priority prio1Annot = o1.getClass().getAnnotation(Priority.class);
    if (prio1Annot != null) {
        prio1 = prio1Annot.value();
    }
    Priority prio2Annot = o2.getClass().getAnnotation(Priority.class);
    if (prio2Annot != null) {
        prio2 = prio2Annot.value();
    }
    if (prio1 < prio2) {
        return 1;
    }
    if (prio2 < prio1) {
        return -1;
    }
    return o2.getClass().getSimpleName().compareTo(o1.getClass().getSimpleName());
}
Also used : Priority(javax.annotation.Priority)

Example 8 with Priority

use of javax.annotation.Priority in project redkale by redkale.

the class Filter method compareTo.

@Override
public int compareTo(Object o) {
    if (!(o instanceof Filter))
        return 1;
    Priority p1 = this.getClass().getAnnotation(Priority.class);
    Priority p2 = o.getClass().getAnnotation(Priority.class);
    return (p2 == null ? 0 : p2.value()) - (p1 == null ? 0 : p1.value());
}
Also used : Priority(javax.annotation.Priority)

Example 9 with Priority

use of javax.annotation.Priority in project jsr354-ri by JavaMoney.

the class PriorityServiceComparator method getPriority.

/**
 * Checks the given type optionally annotated with a @Priority. If present the annotation's value is evaluated.
 * If no such annotation is present, a default priority {@code 1} is returned.
 *
 * @param type the type, not {@code null}.
 * @return a priority, by default 1.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static int getPriority(Class type) {
    int prio = 1;
    Priority priority = (Priority) type.getAnnotation(Priority.class);
    if (priority != null) {
        prio = priority.value();
    }
    return prio;
}
Also used : Priority(javax.annotation.Priority)

Example 10 with Priority

use of javax.annotation.Priority in project jsr354-ri by JavaMoney.

the class OSGIServiceComparator method getPriority.

/**
 * Checks the given type optionally annotated with a @Priority. If present the annotation's value is evaluated.
 * If no such annotation is present, a default priority {@code 1} is returned.
 *
 * @param type the type, not {@code null}.
 * @return a priority, by default 1.
 */
public static int getPriority(Class<?> type) {
    int prio = 1;
    Priority priority = type.getAnnotation(Priority.class);
    if (priority != null) {
        prio = priority.value();
    }
    return prio;
}
Also used : Priority(javax.annotation.Priority)

Aggregations

Priority (javax.annotation.Priority)14 Annotation (java.lang.annotation.Annotation)2 Parameter (java.lang.reflect.Parameter)2 Observes (javax.enterprise.event.Observes)2 AnnotatedParameter (javax.enterprise.inject.spi.AnnotatedParameter)2 MandatoryDocumentInitializer (com.xpn.xwiki.doc.MandatoryDocumentInitializer)1 Method (java.lang.reflect.Method)1 Type (java.lang.reflect.Type)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 ObserverException (javax.enterprise.event.ObserverException)1 ObservesAsync (javax.enterprise.event.ObservesAsync)1 Reception (javax.enterprise.event.Reception)1 TransactionPhase (javax.enterprise.event.TransactionPhase)1 AnnotatedMethod (javax.enterprise.inject.spi.AnnotatedMethod)1 EventContext (javax.enterprise.inject.spi.EventContext)1 Extension (javax.enterprise.inject.spi.Extension)1 InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1