当前位置: 首页>>代码示例>>Java>>正文


Java GenericBeanDefinition.setAutowireCandidate方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.support.GenericBeanDefinition.setAutowireCandidate方法的典型用法代码示例。如果您正苦于以下问题:Java GenericBeanDefinition.setAutowireCandidate方法的具体用法?Java GenericBeanDefinition.setAutowireCandidate怎么用?Java GenericBeanDefinition.setAutowireCandidate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.support.GenericBeanDefinition的用法示例。


在下文中一共展示了GenericBeanDefinition.setAutowireCandidate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reloadBean

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Reloading spring bean
 *
 * @param clazz
 * @param initMethod
 * @param destroyMethod
 * @throws Exception
 */
public void reloadBean(Class<?> clazz, String initMethod, String destroyMethod) throws Exception {

    BeanDefinitionRegistry beanDefinitionRegistry = ((BeanDefinitionRegistry) this.beanFactory);
    String beanName = clazz.getSimpleName().substring(0, 1).toLowerCase() + clazz.getSimpleName().substring(1);

    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
    beanDefinition.setBeanClass(clazz);
    beanDefinition.setAutowireCandidate(true);

    if (StringUtils.isNotBlank(initMethod)) {
        beanDefinition.setInitMethodName(initMethod);
    }

    if (StringUtils.isNotBlank(destroyMethod)) {
        beanDefinition.setDestroyMethodName(destroyMethod);
    }

    if (beanDefinitionRegistry.containsBeanDefinition(beanName)) {
        beanDefinitionRegistry.removeBeanDefinition(beanName);
    }

    beanDefinitionRegistry.registerBeanDefinition(beanName, beanDefinition);
    applicationContext.getBean(beanName);
}
 
开发者ID:speedyproject,项目名称:dcmp,代码行数:33,代码来源:SpringBeanFactory.java

示例2: createBeanDefinition

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
private static BeanDefinition createBeanDefinition(ComponentDefinition componentDefinition) {
    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();

    beanDefinition.setBeanClassName(componentDefinition.getComponentClass());
    beanDefinition.setScope(getScope(componentDefinition.getScope()));
    beanDefinition.setAutowireCandidate(true);
    beanDefinition.setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_NAME);
    beanDefinition.setDependsOn(componentDefinition.getDependsOn());
    beanDefinition.setLazyInit(componentDefinition.isLazyInit());

    ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
    for (Object value : componentDefinition.getConstructorArguments()) {
        constructorArgumentValues.addIndexedArgumentValue(constructorArgumentValues.getArgumentCount(), value);
    }
    beanDefinition.setConstructorArgumentValues(constructorArgumentValues);

    MutablePropertyValues propertyValues = new MutablePropertyValues();
    for (PropertyValue propertyValue : componentDefinition.getPropertyValues()) {
        propertyValues.add(propertyValue.getName(), propertyValue.getValue());
    }
    beanDefinition.setPropertyValues(propertyValues);

    return beanDefinition;
}
 
开发者ID:Indoqa,项目名称:indoqa-spring,代码行数:25,代码来源:DynamicApplicationContextBuilder.java

示例3: createApplicationServlet

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Creates a Servlet bean definition for the given JAX-RS application
 *
 * @param applicationClass
 * @param path
 * @return a Servlet bean definition for the given JAX-RS application
 */
private GenericBeanDefinition createApplicationServlet(Class<? extends Application> applicationClass, String path) {
    GenericBeanDefinition applicationServletBean = new GenericBeanDefinition();
    applicationServletBean.setFactoryBeanName(ResteasyApplicationBuilder.BEAN_NAME);
    applicationServletBean.setFactoryMethodName("build");

    Set<Class<?>> resources = allResources;

    ConstructorArgumentValues values = new ConstructorArgumentValues();
    values.addIndexedArgumentValue(0, applicationClass.getName());
    values.addIndexedArgumentValue(1, path);
    values.addIndexedArgumentValue(2, resources);
    values.addIndexedArgumentValue(3, providers);
    applicationServletBean.setConstructorArgumentValues(values);

    applicationServletBean.setAutowireCandidate(false);
    applicationServletBean.setScope("singleton");

    return applicationServletBean;
}
 
开发者ID:paypal,项目名称:resteasy-spring-boot,代码行数:27,代码来源:ResteasyEmbeddedServletInitializer.java

示例4: 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

示例5: registerWithServer

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@PostConstruct
public void registerWithServer() {
	AutowireCapableBeanFactory factory = context
			.getAutowireCapableBeanFactory();
	BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
	GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setBeanClass(RmiServiceExporter.class);
	beanDefinition.setAutowireCandidate(true);

	MutablePropertyValues propertyValues = new MutablePropertyValues();

	Class<?> serviceInterface = this.getClass().getInterfaces()[0];

	propertyValues.addPropertyValue("serviceInterface", serviceInterface);
	String serviceName = serviceInterface.getCanonicalName();
	propertyValues.addPropertyValue("serviceName", serviceName);
	propertyValues.addPropertyValue("service", this);
	propertyValues.addPropertyValue("registryPort", "1099");
	beanDefinition.setPropertyValues(propertyValues);

	registry.registerBeanDefinition(serviceName, beanDefinition);
	context.getBean(serviceName); // Need this else
									// NotBoundException
	getService().registerClient(getHostAddress());

}
 
开发者ID:DevOpsDistilled,项目名称:OpERP,代码行数:27,代码来源:AbstractEntityModel.java

示例6: registerAspect

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * register aspectJ for disconf get request
 *
 * @param registry
 */
private void registerAspect(BeanDefinitionRegistry registry) {

    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
    beanDefinition.setBeanClass(DisconfAspectJ.class);
    beanDefinition.setLazyInit(false);
    beanDefinition.setAbstract(false);
    beanDefinition.setAutowireCandidate(true);
    beanDefinition.setScope("singleton");

    registry.registerBeanDefinition("disconfAspectJ", beanDefinition);
}
 
开发者ID:ningyu1,项目名称:disconf-client-ext,代码行数:17,代码来源:DisconfMgrBeanExt.java

示例7: registerBean

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Register bean.
 *
 * @param beanToRegister the bean to register
 * @param beanName the bean name
 * @param scope the scope
 * @param setLazyInit the set lazy init
 * @param setAutowireCandidate the set autowire candidate
 */
public void registerBean(Class<?> beanToRegister, String beanName,
		String scope /* "session" */, boolean setLazyInit,
		boolean setAutowireCandidate) {
	GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setBeanClass(beanToRegister);
	beanDefinition.setLazyInit(setLazyInit);
	beanDefinition.setAbstract(false);
	beanDefinition.setAutowireCandidate(setAutowireCandidate);
	beanDefinition.setScope(scope);

	registry.registerBeanDefinition(beanName, beanDefinition);
}
 
开发者ID:techtrip,项目名称:dynamicbeanloader,代码行数:22,代码来源:ContextAwareBeanFactory.java

示例8: registerBean

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Add's a new bean to Spring's context
 *
 * @param name
 */
public void registerBean(final String name) {
    if (registeredbeans.containsKey(name)) {
        return;
    }
    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
    beanDefinition.setBeanClassName(name);
    beanDefinition.setAutowireCandidate(true);
    AutowireCapableBeanFactory factory = applicationContext.getAutowireCapableBeanFactory();
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
    registry.registerBeanDefinition(name, beanDefinition);
    factory.autowireBeanProperties(this,
            AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
    registeredbeans.put(name, Boolean.TRUE);
}
 
开发者ID:rvt,项目名称:cnctools,代码行数:20,代码来源:ScreensConfiguration.java

示例9: registerClient

import org.springframework.beans.factory.support.GenericBeanDefinition; //导入方法依赖的package包/类
@Override
public void registerClient(String clientAddress) {
	System.out.println("Client from " + clientAddress);

	ApplicationContext context = ServerApp.getApplicationContext();
	AutowireCapableBeanFactory factory = context
			.getAutowireCapableBeanFactory();
	BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
	GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setBeanClass(RmiProxyFactoryBean.class);
	beanDefinition.setAutowireCandidate(true);

	Class<EM> entityModelInterfaceClass = getEntityModelInterfaceClass();

	MutablePropertyValues propertyValues = new MutablePropertyValues();
	propertyValues.addPropertyValue("serviceInterface",
			entityModelInterfaceClass);
	propertyValues.addPropertyValue("serviceUrl", "rmi://" + clientAddress
			+ ":1099/" + entityModelInterfaceClass.getCanonicalName());
	beanDefinition.setPropertyValues(propertyValues);

	registry.registerBeanDefinition(
			entityModelInterfaceClass.getCanonicalName(), beanDefinition);
	EM entityModel = context.getBean(entityModelInterfaceClass);
	registerEntityModel(entityModel);
	System.out.println(entityModel);

}
 
开发者ID:DevOpsDistilled,项目名称:OpERP,代码行数:29,代码来源:AbstractEntityService.java


注:本文中的org.springframework.beans.factory.support.GenericBeanDefinition.setAutowireCandidate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。