本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}