本文整理汇总了Java中org.springframework.beans.factory.support.BeanDefinitionBuilder.setDestroyMethodName方法的典型用法代码示例。如果您正苦于以下问题:Java BeanDefinitionBuilder.setDestroyMethodName方法的具体用法?Java BeanDefinitionBuilder.setDestroyMethodName怎么用?Java BeanDefinitionBuilder.setDestroyMethodName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.BeanDefinitionBuilder
的用法示例。
在下文中一共展示了BeanDefinitionBuilder.setDestroyMethodName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
//Sort out the Config Class
BeanDefinitionBuilder configBuilder
= helper.createBeanDefinitionBuilder(element, parserContext,
Config.class);
String configId = helper.getId(null, configBuilder, parserContext);
helper.parseAttributes(element, parserContext, configBuilder);
helper.registerBeanDefinition(configBuilder, configId,
null, parserContext);
//Do the main Redisson bean
BeanDefinitionBuilder builder
= helper.createBeanDefinitionBuilder(element, parserContext,
Redisson.class);
builder.setFactoryMethod("create");
builder.setDestroyMethodName("shutdown");
builder.addConstructorArgReference(configId);
parserContext.getDelegate().parseQualifierElements(element,
builder.getRawBeanDefinition());
String id = helper.getId(element, builder, parserContext);
helper.parseAttributes(element, parserContext, configBuilder);
//Sort out all the nested elements
parseChildElements(element, configId, id, builder, parserContext);
helper.registerBeanDefinition(builder, id,
helper.parseAliase(element), parserContext);
return builder.getBeanDefinition();
}
示例2: doParse
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
builder.getRawBeanDefinition().setBeanClass(RedisClient.class);
if (helper.hasAttribute(element, HOST_ATTRIBUTE)) {
helper.addConstructorArgs(element,
HOST_ATTRIBUTE, String.class, builder);
helper.addConstructorArgs(element,
PORT_ATTRIBUTE, int.class, builder);
helper.addConstructorArgs(element,
CONNECTION_TIMEOUT_ATTRIBUTE, int.class, builder);
helper.addConstructorArgs(element,
COMMAND_TIMEOUT_ATTRIBUTE, int.class, builder);
} else {
BeanDefinitionBuilder b
= helper.createBeanDefinitionBuilder(element,
parserContext,
RedisClientConfig.class);
String configId = helper.getId(null, b, parserContext);
helper.parseAttributes(element, parserContext, b);
BeanComponentDefinition def
= helper.registerBeanDefinition(b, configId,
null, parserContext);
helper.addConstructorArgs(def, RedisClientConfig.class, builder);
}
builder.setDestroyMethodName("shutdown");
parserContext.getDelegate().parseQualifierElements(element,
builder.getRawBeanDefinition());
}
示例3: createDataSource
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
protected final AbstractBeanDefinition createDataSource(MybatisNodeProperties druidNodeConfig,
DruidProperties defaultConfig, String dataSourceName) {
Assert.notNull(druidNodeConfig, String
.format("DynamicDataSource 未初始化 ,dataSourceName=%s,失败原因: 配置参数为空,你的配置可能存在问题!", dataSourceName + ""));
BeanDefinitionBuilder definitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(DynamicDataSource.class);
definitionBuilder.addConstructorArgValue(druidNodeConfig);
definitionBuilder.addConstructorArgValue(defaultConfig);
definitionBuilder.addConstructorArgValue(dataSourceName);
definitionBuilder.setInitMethodName("init");
definitionBuilder.setDestroyMethodName("close");
return definitionBuilder.getRawBeanDefinition();
}
示例4: registerContainer
import org.springframework.beans.factory.support.BeanDefinitionBuilder; //导入方法依赖的package包/类
private void registerContainer(String beanName, Object bean) {
Class<?> clazz = AopUtils.getTargetClass(bean);
if (!RocketMQListener.class.isAssignableFrom(bean.getClass())) {
throw new IllegalStateException(clazz + " is not instance of " + RocketMQListener.class.getName());
}
RocketMQListener rocketMQListener = (RocketMQListener) bean;
RocketMQMessageListener annotation = clazz.getAnnotation(RocketMQMessageListener.class);
BeanDefinitionBuilder beanBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultRocketMQListenerContainer.class);
beanBuilder.addPropertyValue(PROP_NAMESERVER, rocketMQProperties.getNameServer());
beanBuilder.addPropertyValue(PROP_TOPIC, environment.resolvePlaceholders(annotation.topic()));
beanBuilder.addPropertyValue(PROP_CONSUMER_GROUP, environment.resolvePlaceholders(annotation.consumerGroup()));
beanBuilder.addPropertyValue(PROP_CONSUME_MODE, annotation.consumeMode());
beanBuilder.addPropertyValue(PROP_CONSUME_THREAD_MAX, annotation.consumeThreadMax());
beanBuilder.addPropertyValue(PROP_MESSAGE_MODEL, annotation.messageModel());
beanBuilder.addPropertyValue(PROP_SELECTOR_EXPRESS, environment.resolvePlaceholders(annotation.selectorExpress()));
beanBuilder.addPropertyValue(PROP_SELECTOR_TYPE, annotation.selectorType());
beanBuilder.addPropertyValue(PROP_ROCKETMQ_LISTENER, rocketMQListener);
beanBuilder.addPropertyValue(PROP_PULL_THRESHOLD_FOR_TOPIC, annotation.pullThresholdForTopic());
beanBuilder.addPropertyValue(PROP_PULL_THRESHOLD_SIZE_FOR_TOPIC, annotation.pullThresholdSizeForTopic());
if (Objects.nonNull(objectMapper)) {
beanBuilder.addPropertyValue(PROP_OBJECT_MAPPER, objectMapper);
}
beanBuilder.setDestroyMethodName(METHOD_DESTROY);
String containerBeanName = String.format("%s_%s", DefaultRocketMQListenerContainer.class.getName(), counter.incrementAndGet());
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) applicationContext.getBeanFactory();
beanFactory.registerBeanDefinition(containerBeanName, beanBuilder.getBeanDefinition());
DefaultRocketMQListenerContainer container = beanFactory.getBean(containerBeanName, DefaultRocketMQListenerContainer.class);
if (!container.isStarted()) {
try {
container.start();
} catch (Exception e) {
log.error("started container failed. {}", container, e);
throw new RuntimeException(e);
}
}
log.info("register rocketMQ listener to container, listenerBeanName:{}, containerBeanName:{}", beanName, containerBeanName);
}