Java Code Examples for org.springframework.core.Ordered#HIGHEST_PRECEDENCE

The following examples show how to use org.springframework.core.Ordered#HIGHEST_PRECEDENCE . 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: CorsConfig.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@Order(Ordered.HIGHEST_PRECEDENCE)
@Bean
public CorsWebFilter corsFilter() {
    CorsConfiguration config = new CorsConfiguration();
    // cookie跨域
    config.setAllowCredentials(Boolean.TRUE);
    config.addAllowedMethod(ALL);
    config.addAllowedOrigin(ALL);
    config.addAllowedHeader(ALL);
    // 配置前端js允许访问的自定义响应头
    config.addExposedHeader("setToken");

    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
    source.registerCorsConfiguration("/**", config);

    return new CorsWebFilter(source);
}
 
Example 2
Source File: ViewResolverRegistry.java    From java-technology-stack with MIT License 6 votes vote down vote up
private ContentNegotiatingViewResolver initContentNegotiatingViewResolver(View[] defaultViews) {
	// ContentNegotiatingResolver in the registry: elevate its precedence!
	this.order = (this.order != null ? this.order : Ordered.HIGHEST_PRECEDENCE);

	if (this.contentNegotiatingResolver != null) {
		if (!ObjectUtils.isEmpty(defaultViews) &&
				!CollectionUtils.isEmpty(this.contentNegotiatingResolver.getDefaultViews())) {
			List<View> views = new ArrayList<>(this.contentNegotiatingResolver.getDefaultViews());
			views.addAll(Arrays.asList(defaultViews));
			this.contentNegotiatingResolver.setDefaultViews(views);
		}
	}
	else {
		this.contentNegotiatingResolver = new ContentNegotiatingViewResolver();
		this.contentNegotiatingResolver.setDefaultViews(Arrays.asList(defaultViews));
		this.contentNegotiatingResolver.setViewResolvers(this.viewResolvers);
		if (this.contentNegotiationManager != null) {
			this.contentNegotiatingResolver.setContentNegotiationManager(this.contentNegotiationManager);
		}
	}
	return this.contentNegotiatingResolver;
}
 
Example 3
Source File: ViewResolverRegistry.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private ContentNegotiatingViewResolver initContentNegotiatingViewResolver(View[] defaultViews) {
	// ContentNegotiatingResolver in the registry: elevate its precedence!
	this.order = (this.order != null ? this.order : Ordered.HIGHEST_PRECEDENCE);

	if (this.contentNegotiatingResolver != null) {
		if (!ObjectUtils.isEmpty(defaultViews) &&
				!CollectionUtils.isEmpty(this.contentNegotiatingResolver.getDefaultViews())) {
			List<View> views = new ArrayList<>(this.contentNegotiatingResolver.getDefaultViews());
			views.addAll(Arrays.asList(defaultViews));
			this.contentNegotiatingResolver.setDefaultViews(views);
		}
	}
	else {
		this.contentNegotiatingResolver = new ContentNegotiatingViewResolver();
		this.contentNegotiatingResolver.setDefaultViews(Arrays.asList(defaultViews));
		this.contentNegotiatingResolver.setViewResolvers(this.viewResolvers);
		if (this.contentNegotiationManager != null) {
			this.contentNegotiatingResolver.setContentNegotiationManager(this.contentNegotiationManager);
		}
	}
	return this.contentNegotiatingResolver;
}
 
Example 4
Source File: ErrorHandlerConfiguration.java    From codeway_service with GNU General Public License v3.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
	GlobalExceptionHandler exceptionHandler = new GlobalExceptionHandler(
			errorAttributes,
			this.resourceProperties,
			this.serverProperties.getError(),
			this.applicationContext);
	exceptionHandler.setViewResolvers(this.viewResolvers);
	exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
	exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
	return exceptionHandler;
}
 
Example 5
Source File: FwGatewayErrorConfigure.java    From fw-spring-cloud with Apache License 2.0 5 votes vote down vote up
@Bean
    @Order(Ordered.HIGHEST_PRECEDENCE)
    public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
        FwGatewayExceptionHandler exceptionHandler = new FwGatewayExceptionHandler(
                errorAttributes,
                this.resourceProperties,
                this.serverProperties.getError(),
                this.applicationContext);
        exceptionHandler.setViewResolvers(this.viewResolvers);
        exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
        exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
        return exceptionHandler;
}
 
Example 6
Source File: CacheManagerCustomizerNoOverrideTest.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Order(Ordered.HIGHEST_PRECEDENCE)
@Bean
public ComponentCustomizer<EhcacheComponent> customizer() {
    return new ComponentCustomizer<EhcacheComponent>() {
        @Override
        public void customize(EhcacheComponent component) {
            component.setCacheManager(CACHE_MANAGER);
        }
    };
}
 
Example 7
Source File: CacheManagerCustomizerOverrideTest.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Order(Ordered.HIGHEST_PRECEDENCE)
@Bean
public ComponentCustomizer<EhcacheComponent> customizer() {
    return new ComponentCustomizer<EhcacheComponent>() {
        @Override
        public void customize(EhcacheComponent component) {
            component.setCacheManager(CACHE_MANAGER);
        }
    };
}
 
Example 8
Source File: RemoteCacheManagerCustomizerOverrideTest.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Order(Ordered.HIGHEST_PRECEDENCE)
@Bean
public ComponentCustomizer<InfinispanComponent> customizer() {
    return new ComponentCustomizer<InfinispanComponent>() {
        @Override
        public void customize(InfinispanComponent component) {
            component.getConfiguration().setCacheContainer(CACHE_MANAGER);
        }
    };
}
 
Example 9
Source File: EmbeddedCacheManagerCustomizerNoOverrideTest.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Order(Ordered.HIGHEST_PRECEDENCE)
@Bean
public ComponentCustomizer<InfinispanComponent> customizer() {
    return new ComponentCustomizer<InfinispanComponent>() {
        @Override
        public void customize(InfinispanComponent component) {
            component.getConfiguration().setCacheContainer(CACHE_MANAGER);
        }
    };
}
 
Example 10
Source File: ExceptionConfiguration.java    From MyShopPlus with Apache License 2.0 5 votes vote down vote up
@Primary
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ObjectProvider<List<ViewResolver>> viewResolversProvider, ServerCodecConfigurer serverCodecConfigurer) {
    JsonExceptionHandler jsonExceptionHandler = new JsonExceptionHandler();
    jsonExceptionHandler.setViewResolvers(viewResolversProvider.getIfAvailable(Collections::emptyList));
    jsonExceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters());
    jsonExceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders());
    return jsonExceptionHandler;
}
 
Example 11
Source File: SwaggerConfig.java    From sk-admin with Apache License 2.0 5 votes vote down vote up
@Bean
public AlternateTypeRuleConvention pageableConvention(final TypeResolver resolver) {
    return new AlternateTypeRuleConvention() {
        @Override
        public int getOrder() {
            return Ordered.HIGHEST_PRECEDENCE;
        }

        @Override
        public List<AlternateTypeRule> rules() {
            return newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class)));
        }
    };
}
 
Example 12
Source File: BannerListener.java    From mPass with Apache License 2.0 4 votes vote down vote up
@Override
public int getOrder() {
    return Ordered.HIGHEST_PRECEDENCE;
}
 
Example 13
Source File: EmbeddedRedisConfiguration.java    From jetlinks-community with Apache License 2.0 4 votes vote down vote up
@Override
public int getOrder() {
    return Ordered.HIGHEST_PRECEDENCE;
}
 
Example 14
Source File: GatewayConfiguration.java    From spring-cloud-sofastack-samples with Apache License 2.0 4 votes vote down vote up
/**
 * 配置SentinelGatewayBlockExceptionHandler,限流后异常处理
 * @return
 */
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public SentinelGatewayBlockExceptionHandler sentinelGatewayBlockExceptionHandler() {
    return new SentinelGatewayBlockExceptionHandler(viewResolvers, serverCodecConfigurer);
}
 
Example 15
Source File: AsyncExecutionInterceptor.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public int getOrder() {
	return Ordered.HIGHEST_PRECEDENCE;
}
 
Example 16
Source File: SwaggerConfig.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Bean
@Order(value = Ordered.HIGHEST_PRECEDENCE)
public CorsFilter swaggerCorsFilter() {
    return new SwaggerCorsFilter();
}
 
Example 17
Source File: RestTemplatePostProcessor.java    From log-trace-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public int getOrder() {
    return Ordered.HIGHEST_PRECEDENCE + 1;
}
 
Example 18
Source File: CloudSecurityInnerAspect.java    From smaker with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public int getOrder() {
	return Ordered.HIGHEST_PRECEDENCE + 1;
}
 
Example 19
Source File: SpringLoader.java    From joyrpc with Apache License 2.0 4 votes vote down vote up
@Override
public int getOrder() {
    return Ordered.HIGHEST_PRECEDENCE;
}
 
Example 20
Source File: MybatisplusAutoConfiguration.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnProperty(value = "platform.mybatis.smart-enum",havingValue = "true",matchIfMissing = true)
@Order(Ordered.HIGHEST_PRECEDENCE)
public CustomizeSqlSessionFactory customizeSqlSessionFactory(SqlSessionFactory sqlSessionFactory, ApplicationContext applicationContext){
    return new CustomizeSqlSessionFactory(typeEnumsPackage,sqlSessionFactory,applicationContext);
}