當前位置: 首頁>>代碼示例>>Java>>正文


Java GenericBeanDefinition.setAttribute方法代碼示例

本文整理匯總了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);		

}
 
開發者ID:valliappanr,項目名稱:refreshable-beans,代碼行數:17,代碼來源:SpringContextWrapper.java

示例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;
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:13,代碼來源:AbstractReferenceDefinitionParser.java

示例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);
    }
}
   }
 
開發者ID:ilivoo,項目名稱:game,代碼行數:42,代碼來源:NioServerBeanDefinitionParser.java


注:本文中的org.springframework.beans.factory.support.GenericBeanDefinition.setAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。