Java Code Examples for org.springframework.context.annotation.DependsOn

The following examples show how to use org.springframework.context.annotation.DependsOn. These examples are extracted from open source projects. 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 Project: WeBASE-Front   Source File: Web3ApiService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * add web3j from chain and remove web3j not in chain
 * @param groupIdList
 * @throws FrontException
 */
@DependsOn("encryptType")
public void refreshWeb3jMap(List<String> groupIdList) throws FrontException {
    log.debug("refreshWeb3jMap groupIdList:{}", groupIdList);
    // if localGroupIdList not contain group in groupList from chain, add it
    groupIdList.stream()
        .filter(groupId ->
            web3jMap.get(Integer.parseInt(groupId)) == null)
        .forEach(group2Init ->
            initWeb3j(Integer.parseInt(group2Init)));

    Set<Integer> localGroupIdList = web3jMap.keySet();
    log.debug("refreshWeb3jMap localGroupList:{}", localGroupIdList);
    // if local web3j map contains group that not in groupList from chain
    // remove it from local web3j map
    localGroupIdList.stream()
        // not contains in groupList from chain
        .filter(groupId ->
            !groupIdList.contains(String.valueOf(groupId)))
        .forEach(group2Remove ->
            web3jMap.remove(group2Remove));
}
 
Example 2
Source Project: ZTuoExchange_framework   Source File: ShiroConfig.java    License: MIT License 6 votes vote down vote up
/**
 * ShiroFilterFactoryBean 处理拦截资源文件问题。
 *
 * @param securityManager
 * @return
 */

@Bean(name="shiroFilter")
@DependsOn({"securityManager"})
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
    log.info("ShiroConfiguration.shirFilter()");
    ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    shiroFilterFactoryBean.setSecurityManager(securityManager);
    //拦截器.
    Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
    filterChainDefinitionMap.put("/captcha", "anon");
    filterChainDefinitionMap.put("/admin/code/**", "anon");
    filterChainDefinitionMap.put("admin/**/page-query", "user");
    filterChainDefinitionMap.put("/admin/employee/logout", "logout");
    filterChainDefinitionMap.put("admin/**/detail", "authc");
    shiroFilterFactoryBean.setUnauthorizedUrl("/403");
    /*shiroFilterFactoryBean.setU("/403");*/
    shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);

    return shiroFilterFactoryBean;
}
 
Example 3
Source Project: sbp   Source File: ImportDataConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
@ConditionalOnProperty(prefix = "spring.flyway", name = "import-data")
@DependsOn("flywayInitializer")
public FlywayDataImporter flywayDataImporter() {
    FluentConfiguration flywayConf = plugin != null
            ? Flyway.configure(plugin.getWrapper().getPluginClassLoader()) : Flyway.configure();
    flywayConf.configuration(flyway.getConfiguration());
    flywayConf.baselineVersion("0");
    flywayConf.baselineOnMigrate(true);
    flywayConf.locations("classpath:/db_data");
    flywayConf.table("_db_data");
    Flyway importDataFlyway = new Flyway(flywayConf);
    FlywayDataImporter importer = new FlywayDataImporter(importDataFlyway);
    importer.setOrder(Ordered.LOWEST_PRECEDENCE);
    return importer;
}
 
Example 4
Source Project: ZTuoExchange_framework   Source File: ShiroConfig.java    License: MIT License 6 votes vote down vote up
/**
 * ShiroFilterFactoryBean 处理拦截资源文件问题。
 *
 * @param securityManager
 * @return
 */

@Bean(name="shiroFilter")
@DependsOn({"securityManager"})
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
    log.info("ShiroConfiguration.shirFilter()");
    ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    shiroFilterFactoryBean.setSecurityManager(securityManager);
    //拦截器.
    Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
    filterChainDefinitionMap.put("/captcha", "anon");
    filterChainDefinitionMap.put("/admin/code/**", "anon");
    filterChainDefinitionMap.put("admin/**/page-query", "user");
    filterChainDefinitionMap.put("/admin/employee/logout", "logout");
    filterChainDefinitionMap.put("admin/**/detail", "authc");
    shiroFilterFactoryBean.setUnauthorizedUrl("/403");
    /*shiroFilterFactoryBean.setU("/403");*/
    shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);

    return shiroFilterFactoryBean;
}
 
Example 5
Source Project: ambari-logsearch   Source File: ApplicationConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
@DependsOn("logFeederSecurityConfig")
@Conditional(NonCloudStorageCondition.class)
public LogSearchConfigLogFeeder logSearchConfigLogFeeder() throws Exception {
  if (logFeederProps.isUseLocalConfigs()) {
    LogSearchConfigLogFeeder logfeederConfig = LogSearchConfigFactory.createLogSearchConfigLogFeeder(
      Maps.fromProperties(logFeederProps.getProperties()),
      logFeederProps.getClusterName(),
      LogSearchConfigLogFeederLocal.class, false);
    logfeederConfig.setLogLevelFilterManager(logLevelFilterManager());
    return logfeederConfig;
  } else {
    return LogSearchConfigFactory.createLogSearchConfigLogFeeder(
      Maps.fromProperties(logFeederProps.getProperties()),
      logFeederProps.getClusterName(),
      LogSearchConfigLogFeederZK.class, false);
  }
}
 
Example 6
Source Project: rqueue   Source File: RqueueListenerAutoConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@DependsOn("rqueueConfig")
@ConditionalOnMissingBean
public RqueueMessageListenerContainer rqueueMessageListenerContainer(
    RqueueMessageHandler rqueueMessageHandler) {
  if (simpleRqueueListenerContainerFactory.getRqueueMessageHandler() == null) {
    simpleRqueueListenerContainerFactory.setRqueueMessageHandler(rqueueMessageHandler);
  }
  return simpleRqueueListenerContainerFactory.createMessageListenerContainer();
}
 
Example 7
Source Project: rqueue   Source File: RqueueListenerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@DependsOn("rqueueConfig")
public RqueueMessageListenerContainer rqueueMessageListenerContainer(
    RqueueMessageHandler rqueueMessageHandler) {
  if (simpleRqueueListenerContainerFactory.getRqueueMessageHandler() == null) {
    simpleRqueueListenerContainerFactory.setRqueueMessageHandler(rqueueMessageHandler);
  }
  return simpleRqueueListenerContainerFactory.createMessageListenerContainer();
}
 
Example 8
Source Project: rqueue   Source File: RqueueListenerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Conditional(MetricsEnabled.class)
@DependsOn({"meterRegistry", "rqueueMetricsProperties"})
public RqueueMetrics rqueueMetrics(
    @Qualifier("stringRqueueRedisTemplate") RqueueRedisTemplate<String> rqueueRedisTemplate) {
  QueueCounter queueCounter = new QueueCounter();
  return new RqueueMetrics(rqueueRedisTemplate, queueCounter);
}
 
Example 9
@Test
public void dependsOnMetadataIsPropagated() {
	@Configuration class Config {
		@Bean() @DependsOn({"bar", "baz"}) Object foo() { return null; }
	}

	assertArrayEquals("dependsOn metadata was not propagated",
			new String[] {"bar", "baz"}, beanDef(Config.class).getDependsOn());
}
 
Example 10
Source Project: dts-shop   Source File: ShiroConfig.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public static DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
	DefaultAdvisorAutoProxyCreator creator = new DefaultAdvisorAutoProxyCreator();
	creator.setProxyTargetClass(true);
	return creator;
}
 
Example 11
Source Project: ZTuoExchange_framework   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * shiro缓存管理器;
 * 需要注入对应的其它的实体类中:
 * 安全管理器:securityManager
 *
 * @return
 */
@Bean(name="ehCacheManager")
@DependsOn("lifecycleBeanPostProcessor")
public EhCacheManager ehCacheManager() {
    log.info("ShiroConfiguration.getEhCacheManager()");
    EhCacheManager cacheManager = new EhCacheManager();
    cacheManager.setCacheManagerConfigFile("classpath:ehcache-shiro.xml");
    return cacheManager;
}
 
Example 12
Source Project: ZTuoExchange_framework   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * cookie 管理器
 * @return
 */
@Bean(name="cookieRememberMeManager")
@DependsOn({"simpleCookie"})
public CookieRememberMeManager getCookieRememberMeManager(SimpleCookie simpleCookie){
    CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
    cookieRememberMeManager.setCookie(simpleCookie);
    /**
     * 设置 rememberMe cookie 的密钥 ,不设置 很可能:javax.crypto.BadPaddingException: Given final block not properly padded
     */
    cookieRememberMeManager.setCipherKey(Base64.decode("2AvVhdsgUs0FSA3SDFAdag=="));
    return cookieRememberMeManager ;
}
 
Example 13
Source Project: ZTuoExchange_framework   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * @DependOn  :在初始化 defaultWebSecurityManager 实例前 强制先初始化 adminRealm ,ehCacheManager。。。。。
 * @param realm
 * @param ehCacheManager
 * @param cookieRememberMeManager
 * @return
 */

@Bean(name = "securityManager")
@DependsOn({"adminRealm","ehCacheManager","cookieRememberMeManager"})
public DefaultWebSecurityManager getDefaultWebSecurityManager(AdminRealm realm, EhCacheManager ehCacheManager,CookieRememberMeManager cookieRememberMeManager) {
    DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
    //设置realm.
    defaultWebSecurityManager.setRealm(realm);
    defaultWebSecurityManager.setCacheManager(ehCacheManager);
    defaultWebSecurityManager.setRememberMeManager(cookieRememberMeManager);
    return defaultWebSecurityManager;
}
 
Example 14
Source Project: ZTuoExchange_framework   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * 由Advisor决定对哪些类的方法进行AOP代理。
 * @return
 */
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
    DefaultAdvisorAutoProxyCreator defaultAAP = new DefaultAdvisorAutoProxyCreator();
    defaultAAP.setProxyTargetClass(true);
    return defaultAAP;
}
 
Example 15
Source Project: frpMgr   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * Shiro 过滤器代理配置
 */
@Bean
@DependsOn({ "lifecycleBeanPostProcessor" })
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
	DefaultAdvisorAutoProxyCreator bean = new DefaultAdvisorAutoProxyCreator();
	bean.setProxyTargetClass(true);
	return bean;
}
 
Example 16
Source Project: sbp   Source File: DemoApp.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
@DependsOn("multiApplicationContextProviderRegister")
public ModelMapper modelMapper(ApplicationContext applicationContext) {
    ModelMapper mapper = new ModelMapper();
    mapper.getConfiguration().setSourceNameTokenizer(NameTokenizers.CAMEL_CASE)
            .addValueReader(new RecordValueReader());
    mapper.addConverter(new IdsConverter());
    return mapper;
}
 
Example 17
Source Project: springboot-learn   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * 开启Shiro的注解(如@RequiresRoles,@RequiresPermissions),需借助SpringAOP扫描使用Shiro注解的类,并在必要时进行安全逻辑验证 * 配置以下两个bean(DefaultAdvisorAutoProxyCreator(可选)和AuthorizationAttributeSourceAdvisor)即可实现此功能
 */
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
    DefaultAdvisorAutoProxyCreator creator = new DefaultAdvisorAutoProxyCreator();
    creator.setProxyTargetClass(true);
    return creator;
}
 
Example 18
Source Project: ZTuoExchange_framework   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * shiro缓存管理器;
 * 需要注入对应的其它的实体类中:
 * 安全管理器:securityManager
 *
 * @return
 */
@Bean(name="ehCacheManager")
@DependsOn("lifecycleBeanPostProcessor")
public EhCacheManager ehCacheManager() {
    log.info("ShiroConfiguration.getEhCacheManager()");
    EhCacheManager cacheManager = new EhCacheManager();
    cacheManager.setCacheManagerConfigFile("classpath:ehcache-shiro.xml");
    return cacheManager;
}
 
Example 19
Source Project: ZTuoExchange_framework   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * cookie 管理器
 * @return
 */
@Bean(name="cookieRememberMeManager")
@DependsOn({"simpleCookie"})
public CookieRememberMeManager getCookieRememberMeManager(SimpleCookie simpleCookie){
    CookieRememberMeManager cookieRememberMeManager = new CookieRememberMeManager();
    cookieRememberMeManager.setCookie(simpleCookie);
    /**
     * 设置 rememberMe cookie 的密钥 ,不设置 很可能:javax.crypto.BadPaddingException: Given final block not properly padded
     */
    cookieRememberMeManager.setCipherKey(Base64.decode("2AvVhdsgUs0FSA3SDFAdag=="));
    return cookieRememberMeManager ;
}
 
Example 20
Source Project: ZTuoExchange_framework   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * @DependOn  :在初始化 defaultWebSecurityManager 实例前 强制先初始化 adminRealm ,ehCacheManager。。。。。
 * @param realm
 * @param ehCacheManager
 * @param cookieRememberMeManager
 * @return
 */

@Bean(name = "securityManager")
@DependsOn({"adminRealm","ehCacheManager","cookieRememberMeManager"})
public DefaultWebSecurityManager getDefaultWebSecurityManager(AdminRealm realm, EhCacheManager ehCacheManager,CookieRememberMeManager cookieRememberMeManager) {
    DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
    //设置realm.
    defaultWebSecurityManager.setRealm(realm);
    defaultWebSecurityManager.setCacheManager(ehCacheManager);
    defaultWebSecurityManager.setRememberMeManager(cookieRememberMeManager);
    return defaultWebSecurityManager;
}
 
Example 21
Source Project: ZTuoExchange_framework   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * 由Advisor决定对哪些类的方法进行AOP代理。
 * @return
 */
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
    DefaultAdvisorAutoProxyCreator defaultAAP = new DefaultAdvisorAutoProxyCreator();
    defaultAAP.setProxyTargetClass(true);
    return defaultAAP;
}
 
Example 22
/**
 * PlatformTransactionManager
 *
 * @return PlatformTransactionManager
 * @throws Throwable throwable
 */
@Bean(name = "txManager")
@DependsOn({"userTransaction", "atomikosTransactionManager"})
public PlatformTransactionManager transactionManager() throws Throwable {
    UserTransaction userTransaction = userTransaction();
    TransactionManager atomikosTransactionManager = atomikosTransactionManager();
    return new JtaTransactionManager(userTransaction, atomikosTransactionManager);
}
 
Example 23
@Test
public void dependsOnMetadataIsPropagated() {
	@Configuration class Config {
		@Bean() @DependsOn({"bar", "baz"}) Object foo() { return null; }
	}

	assertArrayEquals("dependsOn metadata was not propagated",
			new String[] {"bar", "baz"}, beanDef(Config.class).getDependsOn());
}
 
Example 24
Source Project: jeesupport   Source File: AbsDwrConfig.java    License: MIT License 5 votes vote down vote up
@SuppressWarnings( "unchecked" )
@Bean
@DependsOn( "commonConfig" )
public ServletRegistrationBean servletRegistrationBean() {
    String dwr_url = CommonConfig.getString("jees.webs.dwr.url", "/dwr" );
    DwrSpringServlet servlet = new DwrSpringServlet();
    ServletRegistrationBean registrationBean = new ServletRegistrationBean(servlet, dwr_url + "/*");
    registrationBean.addInitParameter("debug", CommonConfig.getString("jees.webs.dwr.debug", "false" ));
    return registrationBean;
}
 
Example 25
Source Project: Spring   Source File: ServerJmxConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@DependsOn("registry")
public ConnectorServerFactoryBean connectorServer() throws MalformedObjectNameException {
	ConnectorServerFactoryBean connectorServerFactoryBean = new ConnectorServerFactoryBean();
	connectorServerFactoryBean.setObjectName("connector:name=rmi");
	connectorServerFactoryBean.setServiceUrl("service:jmx:rmi://localhost/jndi/rmi://localhost:1099/connector");
	return connectorServerFactoryBean;
}
 
Example 26
Source Project: Goku.Framework.CoreUI   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * ShiroRealm,这是个自定义的认证类,继承自AuthorizingRealm,
 * 负责用户的认证和权限的处理,可以参考JdbcRealm的实现。
 */
@Bean(name = "shiroRealm")
@DependsOn("lifecycleBeanPostProcessor")
public ShiroRealm shiroRealm() {
    ShiroRealm realm = new ShiroRealm();
    realm.setCacheManager(ehCacheManager());
    return realm;
}
 
Example 27
Source Project: Goku.Framework.CoreUI   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
/**
 * DefaultAdvisorAutoProxyCreator,Spring的一个bean,由Advisor决定对哪些类的方法进行AOP代理。
 */
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
    DefaultAdvisorAutoProxyCreator defaultAAP = new DefaultAdvisorAutoProxyCreator();
    defaultAAP.setProxyTargetClass(true);
    return defaultAAP;
}
 
Example 28
Source Project: springboot-shiro   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
    DefaultAdvisorAutoProxyCreator creator = new DefaultAdvisorAutoProxyCreator();
    creator.setProxyTargetClass(true);
    return creator;
}
 
Example 29
Source Project: litemall   Source File: ShiroConfig.java    License: MIT License 5 votes vote down vote up
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public static DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
    DefaultAdvisorAutoProxyCreator creator = new DefaultAdvisorAutoProxyCreator();
    creator.setProxyTargetClass(true);
    return creator;
}
 
Example 30
Source Project: ambari-logsearch   Source File: ApplicationConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Conditional(CloudStorageCondition.class)
@DependsOn({"cloudInputConfigHandler"})
public InputConfigUploader cloudInputConfigUploader() throws Exception {
  return new InputConfigUploader("Cloud Input Config Loader", cloudLogSearchLogFeederConfig(),
    cloudInputConfigManager(),null);
}