org.springframework.core.OrderComparator Java Examples

The following examples show how to use org.springframework.core.OrderComparator. 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: AbstractNode.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
@Override
public List<Node> getChildren()
{
    if ( sortedChildren == null )
    {
        final int size = children == null ? 0 : children.size();

        if ( size > 1 )
        {
            List<Node> clone = Lists.newArrayList( children );
            Collections.sort( clone, OrderComparator.INSTANCE );
            sortedChildren = ImmutableList.copyOf( clone );
        }
        else if ( size == 1 )
        {
            sortedChildren = ImmutableList.of( children.get( 0 ) );
        }
        else
        {
            sortedChildren = ImmutableList.of();
        }
    }

    return sortedChildren;
}
 
Example #2
Source File: AbstractAspectJAdvisorFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testMultiplePerTargetAspectsWithOrderAnnotation() throws SecurityException, NoSuchMethodException {
	TestBean target = new TestBean();
	int realAge = 65;
	target.setAge(realAge);

	List<Advisor> advisors = new LinkedList<>();
	PerTargetAspectWithOrderAnnotation10 aspect1 = new PerTargetAspectWithOrderAnnotation10();
	aspect1.count = 100;
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect1, "someBean1")));
	PerTargetAspectWithOrderAnnotation5 aspect2 = new PerTargetAspectWithOrderAnnotation5();
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect2, "someBean2")));
	Collections.sort(advisors, new OrderComparator());

	TestBean itb = (TestBean) createProxy(target, advisors, TestBean.class);
	assertEquals("Around advice must NOT apply", realAge, itb.getAge());

	// Hit the method in the per clause to instantiate the aspect
	itb.getSpouse();

	assertEquals("Around advice must apply", 0, itb.getAge());
	assertEquals("Around advice must apply", 1, itb.getAge());
}
 
Example #3
Source File: AbstractAspectJAdvisorFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultiplePerTargetAspectsWithOrderAnnotation() throws SecurityException, NoSuchMethodException {
	TestBean target = new TestBean();
	int realAge = 65;
	target.setAge(realAge);

	List<Advisor> advisors = new LinkedList<Advisor>();
	PerTargetAspectWithOrderAnnotation10 aspect1 = new PerTargetAspectWithOrderAnnotation10();
	aspect1.count = 100;
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect1, "someBean1")));
	PerTargetAspectWithOrderAnnotation5 aspect2 = new PerTargetAspectWithOrderAnnotation5();
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect2, "someBean2")));
	Collections.sort(advisors, new OrderComparator());

	TestBean itb = (TestBean) createProxy(target, advisors, TestBean.class);
	assertEquals("Around advice must NOT apply", realAge, itb.getAge());

	// Hit the method in the per clause to instantiate the aspect
	itb.getSpouse();

	assertEquals("Around advice must apply", 0, itb.getAge());
	assertEquals("Around advice must apply", 1, itb.getAge());
}
 
Example #4
Source File: AbstractAspectJAdvisorFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testMultiplePerTargetAspectsWithOrderAnnotation() throws SecurityException, NoSuchMethodException {
	TestBean target = new TestBean();
	int realAge = 65;
	target.setAge(realAge);

	List<Advisor> advisors = new LinkedList<>();
	PerTargetAspectWithOrderAnnotation10 aspect1 = new PerTargetAspectWithOrderAnnotation10();
	aspect1.count = 100;
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect1, "someBean1")));
	PerTargetAspectWithOrderAnnotation5 aspect2 = new PerTargetAspectWithOrderAnnotation5();
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect2, "someBean2")));
	Collections.sort(advisors, new OrderComparator());

	TestBean itb = (TestBean) createProxy(target, advisors, TestBean.class);
	assertEquals("Around advice must NOT apply", realAge, itb.getAge());

	// Hit the method in the per clause to instantiate the aspect
	itb.getSpouse();

	assertEquals("Around advice must apply", 0, itb.getAge());
	assertEquals("Around advice must apply", 1, itb.getAge());
}
 
Example #5
Source File: AbstractAspectJAdvisorFactoryTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testMultiplePerTargetAspects() throws SecurityException, NoSuchMethodException {
	TestBean target = new TestBean();
	int realAge = 65;
	target.setAge(realAge);

	List<Advisor> advisors = new LinkedList<>();
	PerTargetAspect aspect1 = new PerTargetAspect();
	aspect1.count = 100;
	aspect1.setOrder(10);
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect1, "someBean1")));
	PerTargetAspect aspect2 = new PerTargetAspect();
	aspect2.setOrder(5);
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect2, "someBean2")));
	Collections.sort(advisors, new OrderComparator());

	TestBean itb = (TestBean) createProxy(target, advisors, TestBean.class);
	assertEquals("Around advice must NOT apply", realAge, itb.getAge());

	// Hit the method in the per clause to instantiate the aspect
	itb.getSpouse();

	assertEquals("Around advice must apply", 0, itb.getAge());
	assertEquals("Around advice must apply", 1, itb.getAge());
}
 
Example #6
Source File: ApiFilenameCheckerFactory.java    From swagger-brake with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an {@link ApiFileNameChecker} instance based on the provided configuredApiFilename argument.
 * @param configuredApiFilename the filename that is used to construct a proper instance f {@link ApiFileNameChecker}
 * @return the {@link ApiFileNameChecker}
 */
public ApiFileNameChecker create(String configuredApiFilename) {
    Collection<ApiFileNameChecker> checkers = new TreeSet<>(OrderComparator.INSTANCE);
    checkers.add(new SwaggerApiFileNameChecker());
    if (StringUtils.isNotBlank(configuredApiFilename)) {
        checkers.add(new ConfigurableApiFileNameChecker(configuredApiFilename));
    }
    return new ApiFileNameCheckerChain(checkers);
}
 
Example #7
Source File: PostProcessorRegistrationDelegate.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static void sortPostProcessors(List<?> postProcessors, ConfigurableListableBeanFactory beanFactory) {
	Comparator<Object> comparatorToUse = null;
	if (beanFactory instanceof DefaultListableBeanFactory) {
		comparatorToUse = ((DefaultListableBeanFactory) beanFactory).getDependencyComparator();
	}
	if (comparatorToUse == null) {
		comparatorToUse = OrderComparator.INSTANCE;
	}
	Collections.sort(postProcessors, comparatorToUse);
}
 
Example #8
Source File: DefaultListableBeanFactory.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private Comparator<Object> adaptDependencyComparator(Map<String, Object> matchingBeans) {
	Comparator<Object> comparator = getDependencyComparator();
	if (comparator instanceof OrderComparator) {
		return ((OrderComparator) comparator).withSourceProvider(
				createFactoryAwareOrderSourceProvider(matchingBeans));
	}
	else {
		return comparator;
	}
}
 
Example #9
Source File: AbstractAspectJAdvisorFactoryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiplePerTargetAspects() throws SecurityException, NoSuchMethodException {
	TestBean target = new TestBean();
	int realAge = 65;
	target.setAge(realAge);

	List<Advisor> advisors = new LinkedList<Advisor>();
	PerTargetAspect aspect1 = new PerTargetAspect();
	aspect1.count = 100;
	aspect1.setOrder(10);
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect1, "someBean1")));
	PerTargetAspect aspect2 = new PerTargetAspect();
	aspect2.setOrder(5);
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect2, "someBean2")));
	Collections.sort(advisors, new OrderComparator());

	TestBean itb = (TestBean) createProxy(target, advisors, TestBean.class);
	assertEquals("Around advice must NOT apply", realAge, itb.getAge());

	// Hit the method in the per clause to instantiate the aspect
	itb.getSpouse();

	assertEquals("Around advice must apply", 0, itb.getAge());
	assertEquals("Around advice must apply", 1, itb.getAge());
}
 
Example #10
Source File: PostProcessorRegistrationDelegate.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private static void sortPostProcessors(ConfigurableListableBeanFactory beanFactory, List<?> postProcessors) {
	Comparator<Object> comparatorToUse = null;
	if (beanFactory instanceof DefaultListableBeanFactory) {
		comparatorToUse = ((DefaultListableBeanFactory) beanFactory).getDependencyComparator();
	}
	if (comparatorToUse == null) {
		comparatorToUse = OrderComparator.INSTANCE;
	}
	Collections.sort(postProcessors, comparatorToUse);
}
 
Example #11
Source File: DefaultListableBeanFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private Comparator<Object> adaptDependencyComparator(Map<String, Object> matchingBeans) {
	Comparator<Object> comparator = getDependencyComparator();
	if (comparator instanceof OrderComparator) {
		return ((OrderComparator) comparator).withSourceProvider(
				createFactoryAwareOrderSourceProvider(matchingBeans));
	}
	else {
		return comparator;
	}
}
 
Example #12
Source File: CompositeOrderedProcessor.java    From FortifyBugTrackerUtility with MIT License 5 votes vote down vote up
/**
 * This method retrieves the currently configured {@link IProcessor} instances
 * from our superclass, and returns them in a sorted order.
 */
@Override
protected List<IProcessor> getProcessors() {
	List<IProcessor> result = new ArrayList<IProcessor>(super.getProcessors());
	result.sort(new OrderComparator());
	return result;
}
 
Example #13
Source File: AppContext.java    From cuba with Apache License 2.0 5 votes vote down vote up
static void startContext() {
    if (started)
        return;

    started = true;
    listeners.sort(new OrderComparator());
    for (Listener listener : listeners) {
        listener.applicationStarted();
    }

    Events events = (Events) getApplicationContext().getBean(Events.NAME);
    events.publish(new AppContextStartedEvent(context));

    listenersNotified = true;
}
 
Example #14
Source File: PersistenceImplSupport.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    Map<String, BeforeCommitTransactionListener> beforeCommitMap = applicationContext.getBeansOfType(BeforeCommitTransactionListener.class);
    beforeCommitTxListeners = new ArrayList<>(beforeCommitMap.values());
    beforeCommitTxListeners.sort(new OrderComparator());

    Map<String, AfterCompleteTransactionListener> afterCompleteMap = applicationContext.getBeansOfType(AfterCompleteTransactionListener.class);
    afterCompleteTxListeners = new ArrayList<>(afterCompleteMap.values());
    afterCompleteTxListeners.sort(new OrderComparator());
}
 
Example #15
Source File: DefaultSchemaService.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public List<Schema> getSortedSchemas()
{
    List<Schema> schemas = Lists.newArrayList( classSchemaMap.values() );
    schemas.sort( OrderComparator.INSTANCE );

    return schemas;
}
 
Example #16
Source File: DefaultSchemaService.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public List<Schema> getMetadataSchemas()
{
    List<Schema> schemas = getSchemas();

    schemas.removeIf( schema -> !schema.isMetadata() );
    schemas.sort( OrderComparator.INSTANCE );

    return schemas;
}
 
Example #17
Source File: ExtRequestMappingHandlerMapping.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Override
protected void detectMappedInterceptors(List<HandlerInterceptor> mappedInterceptors) {
	super.detectMappedInterceptors(mappedInterceptors);
	CUtils.stripNull(mappedInterceptors);
	Collections.sort(mappedInterceptors, new Comparator<HandlerInterceptor>() {

		@Override
		public int compare(HandlerInterceptor o1, HandlerInterceptor o2) {
			return OrderComparator.INSTANCE.compare(o1, o2);
		}
		
	});
}
 
Example #18
Source File: ScoringServiceImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void register(ScoringAgent agent, boolean isDefault) {
    if (agent == null) {
        throw new RuntimeException("can't register a null agent");
    }
    if (agent.getAgentId() == null) {
        throw new RuntimeException("the scoring agentId is null");
    }
    scoringAgentMap.put(agent.getAgentId(), agent);
    sortedScoringAgents = new ArrayList<ScoringAgent>(scoringAgentMap.values());
    Collections.sort(sortedScoringAgents, new OrderComparator());

    if (isDefault) {
        defaultScoringAgent = agent;
    }
}
 
Example #19
Source File: ScoringServiceImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void register(ScoringAgent agent) {
    if (agent == null) {
        throw new RuntimeException("can't register a null agent");
    }
    if (agent.getAgentId() == null) {
        throw new RuntimeException("the scoring agentId is null");
    }
    scoringAgentMap.put(agent.getAgentId(), agent);
    sortedScoringAgents = new ArrayList<ScoringAgent>(scoringAgentMap.values());
    Collections.sort(sortedScoringAgents, new OrderComparator());
}
 
Example #20
Source File: CompositeEnvironmentRepository.java    From spring-cloud-config with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link CompositeEnvironmentRepository}.
 * @param environmentRepositories The list of {@link EnvironmentRepository}s to create
 * the composite from.
 */
public CompositeEnvironmentRepository(
		List<EnvironmentRepository> environmentRepositories) {
	// Sort the environment repositories by the priority
	Collections.sort(environmentRepositories, OrderComparator.INSTANCE);
	this.environmentRepositories = environmentRepositories;
}
 
Example #21
Source File: ScoringServiceImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void register(ScoringAgent agent, boolean isDefault) {
    if (agent == null) {
        throw new RuntimeException("can't register a null agent");
    }
    if (agent.getAgentId() == null) {
        throw new RuntimeException("the scoring agentId is null");
    }
    scoringAgentMap.put(agent.getAgentId(), agent);
    sortedScoringAgents = new ArrayList<ScoringAgent>(scoringAgentMap.values());
    Collections.sort(sortedScoringAgents, new OrderComparator());

    if (isDefault) {
        defaultScoringAgent = agent;
    }
}
 
Example #22
Source File: ScoringServiceImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void register(ScoringAgent agent) {
    if (agent == null) {
        throw new RuntimeException("can't register a null agent");
    }
    if (agent.getAgentId() == null) {
        throw new RuntimeException("the scoring agentId is null");
    }
    scoringAgentMap.put(agent.getAgentId(), agent);
    sortedScoringAgents = new ArrayList<ScoringAgent>(scoringAgentMap.values());
    Collections.sort(sortedScoringAgents, new OrderComparator());
}
 
Example #23
Source File: AbstractGrayManager.java    From spring-cloud-gray with Apache License 2.0 5 votes vote down vote up
private void putTypeAllTo(Map<String, List<RequestInterceptor>> requestInterceptorMap, List<RequestInterceptor> all) {
    if (all.isEmpty()) {
        return;
    }
    requestInterceptorMap.values().forEach(list -> {
        list.addAll(all);
        OrderComparator.sort(list);
    });
}
 
Example #24
Source File: ConfigurationClassParser.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Register member (nested) classes that happen to be configuration classes themselves.
 */
private void processMemberClasses(ConfigurationClass configClass, SourceClass sourceClass) throws IOException {
	Collection<SourceClass> memberClasses = sourceClass.getMemberClasses();
	if (!memberClasses.isEmpty()) {
		List<SourceClass> candidates = new ArrayList<>(memberClasses.size());
		for (SourceClass memberClass : memberClasses) {
			if (ConfigurationClassUtils.isConfigurationCandidate(memberClass.getMetadata()) &&
					!memberClass.getMetadata().getClassName().equals(configClass.getMetadata().getClassName())) {
				candidates.add(memberClass);
			}
		}
		OrderComparator.sort(candidates);
		for (SourceClass candidate : candidates) {
			if (this.importStack.contains(configClass)) {
				this.problemReporter.error(new CircularImportProblem(configClass, this.importStack));
			}
			else {
				this.importStack.push(configClass);
				try {
					processConfigurationClass(candidate.asConfigClass(configClass));
				}
				finally {
					this.importStack.pop();
				}
			}
		}
	}
}
 
Example #25
Source File: PostProcessorRegistrationDelegate.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private static void sortPostProcessors(List<?> postProcessors, ConfigurableListableBeanFactory beanFactory) {
	Comparator<Object> comparatorToUse = null;
	if (beanFactory instanceof DefaultListableBeanFactory) {
		comparatorToUse = ((DefaultListableBeanFactory) beanFactory).getDependencyComparator();
	}
	if (comparatorToUse == null) {
		comparatorToUse = OrderComparator.INSTANCE;
	}
	postProcessors.sort(comparatorToUse);
}
 
Example #26
Source File: DefaultListableBeanFactory.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Nullable
private Comparator<Object> adaptDependencyComparator(Map<String, ?> matchingBeans) {
	Comparator<Object> comparator = getDependencyComparator();
	if (comparator instanceof OrderComparator) {
		return ((OrderComparator) comparator).withSourceProvider(
				createFactoryAwareOrderSourceProvider(matchingBeans));
	}
	else {
		return comparator;
	}
}
 
Example #27
Source File: SpringMvcPolyfill.java    From Milkomeda with MIT License 5 votes vote down vote up
/**
 * 动态添加拦截器
 * @param interceptor       拦截器
 * @param order             排序
 * @param includeURLs       需要拦截的URL
 * @param excludeURLs       排除拦截的URL
 * @param handlerMapping    AbstractHandlerMapping实现类
 */
@SuppressWarnings("all")
public static void addDynamicInterceptor(HandlerInterceptor interceptor, int order, List<String> includeURLs, List<String> excludeURLs, AbstractHandlerMapping handlerMapping) {
    String[] include = StringUtils.toStringArray(includeURLs);
    String[] exclude = StringUtils.toStringArray(excludeURLs);
    // HandlerInterceptor -> MappedInterceptor -> HydrogenMappedInterceptor
    HydrogenMappedInterceptor hmi = new HydrogenMappedInterceptor(new MappedInterceptor(include, exclude, interceptor));
    // 内部的处理流程会设置,然而不是最终采纳的拦截器列表
    // handlerMapping.setInterceptors(mappedInterceptor);
    hmi.setOrder(order);
    try {
        findAdaptedInterceptorsField(handlerMapping);
        // 添加到可采纳的拦截器列表,让拦截器处理器Chain流程获取得到这个拦截器
        List<HandlerInterceptor> handlerInterceptors = (List<HandlerInterceptor>) adaptedInterceptorsField.get(handlerMapping);
        // 过滤添加过的拦截器
        boolean mapped = handlerInterceptors.stream().anyMatch(itor -> {
            // 只判断HydrogenMappedInterceptor拦截器类型
            if (itor instanceof HydrogenMappedInterceptor) {
                return itor.equals(hmi);
            }
            return false;
        });
        if (mapped) {
            return;
        }
        handlerInterceptors.add(hmi);
        // 仿Spring MVC源码对拦截器排序
        handlerInterceptors = handlerInterceptors.stream()
                .sorted(OrderComparator.INSTANCE.withSourceProvider(itor -> {
                    if (itor instanceof HydrogenMappedInterceptor) {
                        return (Ordered) ((HydrogenMappedInterceptor) itor)::getOrder;
                    }
                    return null;
                })).collect(Collectors.toList());
        adaptedInterceptorsField.set(handlerMapping, handlerInterceptors);
    } catch (Exception e) {
        log.error("SpringMvcPolyfill invoke AbstractHandlerMapping.adaptedInterceptors error with msg: {}",  e.getMessage(), e);
    }
}
 
Example #28
Source File: AbstractAspectJAdvisorFactoryTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testMultiplePerTargetAspects() throws SecurityException, NoSuchMethodException {
	TestBean target = new TestBean();
	int realAge = 65;
	target.setAge(realAge);

	List<Advisor> advisors = new LinkedList<>();
	PerTargetAspect aspect1 = new PerTargetAspect();
	aspect1.count = 100;
	aspect1.setOrder(10);
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect1, "someBean1")));
	PerTargetAspect aspect2 = new PerTargetAspect();
	aspect2.setOrder(5);
	advisors.addAll(
			getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(aspect2, "someBean2")));
	Collections.sort(advisors, new OrderComparator());

	TestBean itb = (TestBean) createProxy(target, advisors, TestBean.class);
	assertEquals("Around advice must NOT apply", realAge, itb.getAge());

	// Hit the method in the per clause to instantiate the aspect
	itb.getSpouse();

	assertEquals("Around advice must apply", 0, itb.getAge());
	assertEquals("Around advice must apply", 1, itb.getAge());
}
 
Example #29
Source File: ConfigurationClassParser.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Register member (nested) classes that happen to be configuration classes themselves.
 */
private void processMemberClasses(ConfigurationClass configClass, SourceClass sourceClass) throws IOException {
	Collection<SourceClass> memberClasses = sourceClass.getMemberClasses();
	if (!memberClasses.isEmpty()) {
		List<SourceClass> candidates = new ArrayList<>(memberClasses.size());
		for (SourceClass memberClass : memberClasses) {
			if (ConfigurationClassUtils.isConfigurationCandidate(memberClass.getMetadata()) &&
					!memberClass.getMetadata().getClassName().equals(configClass.getMetadata().getClassName())) {
				candidates.add(memberClass);
			}
		}
		OrderComparator.sort(candidates);
		for (SourceClass candidate : candidates) {
			if (this.importStack.contains(configClass)) {
				this.problemReporter.error(new CircularImportProblem(configClass, this.importStack));
			}
			else {
				this.importStack.push(configClass);
				try {
					processConfigurationClass(candidate.asConfigClass(configClass));
				}
				finally {
					this.importStack.pop();
				}
			}
		}
	}
}
 
Example #30
Source File: PostProcessorRegistrationDelegate.java    From java-technology-stack with MIT License 5 votes vote down vote up
private static void sortPostProcessors(List<?> postProcessors, ConfigurableListableBeanFactory beanFactory) {
	Comparator<Object> comparatorToUse = null;
	if (beanFactory instanceof DefaultListableBeanFactory) {
		comparatorToUse = ((DefaultListableBeanFactory) beanFactory).getDependencyComparator();
	}
	if (comparatorToUse == null) {
		comparatorToUse = OrderComparator.INSTANCE;
	}
	postProcessors.sort(comparatorToUse);
}