Refine search
/** * @author zhouhao */ @Configuration @Order @ComponentScan({"org.hswebframework.web.service.form.simple" , "org.hswebframework.web.controller.form"}) public class DynamicFormAutoConfiguration implements CommandLineRunner { private Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private DynamicFormService dynamicFormService; @Override public void run(String... args) throws Exception { try { dynamicFormService.deployAllFromLog(); } catch (Exception e) { logger.error("deploy form error", e); } } }
private static int resolveOrder(Method method) { Order ann = AnnotatedElementUtils.findMergedAnnotation(method, Order.class); return (ann != null ? ann.value() : 0); }
@Bean @Order(Ordered.HIGHEST_PRECEDENCE) public WebMvcConfigurer webUserTokenInterceptorConfigurer(UserTokenManager userTokenManager, AopMethodAuthorizeDefinitionParser parser, List<UserTokenParser> userTokenParser) { return new WebMvcConfigurerAdapter() { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new WebUserTokenInterceptor(userTokenManager, userTokenParser, parser)); super.addInterceptors(registry); } }; }
@Configuration @Order(1) static class SingletonBeanConfig { public @Bean Foo foo() { return new Foo(); } public @Bean Bar bar() { return new Bar(foo()); } }
@Bean(destroyMethod = "destroy") @ConditionalOnBean(DefaultMQProducer.class) @ConditionalOnMissingBean(name = "rocketMQTemplate") @Order(2) public RocketMQTemplate rocketMQTemplate(DefaultMQProducer mqProducer, @Autowired(required = false) @Qualifier("rocketMQMessageObjectMapper") ObjectMapper objectMapper) { RocketMQTemplate rocketMQTemplate = new RocketMQTemplate(); rocketMQTemplate.setProducer(mqProducer); if (Objects.nonNull(objectMapper)) { rocketMQTemplate.setObjectMapper(objectMapper); } return rocketMQTemplate; }
@Order(99) @Profile("auth") @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) static class SpringSecurityConfigurer extends WebSecurityConfigurerAdapter { public static final String USER_ROLE = "user"; @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.headers().frameOptions().sameOrigin(); http.authorizeRequests() .antMatchers("/openapi/**", "/vendor/**", "/styles/**", "/scripts/**", "/views/**", "/img/**").permitAll() .antMatchers("/**").hasAnyRole(USER_ROLE); http.formLogin().loginPage("/signin").permitAll().failureUrl("/signin?#/error").and().httpBasic(); SimpleUrlLogoutSuccessHandler urlLogoutHandler = new SimpleUrlLogoutSuccessHandler(); urlLogoutHandler.setDefaultTargetUrl("/signin?#/logout"); http.logout().logoutUrl("/user/logout").invalidateHttpSession(true).clearAuthentication(true) .logoutSuccessHandler(urlLogoutHandler); http.exceptionHandling().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/signin")); } }
/** * Used by {@link SpringFactoriesLoaderTests} * * @author Arjen Poutsma */ @Order(1) public class MyDummyFactory1 implements DummyFactory { @Override public String getString() { return "Foo"; } }
@Configuration @Order(1) class SingletonBeanConfig { public SingletonBeanConfig(ConfigWithOrderedInnerClasses other) { } public @Bean Foo foo() { return new Foo(); } public @Bean Bar bar() { return new Bar(foo()); } }
/** * Created by shenhongxi on 2017/6/29. */ @Component @Order(value = 1) public class InitRunner implements CommandLineRunner { private final Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private UserMapper userMapper; @Autowired private MessageService messageService; @Override public void run(String... args) throws Exception { logger.info("init......createIfNotExistsTable"); userMapper.createIfNotExistsTable(); for (int i = 0; i < 10; i++) { messageService.send("message" + i); } } }
@Order(99) @Profile("ldap") @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true)
@Order(1) public static class B implements Runnable{ @Override public void run() { } }