Java 类org.springframework.core.OrderComparator 实例源码

项目:cas-5.1.0    文件:PolicyBasedAuthenticationManager.java   
/**
 * Evaluate produced authentication context.
 * We apply an implicit security policy of at least one successful authentication.
 * Then, we apply the configured security policy.
 *
 * @param builder     the builder
 * @param transaction the transaction
 * @throws AuthenticationException the authentication exception
 */
protected void evaluateProducedAuthenticationContext(final AuthenticationBuilder builder,
                                                     final AuthenticationTransaction transaction) throws AuthenticationException {
    if (builder.getSuccesses().isEmpty()) {
        publishEvent(new CasAuthenticationTransactionFailureEvent(this, builder.getFailures(), transaction.getCredentials()));
        throw new AuthenticationException(builder.getFailures(), builder.getSuccesses());
    }

    final Authentication authentication = builder.build();
    final List<AuthenticationPolicy> policies = new ArrayList<>(this.authenticationPolicies);
    OrderComparator.sort(policies);
    final boolean result = policies.stream().allMatch(p -> {
        LOGGER.debug("Executing authentication policy [{}]", p.getClass().getSimpleName());
        return p.isSatisfiedBy(authentication);
    });

    if (!result) {
        publishEvent(new CasAuthenticationPolicyFailureEvent(this, builder.getFailures(), transaction, authentication));
        throw new AuthenticationException(builder.getFailures(), builder.getSuccesses());
    }
}
项目:cas-5.1.0    文件:CasPersonDirectoryConfiguration.java   
@ConditionalOnMissingBean(name = "attributeRepositories")
@Bean
@RefreshScope
public List<IPersonAttributeDao> attributeRepositories() {
    final List<IPersonAttributeDao> list = new ArrayList<>();

    list.addAll(ldapAttributeRepositories());
    list.addAll(jdbcAttributeRepositories());
    list.addAll(jsonAttributeRepositories());
    list.addAll(groovyAttributeRepositories());
    list.addAll(grouperAttributeRepositories());
    list.addAll(stubAttributeRepositories());

    OrderComparator.sort(list);

    LOGGER.debug("Final list of attribute repositories is [{}]", list);
    return list;
}
项目:lams    文件:TransactionSynchronizationManager.java   
/**
 * Return an unmodifiable snapshot list of all registered synchronizations
 * for the current thread.
 * @return unmodifiable List of TransactionSynchronization instances
 * @throws IllegalStateException if synchronization is not active
 * @see TransactionSynchronization
 */
public static List<TransactionSynchronization> getSynchronizations() throws IllegalStateException {
    Set<TransactionSynchronization> synchs = synchronizations.get();
    if (synchs == null) {
        throw new IllegalStateException("Transaction synchronization is not active");
    }
    // Return unmodifiable snapshot, to avoid ConcurrentModificationExceptions
    // while iterating and invoking synchronization callbacks that in turn
    // might register further synchronizations.
    if (synchs.isEmpty()) {
        return Collections.emptyList();
    }
    else {
        // Sort lazily here, not in registerSynchronization.
        List<TransactionSynchronization> sortedSynchs = new ArrayList<TransactionSynchronization>(synchs);
        OrderComparator.sort(sortedSynchs);
        return Collections.unmodifiableList(sortedSynchs);
    }
}
项目:spring4-understanding    文件:AbstractAspectJAdvisorFactoryTests.java   
@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());
}
项目:FoDBugTrackerUtility    文件:SSCContextGeneratorAndUpdater.java   
private List<ISSCApplicationVersionFilter> getFiltersForContext(Context context) {
    List<ISSCApplicationVersionFilter> filtersForContext = getFilters();
    List<ISSCApplicationVersionFilterFactory> filterFactories = getFilterFactories();
    if ( filtersForContext == null ) {
        filtersForContext = new ArrayList<ISSCApplicationVersionFilter>();
    }
    if ( filterFactories != null ) {
        for ( ISSCApplicationVersionFilterFactory filterFactory : filterFactories ) {
            Collection<ISSCApplicationVersionFilter> filtersFromFactory = filterFactory.getSSCApplicationVersionFilters(context);
            if ( filtersFromFactory!= null ) {
                filtersForContext.addAll(filtersFromFactory);
            }
        }
    }
    filtersForContext.sort(new OrderComparator());
    return filtersForContext;
}
项目:FoDBugTrackerUtility    文件:FoDContextGeneratorAndUpdater.java   
private List<IFoDReleaseFilter> getFiltersForContext(Context context) {
    List<IFoDReleaseFilter> filtersForContext = getFilters();
    List<IFoDReleaseFilterFactory> filterFactories = getFilterFactories();
    if ( filtersForContext == null ) {
        filtersForContext = new ArrayList<IFoDReleaseFilter>();
    }
    if ( filterFactories != null ) {
        for ( IFoDReleaseFilterFactory filterFactory : filterFactories ) {
            Collection<IFoDReleaseFilter> filtersFromFactory = filterFactory.getFoDReleaseFilters(context);
            if ( filtersFromFactory!= null ) {
                filtersForContext.addAll(filtersFromFactory);
            }
        }
    }
    filtersForContext.sort(new OrderComparator());
    return filtersForContext;
}
项目:FoDBugTrackerUtility    文件:SpringExpressionUtil.java   
/**
 * Automatically load all PropertyAccessor implementations
 * (annotated with {@link Component}) from 
 * com.fortify.util.spring.propertyaccessor (sub-)packages. 
 * @return
 */
private static final List<PropertyAccessor> getPropertyAccessors() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext("com.fortify.util.spring.propertyaccessor");
    try {
        // Initialize list with discovered PropertyAccessors
        List<PropertyAccessor> result = new ArrayList<PropertyAccessor>(ctx.getBeansOfType(PropertyAccessor.class).values());
        // Add the standard PropertyAccessors
        result.addAll(new StandardEvaluationContext().getPropertyAccessors());

        // Order the accessors
        result.sort(new OrderComparator());

        LOG.info("[Process] Loaded PropertyAccessors: "+result);
        return result;
    } finally {
        ctx.close();
    }
}
项目:webanno    文件:AnnotationEditorExtensionRegistryImpl.java   
public AnnotationEditorExtensionRegistryImpl(
        @Autowired(required = false) List<AnnotationEditorExtension> aExtensions)
{
    if (aExtensions != null) {
        OrderComparator.sort(aExtensions);

        for (AnnotationEditorExtension ext : aExtensions) {
            log.info("Found annotation editor extension: {}",
                    ClassUtils.getAbbreviatedName(ext.getClass(), 20));
        }

        extensions = Collections.unmodifiableList(aExtensions);
    }
    else {
        extensions = Collections.emptyList();
    }
}
项目:AgileAlligators    文件:DefaultSchemaService.java   
@Override
public List<Schema> getMetadataSchemas()
{
    List<Schema> schemas = getSchemas();

    Iterator<Schema> iterator = schemas.iterator();

    while ( iterator.hasNext() )
    {
        Schema schema = iterator.next();

        if ( !schema.isMetadata() )
        {
            iterator.remove();
        }
    }

    Collections.sort( schemas, OrderComparator.INSTANCE );

    return schemas;
}
项目:perecoder    文件:IndexRebuildTaskPerformer.java   
/**
 * Формирует коллекцию фабрик перестроения
 *
 * @param targetClasses коллекция целевых классов или <code>NULL</code>, если необходимо перестроить все индексы
 * @return Возвращает коллекцию фабрик
 */
private List<LuceneRebuildCallbackFactory> createRebuildFactoriesByNames(final Collection<String> targetClasses) {
    // Собираем фабрики, индексы которых повреждены
    List<LuceneRebuildCallbackFactory> targetFactories = Lists.newArrayList(
            Collections2.filter(
                    factories,
                    new Predicate<LuceneRebuildCallbackFactory>() {
                        @Override
                        public boolean apply(LuceneRebuildCallbackFactory input) {
                            return targetClasses == null || targetClasses.contains(input.retrieveTargetClass().getName());
                        }
                    }
            )
    );
    // Сортируем фабрики согласно их порядку
    OrderComparator.sort(targetFactories);
    // Возвращаем коллекцию целевых фабрик
    return targetFactories;
}
项目:class-guard    文件:AbstractAspectJAdvisorFactoryTests.java   
@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());
}
项目:class-guard    文件:SpringFactoriesLoader.java   
/**
 * Load the factory implementations of the given type from the default location,
 * using the given class loader.
 * <p>The returned factories are ordered in accordance with the {@link OrderComparator}.
 * @param factoryClass the interface or abstract class representing the factory
 * @param classLoader the ClassLoader to use for loading (can be {@code null} to use the default)
 */
public static <T> List<T> loadFactories(Class<T> factoryClass, ClassLoader classLoader) {
    Assert.notNull(factoryClass, "'factoryClass' must not be null");
    ClassLoader classLoaderToUse = classLoader;
    if (classLoaderToUse == null) {
        classLoaderToUse = SpringFactoriesLoader.class.getClassLoader();
    }
    List<String> factoryNames = loadFactoryNames(factoryClass, classLoaderToUse);
    if (logger.isTraceEnabled()) {
        logger.trace("Loaded [" + factoryClass.getName() + "] names: " + factoryNames);
    }
    List<T> result = new ArrayList<T>(factoryNames.size());
    for (String factoryName : factoryNames) {
        result.add(instantiateFactory(factoryName, factoryClass, classLoaderToUse));
    }
    OrderComparator.sort(result);
    return result;
}
项目:class-guard    文件:TransactionSynchronizationManager.java   
/**
 * Return an unmodifiable snapshot list of all registered synchronizations
 * for the current thread.
 * @return unmodifiable List of TransactionSynchronization instances
 * @throws IllegalStateException if synchronization is not active
 * @see TransactionSynchronization
 */
public static List<TransactionSynchronization> getSynchronizations() throws IllegalStateException {
    Set<TransactionSynchronization> synchs = synchronizations.get();
    if (synchs == null) {
        throw new IllegalStateException("Transaction synchronization is not active");
    }
    // Return unmodifiable snapshot, to avoid ConcurrentModificationExceptions
    // while iterating and invoking synchronization callbacks that in turn
    // might register further synchronizations.
    if (synchs.isEmpty()) {
        return Collections.emptyList();
    }
    else {
        // Sort lazily here, not in registerSynchronization.
        List<TransactionSynchronization> sortedSynchs = new ArrayList<TransactionSynchronization>(synchs);
        OrderComparator.sort(sortedSynchs);
        return Collections.unmodifiableList(sortedSynchs);
    }
}
项目:class-guard    文件:ExceptionHandlerExceptionResolver.java   
private void initExceptionHandlerAdviceCache() {
    if (getApplicationContext() == null) {
        return;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Looking for exception mappings: " + getApplicationContext());
    }

    List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
    Collections.sort(beans, new OrderComparator());

    for (ControllerAdviceBean bean : beans) {
        ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(bean.getBeanType());
        if (resolver.hasExceptionMappings()) {
            this.exceptionHandlerAdviceCache.put(bean, resolver);
            logger.info("Detected @ExceptionHandler methods in " + bean);
        }
    }
}
项目:class-guard    文件:RequestMappingHandlerAdapter.java   
private void initControllerAdviceCache() {
    if (getApplicationContext() == null) {
        return;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Looking for controller advice: " + getApplicationContext());
    }

    List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
    Collections.sort(beans, new OrderComparator());

    for (ControllerAdviceBean bean : beans) {
        Set<Method> attrMethods = HandlerMethodSelector.selectMethods(bean.getBeanType(), MODEL_ATTRIBUTE_METHODS);
        if (!attrMethods.isEmpty()) {
            this.modelAttributeAdviceCache.put(bean, attrMethods);
            logger.info("Detected @ModelAttribute methods in " + bean);
        }
        Set<Method> binderMethods = HandlerMethodSelector.selectMethods(bean.getBeanType(), INIT_BINDER_METHODS);
        if (!binderMethods.isEmpty()) {
            this.initBinderAdviceCache.put(bean, binderMethods);
            logger.info("Detected @InitBinder methods in " + bean);
        }
    }
}
项目:clobaframe    文件:ResourceProviderSetImpl.java   
@Override
    public void addProvider(ResourceProvider webResourceProvider) {
        if (resourceProviders == null) {
            resourceProviders = new ArrayList<ResourceProvider>();
        }

        resourceProviders.add(webResourceProvider);

        // sort 0-9
        OrderComparator.sort(resourceProviders);
//      resourceProviders.sort(new Comparator<ResourceProvider>() {
//
//          @Override
//          public int compare(ResourceProvider o1, ResourceProvider o2) {
//              return o1.getOrder() - o2.getOrder();
//          }
//      });
    }
项目:clobaframe    文件:GlobalSettingImpl.java   
@Override
    public void addProvider(SettingProvider settingProvider) {
        Assert.isInstanceOf(GlobalSettingProvider.class, settingProvider);

        if (globalSettingProviders == null) {
            globalSettingProviders = new ArrayList<GlobalSettingProvider>();
        }

        globalSettingProviders.add((GlobalSettingProvider)settingProvider);

        // sort 0-9
        OrderComparator.sort(globalSettingProviders);
//      globalSettingProviders.sort(new Comparator<GlobalSettingProvider>() {
//          @Override
//          public int compare(GlobalSettingProvider o1, GlobalSettingProvider o2) {
//              return o1.getOrder() - o2.getOrder();
//          }
//      });
    }
项目:clobaframe    文件:PrincipalSettingImpl.java   
@Override
    public void addProvider(PrincipalSettingProvider settingProvider) {

        if (principalSettingProviders == null) {
            principalSettingProviders = new ArrayList<PrincipalSettingProvider>();
        }

        principalSettingProviders.add(settingProvider);

        // sort 0-9
        OrderComparator.sort(principalSettingProviders);
//      principalSettingProviders.sort(new Comparator<PrincipalSettingProvider>() {
//          @Override
//          public int compare(PrincipalSettingProvider o1, PrincipalSettingProvider o2) {
//              return o1.getOrder() - o2.getOrder();
//          }
//      });
    }
项目:cas-5.1.0    文件:DefaultAuthenticationServiceSelectionPlan.java   
@Override
public Service resolveService(final Service service) {
    OrderComparator.sort(this.strategies);
    return this.strategies.stream()
            .filter(s -> s.supports(service))
            .findFirst()
            .get()
            .resolveServiceFrom(service);
}
项目:cas-5.1.0    文件:DefaultAuthenticationEventExecutionPlan.java   
@Override
public Collection<AuthenticationMetaDataPopulator> getAuthenticationMetadataPopulators(final AuthenticationTransaction transaction) {
    final List<AuthenticationMetaDataPopulator> list = new ArrayList(this.authenticationMetaDataPopulatorList);
    OrderComparator.sort(list);
    LOGGER.debug("Sorted and registered metadata populators for this transaction are [{}]", list);
    return list;
}
项目:cas-5.1.0    文件:RankedMultifactorAuthenticationProviderSelector.java   
@Override
public MultifactorAuthenticationProvider resolve(final Collection<MultifactorAuthenticationProvider> providers,
                                                 final RegisteredService service, final Principal principal) {
    final List<MultifactorAuthenticationProvider> sorted = new ArrayList<>(providers);
    if (sorted.isEmpty()) {
        throw new RuntimeException("List of candidate multifactor authentication providers is empty");
    }
    OrderComparator.sort(sorted);
    final MultifactorAuthenticationProvider provider = sorted.get(sorted.size() - 1);
    LOGGER.debug("Selected the provider [{}] for service [{}] out of [{}] providers", provider, service, providers.size());
    return provider;
}
项目:cas-5.1.0    文件:RegisteredServiceChainingAttributeFilter.java   
@Override
public Map<String, Object> filter(final Map<String, Object> givenAttributes) {
    OrderComparator.sort(this.filters);
    final Map<String, Object> attributes = new HashMap<>();
    filters.forEach(policy -> attributes.putAll(policy.filter(givenAttributes)));
    return attributes;
}
项目:cas-5.1.0    文件:DefaultTicketCatalog.java   
@Override
public Collection<TicketDefinition> findAll() {
    final List list = new ArrayList<>(ticketMetadataMap.values());
    OrderComparator.sort(list);
    LOGGER.debug("Located all registered and known sorted ticket definitions [{}]", list);
    return list;
}
项目:cas-5.1.0    文件:DefaultTicketCatalog.java   
@Override
public Collection<TicketDefinition> find(final Class<Ticket> ticketClass) {
    final List list = ticketMetadataMap.values()
            .stream()
            .filter(t -> t.getImplementationClass().isInstance(ticketClass))
            .collect(Collectors.toList());
    OrderComparator.sort(list);
    LOGGER.debug("Located all registered and known sorted ticket definitions [{}] that match [{}]", list, ticketClass);
    return list;
}
项目:gemini.blueprint    文件:AbstractDelegatedExecutionApplicationContext.java   
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);
}
项目:lams    文件:AspectJProxyFactory.java   
/**
 * Add all {@link Advisor Advisors} from the supplied {@link MetadataAwareAspectInstanceFactory}
 * to the current chain. Exposes any special purpose {@link Advisor Advisors} if needed.
 * @see AspectJProxyUtils#makeAdvisorChainAspectJCapableIfNecessary(List)
 */
private void addAdvisorsFromAspectInstanceFactory(MetadataAwareAspectInstanceFactory instanceFactory) {
    List<Advisor> advisors = this.aspectFactory.getAdvisors(instanceFactory);
    advisors = AopUtils.findAdvisorsThatCanApply(advisors, getTargetClass());
    AspectJProxyUtils.makeAdvisorChainAspectJCapableIfNecessary(advisors);
    OrderComparator.sort(advisors);
    addAdvisors(advisors);
}
项目:game    文件:EventRegistery.java   
public void registerIEventInvoke(Class<? extends Event<?>> eventClz, IEventInvoke invoke) {
List<IEventInvoke> listInvokes = eventInvokes.get(eventClz);
if (listInvokes == null) {
    listInvokes = new ArrayList<IEventInvoke>();
    eventInvokes.put(eventClz, listInvokes);
}
listInvokes.add(invoke);
OrderComparator.sort(listInvokes);
   }
项目:spring4-understanding    文件:AbstractAspectJAdvisorFactoryTests.java   
@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());
}
项目:spring4-understanding    文件:PostProcessorRegistrationDelegate.java   
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);
}
项目:spring4-understanding    文件:DefaultListableBeanFactory.java   
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;
    }
}
项目:FoDBugTrackerUtility    文件:CompositeOrderedProcessor.java   
/**
 * 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;
}
项目:spring    文件:PostProcessorRegistrationDelegate.java   
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);
}
项目:spring    文件:DefaultListableBeanFactory.java   
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;
    }
}
项目:cuba    文件:ExceptionHandlers.java   
/**
 * Create all Web handlers defined by <code>ExceptionHandlersConfiguration</code> beans in spring.xml and
 * GUI handlers defined as Spring-beans.
 */
public void createByConfiguration() {
    removeAll();

    // Web handlers
    Map<String, ExceptionHandlersConfiguration> map = AppBeans.getAll(ExceptionHandlersConfiguration.class);

    // Project-level handlers must run before platform-level
    List<ExceptionHandlersConfiguration> configurations = new ArrayList<>(map.values());
    Collections.reverse(configurations);

    for (ExceptionHandlersConfiguration conf : configurations) {
        for (Class aClass : conf.getHandlerClasses()) {
            try {
                addHandler(ReflectionHelper.<ExceptionHandler>newInstance(aClass));
            } catch (NoSuchMethodException e) {
                log.error("Unable to instantiate {}", aClass, e);
            }
        }
    }

    // GUI handlers
    Map<String, GenericExceptionHandler> handlerMap = AppBeans.getAll(GenericExceptionHandler.class);

    List<GenericExceptionHandler> handlers = new ArrayList<>(handlerMap.values());
    handlers.sort(new OrderComparator());

    for (GenericExceptionHandler handler : handlers) {
        addHandler(handler);
    }
}
项目:cuba    文件:AppContext.java   
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;
}
项目:cuba    文件:PersistenceImplSupport.java   
@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());
}
项目:dhis2-core    文件:DefaultSchemaService.java   
@Override
public List<Schema> getSortedSchemas()
{
    List<Schema> schemas = Lists.newArrayList( classSchemaMap.values() );
    schemas.sort( OrderComparator.INSTANCE );

    return schemas;
}
项目:dhis2-core    文件:DefaultSchemaService.java   
@Override
public List<Schema> getMetadataSchemas()
{
    List<Schema> schemas = getSchemas();

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

    return schemas;
}
项目:dhis2-core    文件:AbstractNode.java   
@Override
public List<Node> getChildren()
{
    if ( sortedChildren == null )
    {
        List<Node> clone = Lists.newArrayList( children );
        Collections.sort( clone, OrderComparator.INSTANCE );
        sortedChildren = ImmutableList.copyOf( clone );
    }

    return sortedChildren;
}
项目:wx_api    文件:EventMulticaster.java   
/**
 * 根据事件来选取监听该事件的listener
 * @param weEvent {@link WXEvent}
 * @return 所有监听该事件的listener,如果没有返回空的collection
 */
public Collection<WXEventListener> getListeners(WXEvent weEvent) {
    //事件的class
    Class<? extends WXEvent> eventType = weEvent.getClass();
    //事件调用源
    Object source = weEvent.getSource();
    //事件调用源的class
    Class<?> sourceType = (source != null ? source.getClass() : null);
    ListenerCacheKey cacheKey = new ListenerCacheKey(eventType, sourceType);
    //尝试从缓存中读取
    ListenerRetriever retriever = this.retrieverCache.get(cacheKey);
    if (retriever != null) {
        //一个检索管理下可能有多个Listener
        return retriever.getWxEventListeners();
    } else {
        retriever = new ListenerRetriever();
        LinkedList<WXEventListener> allListeners = new LinkedList<WXEventListener>();
        Set<WXEventListener> listeners;
        synchronized (this.defaultRetriever) {
            //从默认检索管理中取出所有,准备进行对比
            listeners = new LinkedHashSet<WXEventListener>(this.defaultRetriever.wxEventListeners);
        }
        for (WXEventListener listener : listeners) {
            //当支持这个事件时
            if (supportsEvent(listener, eventType, sourceType)) {
                retriever.wxEventListeners.add(listener);
                allListeners.add(listener);
            }
        }
        //权重排序
        OrderComparator.sort(allListeners);
        this.retrieverCache.put(cacheKey, retriever);
        return allListeners;
    }
}