Java Code Examples for org.springframework.core.annotation.Order.value()

The following are Jave code examples for showing how to use value() of the org.springframework.core.annotation.Order class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: lams   File: BeanFactoryAspectInstanceFactory.java   Source Code and License Vote up 5 votes
/**
 * Determine the order for this factory's target aspect, either
 * an instance-specific order expressed through implementing the
 * {@link org.springframework.core.Ordered} interface (only
 * checked for singleton beans), or an order expressed through the
 * {@link org.springframework.core.annotation.Order} annotation
 * at the class level.
 * @see org.springframework.core.Ordered
 * @see org.springframework.core.annotation.Order
 */
@Override
public int getOrder() {
	Class<?> type = this.beanFactory.getType(this.name);
	if (type != null) {
		if (Ordered.class.isAssignableFrom(type) && this.beanFactory.isSingleton(this.name)) {
			return ((Ordered) this.beanFactory.getBean(this.name)).getOrder();
		}
		Order order = AnnotationUtils.findAnnotation(type, Order.class);
		if (order != null) {
			return order.value();
		}
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example 2
Project: lams   File: SimpleMetadataAwareAspectInstanceFactory.java   Source Code and License Vote up 5 votes
/**
 * Determine a fallback order for the case that the aspect instance
 * does not express an instance-specific order through implementing
 * the {@link org.springframework.core.Ordered} interface.
 * <p>The default implementation simply returns {@code Ordered.LOWEST_PRECEDENCE}.
 * @param aspectClass the aspect class
 */
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	Order order = AnnotationUtils.findAnnotation(aspectClass, Order.class);
	if (order != null) {
		return order.value();
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example 3
Project: lams   File: SingletonMetadataAwareAspectInstanceFactory.java   Source Code and License Vote up 5 votes
/**
 * Check whether the aspect class carries an
 * {@link org.springframework.core.annotation.Order} annotation,
 * falling back to {@code Ordered.LOWEST_PRECEDENCE}.
 * @see org.springframework.core.annotation.Order
 */
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	Order order = AnnotationUtils.findAnnotation(aspectClass, Order.class);
	if (order != null) {
		return order.value();
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example 4
Project: spring-boot-cdi-instance-example   File: CustomAutowireCandidateResolver.java   Source Code and License Vote up 5 votes
private Object returnPrimaryOrHighestPriorityBean(List<Bean> beans) {

			long highestPriority = Integer.MIN_VALUE;
			Object highestPrioBean = null;

			for (Bean bean : beans) {

				if (bean.isPrimary()) {
					return bean.getInstance();
				}

				// TODO figure out to retrieve order from BeanDefinition /
				// BeanDeclaration

				Object instance = bean.getInstance();
				Order order = instance.getClass().getAnnotation(Order.class);
				if (order != null) {
					if (order.value() > highestPriority) {
						highestPriority = order.value();
						highestPrioBean = instance;
					}
				}

				Priority priority = instance.getClass().getAnnotation(Priority.class);
				if (priority != null) {
					if (priority.value() > highestPriority) {
						highestPriority = priority.value();
						highestPrioBean = instance;
					}
				}
			}

			return highestPrioBean;
		}
 
Example 5
Project: class-guard   File: BeanFactoryAspectInstanceFactory.java   Source Code and License Vote up 5 votes
/**
 * Determine the order for this factory's target aspect, either
 * an instance-specific order expressed through implementing the
 * {@link org.springframework.core.Ordered} interface (only
 * checked for singleton beans), or an order expressed through the
 * {@link org.springframework.core.annotation.Order} annotation
 * at the class level.
 * @see org.springframework.core.Ordered
 * @see org.springframework.core.annotation.Order
 */
public int getOrder() {
	Class<?> type = this.beanFactory.getType(this.name);
	if (type != null) {
		if (Ordered.class.isAssignableFrom(type) && this.beanFactory.isSingleton(this.name)) {
			return ((Ordered) this.beanFactory.getBean(this.name)).getOrder();
		}
		Order order = AnnotationUtils.findAnnotation(type, Order.class);
		if (order != null) {
			return order.value();
		}
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example 6
Project: class-guard   File: SimpleMetadataAwareAspectInstanceFactory.java   Source Code and License Vote up 5 votes
/**
 * Determine a fallback order for the case that the aspect instance
 * does not express an instance-specific order through implementing
 * the {@link org.springframework.core.Ordered} interface.
 * <p>The default implementation simply returns {@code Ordered.LOWEST_PRECEDENCE}.
 * @param aspectClass the aspect class
 */
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	Order order = AnnotationUtils.findAnnotation(aspectClass, Order.class);
	if (order != null) {
		return order.value();
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example 7
Project: class-guard   File: SingletonMetadataAwareAspectInstanceFactory.java   Source Code and License Vote up 5 votes
/**
 * Check whether the aspect class carries an
 * {@link org.springframework.core.annotation.Order} annotation,
 * falling back to {@code Ordered.LOWEST_PRECEDENCE}.
 * @see org.springframework.core.annotation.Order
 */
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	Order order = AnnotationUtils.findAnnotation(aspectClass, Order.class);
	if (order != null) {
		return order.value();
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example 8
Project: lams   File: ControllerAdviceBean.java   Source Code and License Vote up 4 votes
private static int initOrderFromBeanType(Class<?> beanType) {
	Order ann = AnnotationUtils.findAnnotation(beanType, Order.class);
	return (ann != null ? ann.value() : Ordered.LOWEST_PRECEDENCE);
}
 
Example 9
Project: spring4-understanding   File: ApplicationListenerMethodAdapter.java   Source Code and License Vote up 4 votes
@Override
public int getOrder() {
	Order order = getMethodAnnotation(Order.class);
	return (order != null ? order.value() : 0);
}
 
Example 10
Project: spring   File: ApplicationListenerMethodAdapter.java   Source Code and License Vote up 4 votes
@Override
public int getOrder() {
	Order order = getMethodAnnotation(Order.class);
	return (order != null ? order.value() : 0);
}
 
Example 11
Project: cuba   File: UiEventListenerMethodAdapter.java   Source Code and License Vote up 4 votes
protected int resolveOrder(Method method) {
    Order ann = AnnotatedElementUtils.findMergedAnnotation(method, Order.class);
    return (ann != null ? ann.value() : 0);
}
 
Example 12
Project: class-guard   File: ControllerAdviceBean.java   Source Code and License Vote up 4 votes
private static int initOrderFromBeanType(Class<?> beanType) {
	Order annot = AnnotationUtils.findAnnotation(beanType, Order.class);
	return (annot != null) ? annot.value() : Ordered.LOWEST_PRECEDENCE;
}