org.springframework.core.annotation.OrderUtils Java Examples

The following examples show how to use org.springframework.core.annotation.OrderUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenericJpaRepositoryFactory.java    From spring-data-jpa-extra with Apache License 2.0 6 votes vote down vote up
private List<EntityAssembler> getEntityAssemblers(Class<?> clazz) {
    if (assemblers.isEmpty()) {
        Collection<EntityAssembler> abs = ContextHolder.getBeansOfType(EntityAssembler.class);
        if (abs.isEmpty()) {
            return Collections.emptyList();
        } else {
            for (EntityAssembler ab : abs) {
                Class p0 = getGenericParameter0(ab.getClass());
                List<EntityAssembler> ass = this.assemblers.computeIfAbsent(p0, k -> new ArrayList<>());
                ass.add(ab);
            }
            for (List<EntityAssembler> ess : assemblers.values()) {
                ess.sort((o1, o2) -> OrderUtils.getOrder(o2.getClass()) - OrderUtils.getOrder(o1.getClass()));
            }
        }
    }
    return assemblers.get(clazz);
}
 
Example #2
Source File: BeanFactoryAspectInstanceFactory.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
		}
		return OrderUtils.getOrder(type, Ordered.LOWEST_PRECEDENCE);
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example #3
Source File: BeanFactoryAspectInstanceFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
		}
		return OrderUtils.getOrder(type, Ordered.LOWEST_PRECEDENCE);
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example #4
Source File: SqlViewCustomizerMap.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
private static int getOrder(@NonNull final SqlViewCustomizer viewCustomizer)
{
	if (viewCustomizer instanceof Ordered)
	{
		return ((Ordered)viewCustomizer).getOrder();
	}
	else
	{
		return OrderUtils.getOrder(viewCustomizer.getClass(), Ordered.LOWEST_PRECEDENCE);
	}
}
 
Example #5
Source File: BeanFactoryAspectInstanceFactory.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * 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();
		}
		return OrderUtils.getOrder(type, Ordered.LOWEST_PRECEDENCE);
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example #6
Source File: ControllerAdviceBean.java    From java-technology-stack with MIT License 5 votes vote down vote up
private static int initOrderFromBeanType(@Nullable Class<?> beanType) {
	Integer order = null;
	if (beanType != null) {
		order = OrderUtils.getOrder(beanType);
	}
	return (order != null ? order : Ordered.LOWEST_PRECEDENCE);
}
 
Example #7
Source File: BeanFactoryAspectInstanceFactory.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * 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();
		}
		return OrderUtils.getOrder(type, Ordered.LOWEST_PRECEDENCE);
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example #8
Source File: ControllerAdviceBean.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private static int initOrderFromBeanType(@Nullable Class<?> beanType) {
	Integer order = null;
	if (beanType != null) {
		order = OrderUtils.getOrder(beanType);
	}
	return (order != null ? order : Ordered.LOWEST_PRECEDENCE);
}
 
Example #9
Source File: SingletonMetadataAwareAspectInstanceFactory.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	return OrderUtils.getOrder(aspectClass, Ordered.LOWEST_PRECEDENCE);
}
 
Example #10
Source File: SimpleMetadataAwareAspectInstanceFactory.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	return OrderUtils.getOrder(aspectClass, Ordered.LOWEST_PRECEDENCE);
}
 
Example #11
Source File: ControllerAdviceBean.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private static int initOrderFromBeanType(Class<?> beanType) {
	return OrderUtils.getOrder(beanType, Ordered.LOWEST_PRECEDENCE);
}
 
Example #12
Source File: SimpleMetadataAwareAspectInstanceFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	return OrderUtils.getOrder(aspectClass, Ordered.LOWEST_PRECEDENCE);
}
 
Example #13
Source File: SingletonMetadataAwareAspectInstanceFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	return OrderUtils.getOrder(aspectClass, Ordered.LOWEST_PRECEDENCE);
}
 
Example #14
Source File: SingletonMetadataAwareAspectInstanceFactory.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	return OrderUtils.getOrder(aspectClass, Ordered.LOWEST_PRECEDENCE);
}
 
Example #15
Source File: SimpleMetadataAwareAspectInstanceFactory.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	return OrderUtils.getOrder(aspectClass, Ordered.LOWEST_PRECEDENCE);
}
 
Example #16
Source File: SingletonMetadataAwareAspectInstanceFactory.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	return OrderUtils.getOrder(aspectClass, Ordered.LOWEST_PRECEDENCE);
}
 
Example #17
Source File: ControllerAdviceBean.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private static int initOrderFromBeanType(Class<?> beanType) {
	return OrderUtils.getOrder(beanType, Ordered.LOWEST_PRECEDENCE);
}
 
Example #18
Source File: SimpleMetadataAwareAspectInstanceFactory.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected int getOrderForAspectClass(Class<?> aspectClass) {
	return OrderUtils.getOrder(aspectClass, Ordered.LOWEST_PRECEDENCE);
}