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


Java Ordered类代码示例

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


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

示例1: corsFilter

import org.springframework.core.Ordered; //导入依赖的package包/类
@Bean
FilterRegistrationBean corsFilter() {
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("*");

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

    FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setOrder(Ordered.HIGHEST_PRECEDENCE);

    return bean;
}
 
开发者ID:BakkerTom,项目名称:happy-news,代码行数:17,代码来源:AuthorizationServerConfig.java

示例2: testSort

import org.springframework.core.Ordered; //导入依赖的package包/类
@Test
public void testSort(@Mocked Ordered o1, @Mocked Ordered o2) {
  Map<String, Ordered> map = new LinkedHashMap<>();
  map.put("a", o1);
  map.put("b", o2);

  ServiceLoader<Ordered> serviceLoader = ServiceLoader.load(Ordered.class);
  Deencapsulation.setField(serviceLoader, "providers", map);
  new Expectations(ServiceLoader.class) {
    {
      o1.getOrder();
      result = -1;
      o2.getOrder();
      result = Integer.MAX_VALUE;
      ServiceLoader.load(Ordered.class);
      result = serviceLoader;
    }
  };

  Assert.assertThat(SPIServiceUtils.getSortedService(Ordered.class), Matchers.contains(o1, o2));
  Assert.assertThat(SPIServiceUtils.getPriorityHighestService(Ordered.class), Matchers.is(o1));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:23,代码来源:TestSPIServiceUtils.java

示例3: casClientInfoLoggingFilter

import org.springframework.core.Ordered; //导入依赖的package包/类
@Bean
public FilterRegistrationBean casClientInfoLoggingFilter() {
    final AuditProperties audit = casProperties.getAudit();

    final FilterRegistrationBean bean = new FilterRegistrationBean();
    bean.setFilter(new ClientInfoThreadLocalFilter());
    bean.setUrlPatterns(Collections.singleton("/*"));
    bean.setName("CAS Client Info Logging Filter");
    bean.setAsyncSupported(true);
    bean.setOrder(Ordered.HIGHEST_PRECEDENCE);

    final Map<String, String> initParams = new HashMap<>();
    if (StringUtils.isNotBlank(audit.getAlternateClientAddrHeaderName())) {
        initParams.put(ClientInfoThreadLocalFilter.CONST_IP_ADDRESS_HEADER, audit.getAlternateClientAddrHeaderName());
    }

    if (StringUtils.isNotBlank(audit.getAlternateServerAddrHeaderName())) {
        initParams.put(ClientInfoThreadLocalFilter.CONST_SERVER_IP_ADDRESS_HEADER, audit.getAlternateServerAddrHeaderName());
    }

    initParams.put(ClientInfoThreadLocalFilter.CONST_USE_SERVER_HOST_ADDRESS, String.valueOf(audit.isUseServerHostAddress()));
    bean.setInitParameters(initParams);
    return bean;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:25,代码来源:CasCoreAuditConfiguration.java

示例4: configureTicketCatalog

import org.springframework.core.Ordered; //导入依赖的package包/类
@Override
public final void configureTicketCatalog(final TicketCatalog plan) {
    LOGGER.debug("Registering core CAS protocol ticket definitions...");

    buildAndRegisterProxyTicketDefinition(plan,
            buildTicketDefinition(plan, ProxyTicket.PROXY_TICKET_PREFIX, 
                    ProxyTicketImpl.class, Ordered.HIGHEST_PRECEDENCE));

    buildAndRegisterServiceTicketDefinition(plan,
            buildTicketDefinition(plan, ServiceTicket.PREFIX, 
                    ServiceTicketImpl.class, Ordered.HIGHEST_PRECEDENCE));

    buildAndRegisterProxyGrantingTicketDefinition(plan,
            buildTicketDefinition(plan, ProxyGrantingTicket.PROXY_GRANTING_TICKET_PREFIX,
                    ProxyGrantingTicketImpl.class, Ordered.LOWEST_PRECEDENCE));

    buildAndRegisterTicketGrantingTicketDefinition(plan,
            buildTicketDefinition(plan, TicketGrantingTicket.PREFIX,
                    TicketGrantingTicketImpl.class, Ordered.LOWEST_PRECEDENCE));
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:CasCoreTicketCatalogConfiguration.java

示例5: webMvcConfigurer

import org.springframework.core.Ordered; //导入依赖的package包/类
@Bean
public WebMvcConfigurer webMvcConfigurer() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addViewControllers(ViewControllerRegistry viewControllerRegistry) {

            // 首页默认加载web端
            viewControllerRegistry.addViewController("/").setViewName("/web/index.html");
            viewControllerRegistry.addViewController("/index.html").setViewName("redirect:/");

            // web首页
            viewControllerRegistry.addViewController("/web").setViewName("/web/index.html");

            // webapp首页
            viewControllerRegistry.addViewController("/webapp").setViewName("/webapp/index.html");

            viewControllerRegistry.setOrder(Ordered.HIGHEST_PRECEDENCE);
            super.addViewControllers(viewControllerRegistry);
        }
    };
}
 
开发者ID:stephenml,项目名称:basic,代码行数:22,代码来源:Application.java

示例6: factory

import org.springframework.core.Ordered; //导入依赖的package包/类
@Bean(name = "VIFilterRegistrationBeanNew")
public org.springframework.boot.web.servlet.FilterRegistrationBean factory() {

    if(environment != null) {
        String port = environment.getProperty("server.port");
        if(port !=null) {
            System.setProperty(SysKeys.SPRINGBOOTPORTKEY, port);
        }
    }
    org.springframework.boot.web.servlet.FilterRegistrationBean filter =
            new org.springframework.boot.web.servlet.FilterRegistrationBean();
    filter.setFilter(new VIFilter());
    filter.setName("vi-filter");
    filter.addUrlPatterns(URLPATTERNS);
    filter.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD);
    filter.setAsyncSupported(true);
    filter.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return filter;
}
 
开发者ID:ctripcorp,项目名称:cornerstone,代码行数:20,代码来源:AutoConfiguration.java

示例7: requestMessageSender

import org.springframework.core.Ordered; //导入依赖的package包/类
@Bean
public JmsMessageSender requestMessageSender(@Value("${jms-sender.ring-buffer-size}") int ringBufferSize) throws JMSException {

  DisruptorJmsMessageSender messageSender = DisruptorJmsMessageSenderFactory.create(
      requestSession(),
      requestMessageProducer(),
      new ArtemisMessageDtoDupMessageDetectStrategy(),
      ringBufferSize
  );


  BeanRegisterUtils.registerSingleton(
      applicationContext,
      "RequestDtoEventDisruptorLifeCycleContainer",
      new DisruptorLifeCycleContainer("RequestDtoEventDisruptor", messageSender.getDisruptor(),
          Ordered.HIGHEST_PRECEDENCE));

  return messageSender;

}
 
开发者ID:chanjarster,项目名称:artemis-disruptor-miaosha,代码行数:21,代码来源:JmsClientConfiguration.java

示例8: doParse

import org.springframework.core.Ordered; //导入依赖的package包/类
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder) {
  String namespaces = element.getAttribute("namespaces");
  //default to application
  if (Strings.isNullOrEmpty(namespaces)) {
    namespaces = ConfigConsts.NAMESPACE_APPLICATION;
  }

  int order = Ordered.LOWEST_PRECEDENCE;
  String orderAttribute = element.getAttribute("order");

  if (!Strings.isNullOrEmpty(orderAttribute)) {
    try {
      order = Integer.parseInt(orderAttribute);
    } catch (Throwable ex) {
      throw new IllegalArgumentException(
          String.format("Invalid order: %s for namespaces: %s", orderAttribute, namespaces));
    }
  }
  PropertySourcesProcessor.addNamespaces(NAMESPACE_SPLITTER.splitToList(namespaces), order);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:22,代码来源:NamespaceHandler.java

示例9: handleUncaughtException

import org.springframework.core.Ordered; //导入依赖的package包/类
@ResponseBody
@Order(Ordered.HIGHEST_PRECEDENCE)
@ExceptionHandler(Throwable.class)
public final ResponseEntity<Result<String>> handleUncaughtException(final Throwable exception, final WebRequest
        request) {
    // adds information about encountered error to application log
    LOG.error(MessageHelper.getMessage("logger.error", request.getDescription(true)), exception);
    HttpStatus code = HttpStatus.OK;

    String message;
    if (exception instanceof FileNotFoundException) {
        // any details about real path of a resource should be normally prevented to send to the client
        message = MessageHelper.getMessage("error.io.not.found");
    } else if (exception instanceof DataAccessException) {
        // any details about data access error should be normally prevented to send to the client,
        // as its message can contain information about failed SQL query or/and database schema
        if (exception instanceof BadSqlGrammarException) {
            // for convenience we need to provide detailed information about occurred BadSqlGrammarException,
            // but it can be retrieved
            SQLException root = ((BadSqlGrammarException) exception).getSQLException();
            if (root.getNextException() != null) {
                LOG.error(MessageHelper.getMessage("logger.error.root.cause", request.getDescription(true)),
                    root.getNextException());
            }
            message = MessageHelper.getMessage("error.sql.bad.grammar");
        } else {
            message = MessageHelper.getMessage("error.sql");
        }
    } else if (exception instanceof UnauthorizedClientException) {
        message = exception.getMessage();
        code = HttpStatus.UNAUTHORIZED;
    } else {
        message = exception.getMessage();
    }

    return new ResponseEntity<>(Result.error(StringUtils.defaultString(StringUtils.trimToNull(message),
                                   MessageHelper.getMessage("error" + ".default"))), code);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:39,代码来源:ExceptionHandlerAdvice.java

示例10: initCorsFilter

import org.springframework.core.Ordered; //导入依赖的package包/类
/**
 * CORS:
 * <p>
 * Do not do any of below, which are the wrong way to attempt solving the ajax problem:
 * - http.authorizeRequests().antMatchers(HttpMethod.OPTIONS, "/**").permitAll();
 * - web.ignoring().antMatchers(HttpMethod.OPTIONS)
 * <p>
 * Global CORS configuration
 * https://spring.io/blog/2015/06/08/cors-support-in-spring-framework
 * https://docs.spring.io/spring-security/site/docs/current/reference/html/cors.html
 * <p>
 * Solution 1
 * add CrossOrigin annotation to Controller class or methods
 * <p>
 * Solution 2
 * override addCorsMappings(CorsRegistry registry) method of WebMvcConfigurerAdapter class
 * <p>
 * <p>
 * The follow method will override CORS Configuration provided by Spring MVC.
 */
@Bean
public FilterRegistrationBean initCorsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();

    // setAllowCredentials(true) is important, otherwise:
    // The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
    config.setAllowCredentials(true);

    // setAllowedHeaders is important! Without it, OPTIONS preflight request
    // will fail with 403 Invalid CORS request
    config.setAllowedHeaders(ImmutableList.of("Authorization", "Cache-Control", "Content-Type"));

    config.addAllowedMethod("*");

    String origins = this.applicationConfig.getAllowedOrigins();
    if (origins != null && !"".equals(origins)) {
        config.setAllowedOrigins(Arrays.asList(StringHelper.splitWithoutWhitespace(origins, ",")));
    }
    source.registerCorsConfiguration("/**", config);
    FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return bean;
}
 
开发者ID:bndynet,项目名称:web-framework-for-java,代码行数:45,代码来源:WebSecurityConfig.java

示例11: toString

import org.springframework.core.Ordered; //导入依赖的package包/类
@Override
public String toString() {
	StringBuilder sb = new StringBuilder();
	Advice advice = this.advisor.getAdvice();
	sb.append(ClassUtils.getShortName(advice.getClass()));
	sb.append(": ");
	if (this.advisor instanceof Ordered) {
		sb.append("order ").append(((Ordered) this.advisor).getOrder()).append(", ");
	}
	if (advice instanceof AbstractAspectJAdvice) {
		AbstractAspectJAdvice ajAdvice = (AbstractAspectJAdvice) advice;
		sb.append(ajAdvice.getAspectName());
		sb.append(", declaration order ");
		sb.append(ajAdvice.getDeclarationOrder());
	}
	return sb.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:AspectJAwareAdvisorAutoProxyCreator.java

示例12: addViewControllers

import org.springframework.core.Ordered; //导入依赖的package包/类
@Override
public void addViewControllers(final ViewControllerRegistry registry) {
    super.addViewControllers(registry);

    registry.addViewController("/login/form")
            .setViewName("login");
    registry.addViewController("/errors/403")
            .setViewName("/errors/403");

    registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:12,代码来源:WebMvcConfig.java

示例13: delegatingFilterProxyRegistrationBean

import org.springframework.core.Ordered; //导入依赖的package包/类
@Bean
DelegatingFilterProxyRegistrationBean delegatingFilterProxyRegistrationBean() {
  DelegatingFilterProxyRegistrationBean bean = new DelegatingFilterProxyRegistrationBean("traceLoggingFilter");

  bean.setDispatcherTypes(ASYNC, ERROR, FORWARD, INCLUDE, REQUEST);
  bean.setOrder(Ordered.LOWEST_PRECEDENCE);
  return bean;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:9,代码来源:LoggingFilterConfig.java

示例14: handleSomethingHasFuckedUp

import org.springframework.core.Ordered; //导入依赖的package包/类
@Async
@Order(Ordered.LOWEST_PRECEDENCE)
@EventListener
void handleSomethingHasFuckedUp(final SomethingHasFuckedUpEvent event) {
    // We caught an unrecoverable exception in a thread, we better stop right now.
    logger.error("Event SomethingHasFuckedUpEvent caught.", event.getException());
    // Stop the application
    SpringApplication.exit(appContext, () -> 42);
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:10,代码来源:CoreEventListener.java

示例15: addViewControllers

import org.springframework.core.Ordered; //导入依赖的package包/类
@Override
public void addViewControllers(final ViewControllerRegistry registry) {
    registry.addViewController("/ui").setViewName("redirect:ui/");
    registry.addViewController("/ui/").setViewName("forward:index.html");
    registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
    super.addViewControllers(registry);
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:8,代码来源:WebMvcConfiguration.java


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