本文整理汇总了Java中org.springframework.beans.factory.support.RootBeanDefinition.setBeanClass方法的典型用法代码示例。如果您正苦于以下问题:Java RootBeanDefinition.setBeanClass方法的具体用法?Java RootBeanDefinition.setBeanClass怎么用?Java RootBeanDefinition.setBeanClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.support.RootBeanDefinition
的用法示例。
在下文中一共展示了RootBeanDefinition.setBeanClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: customizeContext
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) {
Class<?> testClass = mergedConfig.getTestClass();
FlywayTest flywayAnnotation = AnnotatedElementUtils.findMergedAnnotation(testClass, FlywayTest.class);
BeanDefinitionRegistry registry = getBeanDefinitionRegistry(context);
RootBeanDefinition registrarDefinition = new RootBeanDefinition();
registrarDefinition.setBeanClass(PreloadableEmbeddedPostgresRegistrar.class);
registrarDefinition.getConstructorArgumentValues()
.addIndexedArgumentValue(0, databaseAnnotation);
registrarDefinition.getConstructorArgumentValues()
.addIndexedArgumentValue(1, flywayAnnotation);
registry.registerBeanDefinition("preloadableEmbeddedPostgresRegistrar", registrarDefinition);
}
开发者ID:zonkyio,项目名称:embedded-database-spring-test,代码行数:17,代码来源:EmbeddedPostgresContextCustomizerFactory.java
示例2: parse
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(beanClass);
beanDefinition.setLazyInit(false);
String key = element.getAttribute("key");
String value = element.getAttribute("value");
String hide = element.getAttribute("hide");
if(CommonUtils.isTrue(hide)){
JSFContext.putGlobalVal(Constants.HIDE_KEY_PREFIX + key, value);
} else {
JSFContext.putGlobalVal(key, value);
}
beanDefinition.getPropertyValues().addPropertyValue("key", key);
beanDefinition.getPropertyValues().addPropertyValue("value", value);
beanDefinition.getPropertyValues().addPropertyValue("hide", Boolean.valueOf(hide));
return beanDefinition;
}
示例3: fixName
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
/**
* ID处理
* 如果标签上没有定义name 则自动生成name
* @param element
* @param parserContext
*/
private Pair<RootBeanDefinition, String/*name*/> fixName(Element element, ParserContext parserContext, Class beanClass){
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(beanClass);
beanDefinition.setLazyInit(false);
String name = element.getAttribute("name");
synchronized (BaymaxBeanDefinitionParser.class){
if (name == null || name.length() == 0) {
name = "Baymax-" + beanClass.getSimpleName();
while (parserContext.getRegistry().containsBeanDefinition(name)) {
name += (counter++);
}
}
if (name != null && name.length() > 0) {
if (parserContext.getRegistry().containsBeanDefinition(name)) {
throw new IllegalStateException("Duplicate spring bean id " + name);
}
parserContext.getRegistry().registerBeanDefinition(name, beanDefinition);
}
}
return new Pair<RootBeanDefinition, String>(beanDefinition, name);
}
示例4: parse
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
String id = element.getAttribute("id");
String address = element.getAttribute("address");
String rootPath = element.getAttribute("rootPath");
int timeout = Integer.parseInt(element.getAttribute("timeout"));
String token = element.getAttribute("token");
String preferredZone = element.getAttribute("preferredZone");
boolean usedTls = Boolean.valueOf(element.getAttribute("usedTls"));
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(RpcRegistery.class);
// beanDefinition.getPropertyValues().addPropertyValue("id", id);
// beanDefinition.getPropertyValues().addPropertyValue("beanName", type);
beanDefinition.getPropertyValues().addPropertyValue("address", address);
beanDefinition.getPropertyValues().addPropertyValue("rootPath", rootPath);
beanDefinition.getPropertyValues().addPropertyValue("timeout", timeout);
beanDefinition.getPropertyValues().addPropertyValue("token", token);
beanDefinition.getPropertyValues().addPropertyValue("preferredZone", preferredZone);
beanDefinition.getPropertyValues().addPropertyValue("usedTls", usedTls);
parserContext.getRegistry().registerBeanDefinition(id, beanDefinition);
return beanDefinition;
}
示例5: parse
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
public BeanDefinition parse(Element element, ParserContext parserContext) {
String id = element.getAttribute("id");
if (StringUtils.isEmpty(id)) {
String name = element.getAttribute("name");
if (!StringUtils.isEmpty(name)) {
id = name;
} else {
id = RpcAnnotation.class.getName();
}
}
if (parserContext.getRegistry().containsBeanDefinition(id)) {
throw new IllegalStateException("Duplicate spring bean id " + id);
}
String annotationPackage = element.getAttribute("package");
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(RpcAnnotation.class);
beanDefinition.setLazyInit(false);
if (!StringUtils.isEmpty(annotationPackage)) {
beanDefinition.getPropertyValues().addPropertyValue("annotationPackage", annotationPackage);
}
parserContext.getRegistry().registerBeanDefinition(id, beanDefinition);
return beanDefinition;
}
示例6: parse
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
String interfacename = element.getAttribute("interfacename");
String id = element.getAttribute("id");
String preferredZone = element.getAttribute("preferredZone");
boolean usedTls = Boolean.valueOf(element.getAttribute("usedTls"));
int timeout = Strings.isNullOrEmpty(element.getAttribute("timeout")) ? 0
: Integer.parseInt(element.getAttribute("timeout"));
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(RpcReference.class);
beanDefinition.setLazyInit(false);
beanDefinition.getPropertyValues().addPropertyValue("interfacename", interfacename);
beanDefinition.getPropertyValues().addPropertyValue("beanName", id);
beanDefinition.getPropertyValues().addPropertyValue("preferredZone", preferredZone);
beanDefinition.getPropertyValues().addPropertyValue("usedTls", usedTls);
beanDefinition.getPropertyValues().addPropertyValue("timeout", timeout);
parserContext.getRegistry().registerBeanDefinition(id, beanDefinition);
return beanDefinition;
}
示例7: parse
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
FieldDefine fieldDefine = parseFieldDefine(element);
String id = fieldDefine.getId();
if (StringUtils.isEmpty(id)) {
id = fieldDefine.toString()+"-"+System.currentTimeMillis();
}
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(FieldDefine.class);
beanDefinition.setLazyInit(false);
BeanDefinitionRegistry registry = parserContext.getRegistry();
if (registry.containsBeanDefinition(id)) {
throw new IllegalStateException("Duplicate spring bean id " + id);
}
registry.registerBeanDefinition(id, beanDefinition);
MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
propertyValues.addPropertyValue("id", id);
propertyValues.addPropertyValue("name", fieldDefine.getName());
propertyValues.addPropertyValue("type", fieldDefine.getType());
propertyValues.addPropertyValue("selector", fieldDefine.getSelector());
propertyValues.addPropertyValue("processor", fieldDefine.getProcessor());
propertyValues.addPropertyValue("defines", fieldDefine.getDefines());
return beanDefinition;
}
示例8: createAndRegisterBeanDefinition
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
private void createAndRegisterBeanDefinition(ConfigurableApplicationContext annctx, Class<?> clazz, String name) {
RootBeanDefinition rbd = new RootBeanDefinition();
rbd.setBeanClass(clazz);
DefaultListableBeanFactory bf = (DefaultListableBeanFactory) annctx.getBeanFactory();
if (name != null) {
bf.registerBeanDefinition(name, rbd);
} else {
bf.registerBeanDefinition(clazz.getSimpleName(), rbd);
}
}
示例9: postProcessBeanDefinitionRegistry
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) registry;
BeanDefinitionHolder dataSourceInfo = getDataSourceBeanDefinition(beanFactory, databaseAnnotation);
RootBeanDefinition dataSourceDefinition = new RootBeanDefinition();
dataSourceDefinition.setPrimary(dataSourceInfo.getBeanDefinition().isPrimary());
BeanDefinitionHolder flywayInfo = getFlywayBeanDefinition(beanFactory, flywayAnnotation);
if (flywayInfo == null) {
dataSourceDefinition.setBeanClass(EmptyEmbeddedPostgresDataSourceFactoryBean.class);
} else {
String contextBeanName = flywayInfo.getBeanName() + "DataSourceContext";
RootBeanDefinition dataSourceContextDefinition = new RootBeanDefinition();
dataSourceContextDefinition.setBeanClass(FlywayDataSourceContext.class);
registry.registerBeanDefinition(contextBeanName, dataSourceContextDefinition);
dataSourceDefinition.setBeanClass(FlywayEmbeddedPostgresDataSourceFactoryBean.class);
dataSourceDefinition.getConstructorArgumentValues()
.addIndexedArgumentValue(0, flywayInfo.getBeanName());
dataSourceDefinition.getConstructorArgumentValues()
.addIndexedArgumentValue(1, new RuntimeBeanReference(contextBeanName));
}
logger.info("Replacing '{}' DataSource bean with embedded version", dataSourceInfo.getBeanName());
registry.registerBeanDefinition(dataSourceInfo.getBeanName(), dataSourceDefinition);
}
开发者ID:zonkyio,项目名称:embedded-database-spring-test,代码行数:30,代码来源:EmbeddedPostgresContextCustomizerFactory.java
示例10: parse
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(CustomScopeConfigurer.class);
beanDefinition.setScope("singleton");
Map<String, Object> scopes = new HashMap<>();
scopes.put("thread", new SimpleThreadScope());
beanDefinition.getPropertyValues().add("scopes", scopes);
parserContext.getRegistry().registerBeanDefinition("CustomScopeConfigurer", beanDefinition);
return beanDefinition;
}
示例11: parse
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
RootBeanDefinition definition = new RootBeanDefinition();
definition.setBeanClass(TestBean.class);
MutablePropertyValues mpvs = new MutablePropertyValues();
mpvs.add("name", element.getAttribute("name"));
mpvs.add("age", element.getAttribute("age"));
definition.setPropertyValues(mpvs);
parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id"), definition);
return null;
}
示例12: parse
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
String id = element.getAttribute("id");
String interfaceName = element.getAttribute("interface");
String className = element.getAttribute("class");
String ref = element.getAttribute("ref");
if (Strings.isNullOrEmpty(id)) {
String generatedBeanName = element.getAttribute("name");
if (Strings.isNullOrEmpty(generatedBeanName)) {
generatedBeanName = element.getAttribute("interface");
}
id = generatedBeanName;
}
if (!Strings.isNullOrEmpty(id)) {
if (parserContext.getRegistry().containsBeanDefinition(id)) {
throw new IllegalStateException("Duplicate spring bean id " + id);
}
}
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(RpcService.class);
beanDefinition.setLazyInit(false);
beanDefinition.getPropertyValues().addPropertyValue("id", id);
beanDefinition.getPropertyValues().addPropertyValue("interfaceName", interfaceName);
beanDefinition.getPropertyValues().addPropertyValue("implementationClass", className);
beanDefinition.getPropertyValues().addPropertyValue("ref", ref);
parserContext.getRegistry().registerBeanDefinition(id, beanDefinition);
return beanDefinition;
}
示例13: parse
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(beanClass);
beanDefinition.setLazyInit(false);
if (!parserContext.getRegistry().containsBeanDefinition("txazo-config")) {
parserContext.getRegistry().registerBeanDefinition("txazo-config", beanDefinition);
}
return beanDefinition;
}
示例14: getLensJLineShellComponent
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
public LensJLineShellComponent getLensJLineShellComponent() {
GenericApplicationContext ctx = (GenericApplicationContext) getApplicationContext();
RootBeanDefinition rbd = new RootBeanDefinition();
rbd.setBeanClass(LensJLineShellComponent.class);
DefaultListableBeanFactory bf = (DefaultListableBeanFactory) ctx.getBeanFactory();
bf.registerBeanDefinition(LensJLineShellComponent.class.getSimpleName(), rbd);
return ctx.getBean(LensJLineShellComponent.class);
}
示例15: registerTransactionalEventListenerFactory
import org.springframework.beans.factory.support.RootBeanDefinition; //导入方法依赖的package包/类
private void registerTransactionalEventListenerFactory(ParserContext parserContext) {
RootBeanDefinition def = new RootBeanDefinition();
def.setBeanClass(TransactionalEventListenerFactory.class);
parserContext.registerBeanComponent(new BeanComponentDefinition(def,
TransactionManagementConfigUtils.TRANSACTIONAL_EVENT_LISTENER_FACTORY_BEAN_NAME));
}