當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。