use of jakarta.annotation.Priority in project resteasy by resteasy.
the class PriorityComparator method getPriority.
private int getPriority(final Class<?> type) {
final Class<?> clazz = type.isSynthetic() ? type.getSuperclass() : type;
final Priority priority = clazz.getAnnotation(Priority.class);
if (priority != null) {
return priority.value();
}
final Class<?> superType = clazz.getSuperclass();
return superType == null ? Priorities.USER : getPriority(superType);
}
use of jakarta.annotation.Priority in project resteasy by resteasy.
the class PriorityServiceLoader method findClasses.
@SuppressWarnings("unchecked")
private static <S> Holder<S>[] findClasses(final Class<S> type, final ClassLoader cl, final Function<Class<? extends S>, S> constructor) throws IOException {
final Set<Holder<S>> holders = new TreeSet<>();
final Enumeration<URL> resources = cl.getResources(PREFIX + type.getName());
while (resources.hasMoreElements()) {
final URL url = resources.nextElement();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
int commentIdx = line.indexOf('#');
if (commentIdx >= 0) {
line = line.substring(0, commentIdx);
}
line = line.trim();
if (line.equals(""))
continue;
try {
final Class<S> found = (Class<S>) cl.loadClass(line);
final Priority priority = found.getAnnotation(Priority.class);
int p = Integer.MAX_VALUE;
if (priority != null) {
p = priority.value();
}
holders.add(new Holder<>(found, p, constructor));
} catch (ClassNotFoundException e) {
LogMessages.LOGGER.failedToLoad(e, line);
}
}
} catch (IOException e) {
LogMessages.LOGGER.failedToLoad(e, url.toString());
}
}
return (Holder<S>[]) holders.toArray(new Holder[0]);
}
use of jakarta.annotation.Priority in project resteasy by resteasy.
the class Utils method getPriority.
public static int getPriority(Class<?> component) {
component = component.isSynthetic() ? component.getSuperclass() : component;
Priority priority = component.getAnnotation(Priority.class);
if (priority == null)
return Priorities.USER;
return priority.value();
}
use of jakarta.annotation.Priority in project core by weld.
the class ObserverMethodConfiguratorImpl method read.
@Override
public ObserverMethodConfigurator<T> read(Method method) {
checkArgumentNotNull(method);
Set<Parameter> eventParameters = Configurators.getAnnotatedParameters(method, Observes.class, ObservesAsync.class);
checkEventParams(eventParameters, method);
Parameter eventParameter = eventParameters.iterator().next();
Observes observesAnnotation = eventParameter.getAnnotation(Observes.class);
if (observesAnnotation != null) {
reception(observesAnnotation.notifyObserver());
transactionPhase(observesAnnotation.during());
} else {
reception(eventParameter.getAnnotation(ObservesAsync.class).notifyObserver());
}
Priority priority = method.getAnnotation(Priority.class);
if (priority != null) {
priority(priority.value());
}
beanClass(eventParameter.getDeclaringExecutable().getDeclaringClass());
observedType(eventParameter.getType());
qualifiers(Configurators.getQualifiers(eventParameter));
return this;
}
use of jakarta.annotation.Priority in project core by weld.
the class ObserverMethodConfiguratorImpl method read.
@Override
public ObserverMethodConfigurator<T> read(AnnotatedMethod<?> method) {
checkArgumentNotNull(method);
Set<AnnotatedParameter<?>> eventParameters = method.getParameters().stream().filter((p) -> p.isAnnotationPresent(Observes.class) || p.isAnnotationPresent(ObservesAsync.class)).collect(Collectors.toSet());
checkEventParams(eventParameters, method.getJavaMember());
AnnotatedParameter<?> eventParameter = eventParameters.iterator().next();
Observes observesAnnotation = eventParameter.getAnnotation(Observes.class);
if (observesAnnotation != null) {
reception(observesAnnotation.notifyObserver());
transactionPhase(observesAnnotation.during());
async(false);
} else {
reception(eventParameter.getAnnotation(ObservesAsync.class).notifyObserver());
async(true);
}
Priority priority = method.getAnnotation(Priority.class);
if (priority != null) {
priority(priority.value());
}
beanClass(eventParameter.getDeclaringCallable().getDeclaringType().getJavaClass());
observedType(eventParameter.getBaseType());
qualifiers(Configurators.getQualifiers(eventParameter));
return this;
}
Aggregations