当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationAwareOrderComparator类代码示例

本文整理汇总了Java中org.springframework.core.annotation.AnnotationAwareOrderComparator的典型用法代码示例。如果您正苦于以下问题:Java AnnotationAwareOrderComparator类的具体用法?Java AnnotationAwareOrderComparator怎么用?Java AnnotationAwareOrderComparator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AnnotationAwareOrderComparator类属于org.springframework.core.annotation包,在下文中一共展示了AnnotationAwareOrderComparator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jwtTokenEnhancer

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
@Bean
public JwtAccessTokenConverter jwtTokenEnhancer() {
	JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
	String keyValue = this.resource.getJwt().getKeyValue();
	if (!StringUtils.hasText(keyValue)) {
		keyValue = getKeyFromServer();
	}
	if (StringUtils.hasText(keyValue) && !keyValue.startsWith("-----BEGIN")) {
		converter.setSigningKey(keyValue);
	}
	if (keyValue != null) {
		converter.setVerifierKey(keyValue);
	}
	if (!CollectionUtils.isEmpty(this.configurers)) {
		AnnotationAwareOrderComparator.sort(this.configurers);
		for (JwtAccessTokenConverterConfigurer configurer : this.configurers) {
			configurer.configure(converter);
		}
	}
	return converter;
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:22,代码来源:ResourceServerTokenServicesConfiguration.java

示例2: getUserInfoRestTemplate

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
@Override
public OAuth2RestTemplate getUserInfoRestTemplate() {
	if (this.oauth2RestTemplate == null) {
		this.oauth2RestTemplate = createOAuth2RestTemplate(
				this.details == null ? DEFAULT_RESOURCE_DETAILS : this.details);
		this.oauth2RestTemplate.getInterceptors()
				.add(new AcceptJsonRequestInterceptor());
		AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider();
		accessTokenProvider.setTokenRequestEnhancer(new AcceptJsonRequestEnhancer());
		this.oauth2RestTemplate.setAccessTokenProvider(accessTokenProvider);
		if (!CollectionUtils.isEmpty(this.customizers)) {
			AnnotationAwareOrderComparator.sort(this.customizers);
			for (UserInfoRestTemplateCustomizer customizer : this.customizers) {
				customizer.customize(this.oauth2RestTemplate);
			}
		}
	}
	return this.oauth2RestTemplate;
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:20,代码来源:DefaultUserInfoRestTemplateFactory.java

示例3: loadFactories

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
/**
 * Load and instantiate the factory implementations of the given type from
 * {@value #FACTORIES_RESOURCE_LOCATION}, using the given class loader.
 * <p>The returned factories are sorted in accordance with the {@link AnnotationAwareOrderComparator}.
 * <p>If a custom instantiation strategy is required, use {@link #loadFactoryNames}
 * to obtain all registered factory names.
 * @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)
 * @see #loadFactoryNames
 * @throws IllegalArgumentException if any factory implementation class cannot
 * be loaded or if an error occurs while instantiating any factory
 */
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));
	}
	AnnotationAwareOrderComparator.sort(result);
	return result;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:SpringFactoriesLoader.java

示例4: getSynchronizations

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
/**
 * 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);
		AnnotationAwareOrderComparator.sort(sortedSynchs);
		return Collections.unmodifiableList(sortedSynchs);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:TransactionSynchronizationManager.java

示例5: detectResourceHandlers

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
protected void detectResourceHandlers(ApplicationContext appContext) {
	logger.debug("Looking for resource handler mappings");

	Map<String, SimpleUrlHandlerMapping> map = appContext.getBeansOfType(SimpleUrlHandlerMapping.class);
	List<SimpleUrlHandlerMapping> handlerMappings = new ArrayList<SimpleUrlHandlerMapping>(map.values());
	AnnotationAwareOrderComparator.sort(handlerMappings);

	for (SimpleUrlHandlerMapping hm : handlerMappings) {
		for (String pattern : hm.getHandlerMap().keySet()) {
			Object handler = hm.getHandlerMap().get(pattern);
			if (handler instanceof ResourceHttpRequestHandler) {
				ResourceHttpRequestHandler resourceHandler = (ResourceHttpRequestHandler) handler;
				if (logger.isDebugEnabled()) {
					logger.debug("Found resource handler mapping: URL pattern=\"" + pattern + "\", " +
							"locations=" + resourceHandler.getLocations() + ", " +
							"resolvers=" + resourceHandler.getResourceResolvers());
				}
				this.handlerMap.put(pattern, resourceHandler);
			}
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:ResourceUrlProvider.java

示例6: initExceptionHandlerAdviceCache

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
private void initExceptionHandlerAdviceCache() {
	if (getApplicationContext() == null) {
		return;
	}
	if (logger.isDebugEnabled()) {
		logger.debug("Looking for exception mappings: " + getApplicationContext());
	}

	List<ControllerAdviceBean> adviceBeans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
	AnnotationAwareOrderComparator.sort(adviceBeans);

	for (ControllerAdviceBean adviceBean : adviceBeans) {
		ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(adviceBean.getBeanType());
		if (resolver.hasExceptionMappings()) {
			this.exceptionHandlerAdviceCache.put(adviceBean, resolver);
			logger.info("Detected @ExceptionHandler methods in " + adviceBean);
		}
		if (ResponseBodyAdvice.class.isAssignableFrom(adviceBean.getBeanType())) {
			this.responseBodyAdvice.add(adviceBean);
			logger.info("Detected ResponseBodyAdvice implementation in " + adviceBean);
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:ExceptionHandlerExceptionResolver.java

示例7: testConstructorResourceInjectionWithMultipleOrderedCandidates

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
@Test
public void testConstructorResourceInjectionWithMultipleOrderedCandidates() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE);
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(ConstructorsResourceInjectionBean.class));
	TestBean tb = new TestBean();
	bf.registerSingleton("testBean", tb);
	FixedOrder2NestedTestBean ntb1 = new FixedOrder2NestedTestBean();
	bf.registerSingleton("nestedTestBean1", ntb1);
	FixedOrder1NestedTestBean ntb2 = new FixedOrder1NestedTestBean();
	bf.registerSingleton("nestedTestBean2", ntb2);

	ConstructorsResourceInjectionBean bean = (ConstructorsResourceInjectionBean) bf.getBean("annotatedBean");
	assertNull(bean.getTestBean3());
	assertSame(tb, bean.getTestBean4());
	assertEquals(2, bean.getNestedTestBeans().length);
	assertSame(ntb2, bean.getNestedTestBeans()[0]);
	assertSame(ntb1, bean.getNestedTestBeans()[1]);
	bf.destroySingletons();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:AutowiredAnnotationBeanPostProcessorTests.java

示例8: testConstructorResourceInjectionWithMultipleCandidatesAsOrderedCollection

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
@Test
public void testConstructorResourceInjectionWithMultipleCandidatesAsOrderedCollection() {
	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	bf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE);
	AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
	bpp.setBeanFactory(bf);
	bf.addBeanPostProcessor(bpp);
	bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(
			ConstructorsCollectionResourceInjectionBean.class));
	TestBean tb = new TestBean();
	bf.registerSingleton("testBean", tb);
	FixedOrder2NestedTestBean ntb1 = new FixedOrder2NestedTestBean();
	bf.registerSingleton("nestedTestBean1", ntb1);
	FixedOrder1NestedTestBean ntb2 = new FixedOrder1NestedTestBean();
	bf.registerSingleton("nestedTestBean2", ntb2);

	ConstructorsCollectionResourceInjectionBean bean = (ConstructorsCollectionResourceInjectionBean) bf.getBean("annotatedBean");
	assertNull(bean.getTestBean3());
	assertSame(tb, bean.getTestBean4());
	assertEquals(2, bean.getNestedTestBeans().size());
	assertSame(ntb2, bean.getNestedTestBeans().get(0));
	assertSame(ntb1, bean.getNestedTestBeans().get(1));
	bf.destroySingletons();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:AutowiredAnnotationBeanPostProcessorTests.java

示例9: initApplicationContext

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
@Override
protected void initApplicationContext() throws BeansException {
	// new Exception("initApplicationContext").printStackTrace();
	// 修改拦截器排序
	try {
		Field field = AbstractHandlerMapping.class.getDeclaredField("interceptors");
		field.setAccessible(true);
		@SuppressWarnings("unchecked")
		List<Object> interceptors = (List<Object>) field.get(this);
		AnnotationAwareOrderComparator.sort(interceptors);
		// System.out.println("interceptors:" + interceptors);
	}
	catch (Exception e) {
		throw new RuntimeException(e.getMessage(), e);
	}
	super.initApplicationContext();
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:18,代码来源:LeopardHandlerMapping.java

示例10: getOrderedBeansOfType

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
private <T> List<Entry<String, T>> getOrderedBeansOfType(
		ListableBeanFactory beanFactory, Class<T> type, Set<?> excludes) {
	List<Entry<String, T>> beans = new ArrayList<Entry<String, T>>();
	Comparator<Entry<String, T>> comparator = new Comparator<Entry<String, T>>() {

		@Override
		public int compare(Entry<String, T> o1, Entry<String, T> o2) {
			return AnnotationAwareOrderComparator.INSTANCE.compare(o1.getValue(),
					o2.getValue());
		}

	};
	String[] names = beanFactory.getBeanNamesForType(type, true, false);
	Map<String, T> map = new LinkedHashMap<String, T>();
	for (String name : names) {
		if (!excludes.contains(name)) {
			T bean = beanFactory.getBean(name, type);
			if (!excludes.contains(bean)) {
				map.put(name, bean);
			}
		}
	}
	beans.addAll(map.entrySet());
	Collections.sort(beans, comparator);
	return beans;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:27,代码来源:ServletContextInitializerBeans.java

示例11: getListeners

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private List<ApplicationListener<ApplicationEvent>> getListeners(
		ConfigurableEnvironment env) {
	String classNames = env.getProperty(PROPERTY_NAME);
	List<ApplicationListener<ApplicationEvent>> listeners = new ArrayList<ApplicationListener<ApplicationEvent>>();
	if (StringUtils.hasLength(classNames)) {
		for (String className : StringUtils.commaDelimitedListToSet(classNames)) {
			try {
				Class<?> clazz = ClassUtils.forName(className,
						ClassUtils.getDefaultClassLoader());
				Assert.isAssignable(ApplicationListener.class, clazz, "class ["
						+ className + "] must implement ApplicationListener");
				listeners.add((ApplicationListener<ApplicationEvent>) BeanUtils
						.instantiateClass(clazz));
			}
			catch (Exception ex) {
				throw new ApplicationContextException(
						"Failed to load context listener class [" + className + "]",
						ex);
			}
		}
	}
	AnnotationAwareOrderComparator.sort(listeners);
	return listeners;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:DelegatingApplicationListener.java

示例12: restTemplateBuilder

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public RestTemplateBuilder restTemplateBuilder() {
	RestTemplateBuilder builder = new RestTemplateBuilder();
	HttpMessageConverters converters = this.messageConverters.getIfUnique();
	if (converters != null) {
		builder = builder.messageConverters(converters.getConverters());
	}
	List<RestTemplateCustomizer> customizers = this.restTemplateCustomizers
			.getIfAvailable();
	if (!CollectionUtils.isEmpty(customizers)) {
		customizers = new ArrayList<RestTemplateCustomizer>(customizers);
		AnnotationAwareOrderComparator.sort(customizers);
		builder = builder.customizers(customizers);
	}
	return builder;
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:18,代码来源:WebClientAutoConfiguration.java

示例13: getUserInfoRestTemplate

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
public OAuth2RestTemplate getUserInfoRestTemplate() {
	if (this.template == null) {
		this.template = getTemplate(
				this.details == null ? DEFAULT_RESOURCE_DETAILS : this.details);
		this.template.getInterceptors().add(new AcceptJsonRequestInterceptor());
		AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider();
		accessTokenProvider.setTokenRequestEnhancer(new AcceptJsonRequestEnhancer());
		this.template.setAccessTokenProvider(accessTokenProvider);
		if (!CollectionUtils.isEmpty(this.customizers)) {
			AnnotationAwareOrderComparator.sort(this.customizers);
			for (UserInfoRestTemplateCustomizer customizer : this.customizers) {
				customizer.customize(this.template);
			}
		}
	}
	return this.template;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:UserInfoRestTemplateFactory.java

示例14: getFilters

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
private List<GatewayFilter> getFilters(RouteDefinition routeDefinition) {
	List<GatewayFilter> filters = new ArrayList<>();

	//TODO: support option to apply defaults after route specific filters?
	if (!this.gatewayProperties.getDefaultFilters().isEmpty()) {
		filters.addAll(loadGatewayFilters("defaultFilters",
				this.gatewayProperties.getDefaultFilters()));
	}

	if (!routeDefinition.getFilters().isEmpty()) {
		filters.addAll(loadGatewayFilters(routeDefinition.getId(), routeDefinition.getFilters()));
	}

	AnnotationAwareOrderComparator.sort(filters);
	return filters;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gateway,代码行数:17,代码来源:RouteDefinitionRouteLocator.java

示例15: locate

import org.springframework.core.annotation.AnnotationAwareOrderComparator; //导入依赖的package包/类
@Override
public ResponseBuilder locate(final WebApplicationService service) {
    final Map<String, ResponseBuilder> beans = applicationContext.getBeansOfType(ResponseBuilder.class, false, true);
    final List<ResponseBuilder> builders = beans.values().stream().collect(Collectors.toList());
    AnnotationAwareOrderComparator.sortIfNecessary(builders);
    return builders.stream().filter(r -> r.supports(service)).findFirst().orElse(null);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:8,代码来源:DefaultWebApplicationResponseBuilderLocator.java


注:本文中的org.springframework.core.annotation.AnnotationAwareOrderComparator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。