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


Java RootBeanDefinition.setBeanClass方法代碼示例

本文整理匯總了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;
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:22,代碼來源:JSFParameterDefinitionParser.java

示例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);
}
 
開發者ID:tongbanjie,項目名稱:baymax,代碼行數:30,代碼來源:BaymaxBeanDefinitionParser.java

示例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;
}
 
開發者ID:benson-git,項目名稱:ibole-microservice,代碼行數:26,代碼來源:RpcRegisteryParser.java

示例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;
}
 
開發者ID:benson-git,項目名稱:ibole-microservice,代碼行數:24,代碼來源:RpcAnnotationParser.java

示例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;
}
 
開發者ID:benson-git,項目名稱:ibole-microservice,代碼行數:23,代碼來源:RpcReferenceParser.java

示例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;
}
 
開發者ID:brucezee,項目名稱:jspider,代碼行數:29,代碼來源:FieldDefineBeanDefinitionParser.java

示例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);
    }

}
 
開發者ID:avast,項目名稱:hdfs-shell,代碼行數:12,代碼來源:BootShim.java

示例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;
}
 
開發者ID:walle-liao,項目名稱:jaf-examples,代碼行數:14,代碼來源:ScopeNamespaceHandler.java

示例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;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:15,代碼來源:CustomNamespaceHandlerTests.java

示例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;
}
 
開發者ID:benson-git,項目名稱:ibole-microservice,代碼行數:34,代碼來源:RpcServiceParser.java

示例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;
}
 
開發者ID:txazo,項目名稱:spring,代碼行數:11,代碼來源:TxazoBeanDefinitionParser.java

示例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);
}
 
開發者ID:lorthos,項目名稱:incubator-zeppelin-druid,代碼行數:9,代碼來源:LensBootstrap.java

示例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));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:7,代碼來源:AnnotationDrivenBeanDefinitionParser.java


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