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


Java InitializingBean类代码示例

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


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

示例1: afterPropertiesSet

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
	BeanWrapper bw = new BeanWrapperImpl(ThreadPoolTaskExecutor.class);
	determinePoolSizeRange(bw);
	if (this.queueCapacity != null) {
		bw.setPropertyValue("queueCapacity", this.queueCapacity);
	}
	if (this.keepAliveSeconds != null) {
		bw.setPropertyValue("keepAliveSeconds", this.keepAliveSeconds);
	}
	if (this.rejectedExecutionHandler != null) {
		bw.setPropertyValue("rejectedExecutionHandler", this.rejectedExecutionHandler);
	}
	if (this.beanName != null) {
		bw.setPropertyValue("threadNamePrefix", this.beanName + "-");
	}
	this.target = (TaskExecutor) bw.getWrappedInstance();
	if (this.target instanceof InitializingBean) {
		((InitializingBean) this.target).afterPropertiesSet();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:TaskExecutorFactoryBean.java

示例2: afterPropertiesSet

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
开发者ID:klask-io,项目名称:klask-io,代码行数:8,代码来源:ExceptionHandlingAsyncTaskExecutor.java

示例3: configureHandlerExceptionResolvers

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@Override
protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
	if (handlerExceptionResolvers == null) {
		return;
	}
	for (HandlerExceptionResolver resolver : handlerExceptionResolvers) {
		if (resolver instanceof ApplicationContextAware) {
			((ApplicationContextAware) resolver).setApplicationContext(getApplicationContext());
		}
		if (resolver instanceof InitializingBean) {
			try {
				((InitializingBean) resolver).afterPropertiesSet();
			}
			catch (Exception ex) {
				throw new IllegalStateException("Failure from afterPropertiesSet", ex);
			}
		}
		exceptionResolvers.add(resolver);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:StandaloneMockMvcBuilder.java

示例4: createListenerContainer

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
/**
 * Create and start a new container using the specified factory.
 */
protected MessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint,
		JmsListenerContainerFactory<?> factory) {

	MessageListenerContainer listenerContainer = factory.createListenerContainer(endpoint);

	if (listenerContainer instanceof InitializingBean) {
		try {
			((InitializingBean) listenerContainer).afterPropertiesSet();
		}
		catch (Exception ex) {
			throw new BeanInitializationException("Failed to initialize message listener container", ex);
		}
	}

	int containerPhase = listenerContainer.getPhase();
	if (containerPhase < Integer.MAX_VALUE) {  // a custom phase value
		if (this.phase < Integer.MAX_VALUE && this.phase != containerPhase) {
			throw new IllegalStateException("Encountered phase mismatch between container factory definitions: " +
					this.phase + " vs " + containerPhase);
		}
		this.phase = listenerContainer.getPhase();
	}

	return listenerContainer;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:JmsListenerEndpointRegistry.java

示例5: parseTag

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
public static <T> T parseTag(Class<T> clazz, Spec spec) {
    T object = Reflect.on(clazz).create().get();

    if (object instanceof SpecAppliable)
        ((SpecAppliable) object).applySpec(spec);

    if (object instanceof InitializingBean) {
        try {
            ((InitializingBean) object).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    return object;
}
 
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:17,代码来源:Specs.java

示例6: createBean

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
public static <T> T createBean(Class<T> clazz, Settings settings, ApplicationContext applicationContext) throws Exception {
	if (clazz == null || clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) {
		return null;
	}

	T bean = clazz.newInstance();

	if (bean instanceof SettingsAware) {
		((SettingsAware) bean).setSettings(settings);
	}

	if (bean instanceof ApplicationContextAware) {
		((ApplicationContextAware) bean).setApplicationContext(applicationContext);
	}

	if (bean instanceof InitializingBean) {
		((InitializingBean) bean).afterPropertiesSet();
	}

	return bean;
}
 
开发者ID:iceize,项目名称:netty-http-3.x,代码行数:22,代码来源:BeanUtils.java

示例7: init

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@Bean
InitializingBean init(
        final IdentityService identityService) {
    return new InitializingBean() {
        @Override
        public void afterPropertiesSet() throws Exception {

            // install groups & users
            Group userGroup = group("user");
            Group adminGroup = group("admin");

            User joram = user("jbarrez", "Joram", "Barrez");
            identityService.createMembership(joram.getId(), userGroup.getId());
            identityService.createMembership(joram.getId(), adminGroup.getId());

            User josh = user("jlong", "Josh", "Long");
            identityService.createMembership(josh.getId(), userGroup.getId());
        }
    };
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:21,代码来源:SecurityAutoConfigurationTest.java

示例8: createFunctionExclusionGroups

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@Override
protected FunctionExclusionGroups createFunctionExclusionGroups() {
  // TODO: The exclusion groups could be exposed over the network (sending the function identifier) and cached
  final String exclusionGroups = getCommandLine().getOptionValue(EXCLUSION_GROUPS_OPTION);
  if (exclusionGroups != null) {
    try {
      final Class<?> exclusionGroupsClass = ClassUtils.loadClass(exclusionGroups);
      Object groupsObject = exclusionGroupsClass.newInstance();
      if (groupsObject instanceof InitializingBean) {
        ((InitializingBean) groupsObject).afterPropertiesSet();
      }
      if (groupsObject instanceof FactoryBean) {
        groupsObject = ((FactoryBean<?>) groupsObject).getObject();
      }
      if (groupsObject instanceof FunctionExclusionGroups) {
        return (FunctionExclusionGroups) groupsObject;
      }
      throw new IllegalArgumentException("Couldn't set exclusion groups to " + exclusionGroups + " (got " + groupsObject + ")");
    } catch (Exception e) {
      throw new OpenGammaRuntimeException("Error loading exclusion groups", e);
    }
  }
  return null;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:25,代码来源:FindViewAmbiguities.java

示例9: getCurrencyInfo

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
protected <T> Map<String, T> getCurrencyInfo(final Function<CurrencyInfo, T> filter) {
  final Map<String, T> result = new HashMap<String, T>();
  for (final Map.Entry<String, CurrencyInfo> e : getPerCurrencyInfo().entrySet()) {
    final T entry = filter.apply(e.getValue());
    if (entry instanceof InitializingBean) {
      try {
        ((InitializingBean) entry).afterPropertiesSet();
      } catch (final Exception ex) {
        s_logger.debug("Skipping {}", e.getKey());
        s_logger.trace("Caught exception", e);
        continue;
      }
    }
    if (entry != null) {
      result.put(e.getKey(), entry);
    }
  }
  return result;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:StandardFunctionConfiguration.java

示例10: getCurrencyPairInfo

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
protected <T> Map<Pair<String, String>, T> getCurrencyPairInfo(final Function<CurrencyPairInfo, T> filter) {
  final Map<Pair<String, String>, T> result = new HashMap<Pair<String, String>, T>();
  for (final Map.Entry<Pair<String, String>, CurrencyPairInfo> e : getPerCurrencyPairInfo().entrySet()) {
    final T entry = filter.apply(e.getValue());
    if (entry instanceof InitializingBean) {
      try {
        ((InitializingBean) entry).afterPropertiesSet();
      } catch (final Exception ex) {
        s_logger.debug("Skipping {}", e.getKey());
        s_logger.trace("Caught exception", e);
        continue;
      }
    }
    if (entry != null) {
      result.put(e.getKey(), entry);
    }
  }
  return result;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:StandardFunctionConfiguration.java

示例11: clientsCorrelationInitializer

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@Bean
public InitializingBean clientsCorrelationInitializer(final RequestCorrelationProperties properties) {

    return new InitializingBean() {
        @Override
        public void afterPropertiesSet() throws Exception {

            if(clients != null) {
                for(InterceptingHttpAccessor client : clients) {
                    final List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(client.getInterceptors());
                    interceptors.add(new ClientHttpRequestCorrelationInterceptor(properties));
                    client.setInterceptors(interceptors);
                }
            }
        }
    };
}
 
开发者ID:jmnarloch,项目名称:request-correlation-spring-cloud-starter,代码行数:18,代码来源:ClientHttpCorrelationConfiguration.java

示例12: createAdapter

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
private TimestampPair createAdapter(String ip, int port, String user, String password) {
    CobarAdapter adapter = null;
    try {
        DataSource ds = dsFactory.createDataSource(ip, port, user, password);
        adapter = new CobarAdapter();
        adapter.setDataSource(ds);
        ((InitializingBean) adapter).afterPropertiesSet();
        return new TimestampPair(adapter);
    } catch (Exception exception) {
        logger.error("ip=" + ip + ", port=" + port, exception);
        try {
            adapter.destroy();
        } catch (Exception e) {
        }
        throw new RuntimeException(exception);
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:AdapterDelegate.java

示例13: autowireAndInitialize

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
private void autowireAndInitialize(ServletRequest req, Map<String, Object> contexts) {
    ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(req.getServletContext());
    AutowireCapableBeanFactory autowirer = appContext.getAutowireCapableBeanFactory();
    for (Map.Entry<String,Object> entry : contexts.entrySet()) {
        Object context = entry.getValue();
        autowirer.autowireBean(context);
        try {
            if (context instanceof InitializingBean) {
                ((InitializingBean) context).afterPropertiesSet();
            }
        } catch (Exception e) {
            logger.warn("Invocation of init method failed of context: " + entry.getKey(), e);
        }

    }
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:17,代码来源:CPESessionContextIntegrationFilter.java

示例14: populateData

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@Bean
InitializingBean populateData(final UserService userService) {
    return () -> {
        userService.deleteAll();
        userService.persist(User.builder().login("malysz").name("adam").salary(new BigDecimal(306)).build());
        log.info(" {}", userService.persist(User.builder().login("borowiec").name("przodownik").salary(new BigDecimal(100)).build()));
        log.info(" {}", userService.persist(User.builder().login("borowiec").name("aga").salary(new BigDecimal(10)).build()));
        log.info(" {}", userService.persist(User.builder().login("borowiec").name("kalina").salary(new BigDecimal(30)).build()));
        log.info(" {}", userService.persist(User.builder().login("tyson").name("iron mike").salary(new BigDecimal(3234)).build()));
        log.info(" {}", userService.persist(User.builder().login("rossi").name("the doctor").salary(new BigDecimal(2000)).build()));

        log.info(" {}", userService.persist(new User("kazimierczak", "juz", new BigDecimal(100))));
        log.info(" {}", userService.persist(new User("aleksandrowicz", "dawid", new BigDecimal(10))));
        log.info(" {}", userService.persist(new User("barszcz", "mariusz", new BigDecimal(30))));
        log.info(" {}", userService.persist(new User("bogadanski", "pawel", new BigDecimal(3000))));
        log.info(" {}", userService.persist(new User("chudzikowska", "sylwia", new BigDecimal(2000))));

        log.info(" {}", userService.persist(new User("swietojanski", "przemyslaw", new BigDecimal(100))));
        log.info(" {}", userService.persist(new User("zurek", "marcin", new BigDecimal(10))));
        log.info(" {}", userService.persist(new User("grabowski", "michal", new BigDecimal(30))));
        log.info(" {}", userService.persist(new User("gilewski", "piotr", new BigDecimal(3000))));
        log.info(" {}", userService.persist(new User("ostroski", "krzych", new BigDecimal(2000))));
    };
}
 
开发者ID:przodownikR1,项目名称:elasticSearchKata,代码行数:25,代码来源:ElasticSettingApp.java

示例15: afterPropertiesSet

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
	Class<?> executorClass = (shouldUseBackport() ?
			ClassUtils.forName("org.springframework.scheduling.backportconcurrent.ThreadPoolTaskExecutor", getClass().getClassLoader()) :
			ThreadPoolTaskExecutor.class);
	BeanWrapper bw = new BeanWrapperImpl(executorClass);
	determinePoolSizeRange(bw);
	if (this.queueCapacity != null) {
		bw.setPropertyValue("queueCapacity", this.queueCapacity);
	}
	if (this.keepAliveSeconds != null) {
		bw.setPropertyValue("keepAliveSeconds", this.keepAliveSeconds);
	}
	if (this.rejectedExecutionHandler != null) {
		bw.setPropertyValue("rejectedExecutionHandler", this.rejectedExecutionHandler);
	}
	if (this.beanName != null) {
		bw.setPropertyValue("threadNamePrefix", this.beanName + "-");
	}
	this.target = (TaskExecutor) bw.getWrappedInstance();
	if (this.target instanceof InitializingBean) {
		((InitializingBean) this.target).afterPropertiesSet();
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:TaskExecutorFactoryBean.java


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