本文整理汇总了Java中org.springframework.beans.factory.support.GenericBeanDefinition.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java GenericBeanDefinition.setAttribute方法的具体用法?Java GenericBeanDefinition.setAttribute怎么用?Java GenericBeanDefinition.setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.GenericBeanDefinition
的用法示例。
在下文中一共展示了GenericBeanDefinition.setAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAndRegisterBean
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private void createAndRegisterBean(BeanDefinitionRegistry registry,
String beanName, Class<?>[] interfaces, ResourceScriptSource rs,
long refreshCheckDelay) {
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setFactoryBeanName(DEFAULT_SCRIPT_FACTORY_NAME + beanName);
beanDefinition.setFactoryMethodName(DEFAULT_SCRIPT_FACTORY_METHOD_NAME);
beanDefinition.getConstructorArgumentValues().clear();
beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0, rs);
beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(1, interfaces);
beanDefinition.setAutowireCandidate(true);
beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
beanDefinition.setAttribute(
ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE, refreshCheckDelay);
registry.registerBeanDefinition(beanName,beanDefinition);
}
示例2: createBeanReferenceDefinition
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private AbstractBeanDefinition createBeanReferenceDefinition(String beanName, BeanDefinition actualDef) {
GenericBeanDefinition def = new GenericBeanDefinition();
def.setBeanClass(BeanReferenceFactoryBean.class);
def.setAttribute(GENERATED_REF, Boolean.TRUE);
def.setOriginatingBeanDefinition(actualDef);
def.setDependsOn(new String[] { beanName });
def.setSynthetic(true);
MutablePropertyValues mpv = new MutablePropertyValues();
mpv.addPropertyValue(TARGET_BEAN_NAME_PROP, beanName);
def.setPropertyValues(mpv);
return def;
}
示例3: parseDynamic
import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private void parseDynamic(Element element, ParserContext parserContext) {
Element dynamic = DomUtils.getChildElementByTagName(element, AttributeNames.DYNAMIC);
if (dynamic == null) {
log.warn("系统没有开启动态Bean");
return;
}
log.warn("系统开启动态Bean");
String handlerPackage = dynamic.getAttribute(AttributeNames.HANDLER_PACKAGE);
String dynamicPachage = dynamic.getAttribute(AttributeNames.DYNAMIC_PACKAGE);
String dynamicPattern = dynamic.getAttribute(AttributeNames.DYNAMIC_PATTERN);
String proxyTargetClass = dynamic.getAttribute(AttributeNames.PROXY_TARTGET_CALSS);
String defaultRefreshCheckDelay = dynamic.getAttribute(AttributeNames.DEFAULT_REFRESH_CHECK_DELAY);
BeanDefinition beanDefinition = new RootBeanDefinition(MyScriptFactoryPostProcessor.class);
beanDefinition.getPropertyValues().add("defaultRefreshCheckDelay", Long.valueOf(defaultRefreshCheckDelay));
beanDefinition.getPropertyValues().add("defaultProxyTargetClass", Boolean.valueOf(proxyTargetClass));
parserContext.getRegistry().registerBeanDefinition(
StringUtils.uncapitalize(MyScriptFactoryPostProcessor.class.getSimpleName()), beanDefinition);
ClassPathClassScanner handlerScanner = new ClassPathClassScanner();
handlerScanner.addTypeFilter(new AnnotationTypeFilter(Dynamic.class));
Class<?>[] handlerClzss = handlerScanner.findInterestClasses(handlerPackage);
ClassPathClassScanner dynamicScanner = new ClassPathClassScanner();
dynamicScanner.setResourcePattern(dynamicPattern);
List<String> dynamicSource = dynamicScanner.findInterestFileNames(dynamicPachage);
for (Class<?> clz : handlerClzss) {
Dynamic dyn = clz.getAnnotation(Dynamic.class);
GenericBeanDefinition gbd = new GenericBeanDefinition();
gbd.setBeanClass(GroovyScriptFactory.class);
gbd.setAttribute(MyScriptFactoryPostProcessor.LANGUAGE_ATTRIBUTE, "groovy");
gbd.setAttribute(MyScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE, dyn.refreshCheckDelay());
gbd.getConstructorArgumentValues().addIndexedArgumentValue(0, checkAndFindFileUrl(clz, dynamicSource));
parserContext.getRegistry().registerBeanDefinition(StringUtils.uncapitalize(clz.getSimpleName()), gbd);
}
if (!dynamicSource.isEmpty()) {
for (String source : dynamicSource) {
log.error("无法找到源文件[{}]对应的处理器", source);
}
}
}