本文整理汇总了Java中org.springframework.beans.factory.support.GenericBeanDefinition.setDestroyMethodName方法的典型用法代码示例。如果您正苦于以下问题:Java GenericBeanDefinition.setDestroyMethodName方法的具体用法?Java GenericBeanDefinition.setDestroyMethodName怎么用?Java GenericBeanDefinition.setDestroyMethodName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.GenericBeanDefinition
的用法示例。
在下文中一共展示了GenericBeanDefinition.setDestroyMethodName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reloadBean
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
* Reloading spring bean
*
* @param clazz
* @param initMethod
* @param destroyMethod
* @throws Exception
*/
public void reloadBean(Class<?> clazz, String initMethod, String destroyMethod) throws Exception {
BeanDefinitionRegistry beanDefinitionRegistry = ((BeanDefinitionRegistry) this.beanFactory);
String beanName = clazz.getSimpleName().substring(0, 1).toLowerCase() + clazz.getSimpleName().substring(1);
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(clazz);
beanDefinition.setAutowireCandidate(true);
if (StringUtils.isNotBlank(initMethod)) {
beanDefinition.setInitMethodName(initMethod);
}
if (StringUtils.isNotBlank(destroyMethod)) {
beanDefinition.setDestroyMethodName(destroyMethod);
}
if (beanDefinitionRegistry.containsBeanDefinition(beanName)) {
beanDefinitionRegistry.removeBeanDefinition(beanName);
}
beanDefinitionRegistry.registerBeanDefinition(beanName, beanDefinition);
applicationContext.getBean(beanName);
}
示例2: postProcessBeanFactory
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
BeanDefinitionRegistry registry=(BeanDefinitionRegistry)beanFactory;
CuratorFramework curatorFramework = beanFactory.getBean(CuratorFramework.class);
ServiceRouter serviceRouter = beanFactory.getBean(ServiceRouter.class);
for(Class clazz:list){
GenericBeanDefinition definition=(GenericBeanDefinition) BeanDefinitionBuilder.genericBeanDefinition(clazz).getBeanDefinition();
definition.getPropertyValues().addPropertyValue("innerClass",clazz);
definition.getPropertyValues().addPropertyValue("factory",beanFactory);
ServiceApi serviceApi = map.get(clazz.getName());
definition.getPropertyValues().addPropertyValue("proccessName",serviceApi.getName());
String path = "/"+clazz.getName()+"/"+ (serviceApi!=null ? serviceApi.getVersion() :
ThriftConstant.DEFAULT_VERSION);
ServiceDiscover serviceDiscover = new ZookeeperServiceDiscover(curatorFramework, path);
definition.getPropertyValues().addPropertyValue("serverManager",
new ServerManager(serviceDiscover, serviceRouter));
definition.setBeanClass(ProxyFactoryBean.class);
definition.setDestroyMethodName("close");
registry.registerBeanDefinition(clazz.getName(), definition);
}
}