List of usage examples for org.springframework.beans.factory.support GenericBeanDefinition setBeanClass
public void setBeanClass(@Nullable Class<?> beanClass)
From source file:com.laxser.blitz.web.impl.module.ModuleAppContext.java
/** ?messageSourceRose? */ public static void registerMessageSourceIfNecessary(BeanDefinitionRegistry registry, String[] messageBaseNames) { if (!ArrayUtils.contains(registry.getBeanDefinitionNames(), MESSAGE_SOURCE_BEAN_NAME)) { logger.debug("registerMessageSource " + ArrayUtils.toString(messageBaseNames)); GenericBeanDefinition messageSource = new GenericBeanDefinition(); messageSource.setBeanClass(ReloadableResourceBundleMessageSource.class); MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.addPropertyValue("useCodeAsDefaultMessage", true); propertyValues.addPropertyValue("defaultEncoding", "UTF-8"); // propertiesUTF-8?ISO-9959-1 propertyValues.addPropertyValue("cacheSeconds", 60); // hardcode! 60 propertyValues.addPropertyValue("basenames", messageBaseNames); messageSource.setPropertyValues(propertyValues); registry.registerBeanDefinition(MESSAGE_SOURCE_BEAN_NAME, messageSource); }//from w w w . j a v a 2 s. c o m }
From source file:com.gzj.tulip.load.context.RoseWebAppContext.java
/** ?messageSourceRose? */ public static void registerMessageSourceIfNecessary(BeanDefinitionRegistry registry, String[] messageBaseNames) { if (!registry.containsBeanDefinition(MESSAGE_SOURCE_BEAN_NAME)) { GenericBeanDefinition messageSource = new GenericBeanDefinition(); messageSource.setBeanClass(ReloadableResourceBundleMessageSource.class); MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.addPropertyValue("useCodeAsDefaultMessage", true); propertyValues.addPropertyValue("defaultEncoding", "UTF-8"); // propertiesUTF-8?ISO-9959-1 propertyValues.addPropertyValue("cacheSeconds", 60); // hardcode! seconds propertyValues.addPropertyValue("basenames", messageBaseNames); messageSource.setPropertyValues(propertyValues); registry.registerBeanDefinition(MESSAGE_SOURCE_BEAN_NAME, messageSource); }//w ww . j a v a2 s. co m }
From source file:co.paralleluniverse.common.spring.SpringContainerHelper.java
public static BeanDefinition defineBean(Class<?> clazz, ConstructorArgumentValues constructorArgs, MutablePropertyValues properties) { GenericBeanDefinition bean = new GenericBeanDefinition(); bean.setBeanClass(clazz); bean.setAutowireCandidate(true);//from www . jav a 2 s. com bean.setConstructorArgumentValues(constructorArgs); bean.setPropertyValues(properties); return bean; }
From source file:co.paralleluniverse.common.spring.SpringContainerHelper.java
private static BeanDefinition getMBeanExporterBeanDefinition(String defaultDomain) { final AnnotationJmxAttributeSource annotationSource = new AnnotationJmxAttributeSource(); final GenericBeanDefinition bean = new GenericBeanDefinition(); bean.setBeanClass(MBeanExporter.class); MutablePropertyValues properties = new MutablePropertyValues(); properties.add("server", ManagementFactory.getPlatformMBeanServer()); properties.add("autodetectMode", MBeanExporter.AUTODETECT_ASSEMBLER); properties.add("assembler", new MetadataMBeanInfoAssembler(annotationSource)); properties.add("namingStrategy", new MBeanNamingStrategy(annotationSource).setDefaultDomain(defaultDomain)); bean.setPropertyValues(properties);// w w w. ja v a2 s. c om return bean; }
From source file:io.nuun.plugin.spring.UsingSpringAsDIPlugin.java
public Object nativeUnitModule() { ClassPathXmlApplicationContext parentCtx = new ClassPathXmlApplicationContext("context.xml"); StaticApplicationContext dynCtx = new StaticApplicationContext(); GenericBeanDefinition beanDef = new GenericBeanDefinition(); beanDef.setBeanClass(Service3Internal.class); beanDef.setScope("prototype"); dynCtx.registerBeanDefinition("service3", beanDef); dynCtx.setParent(parentCtx);// w w w. jav a 2 s . co m dynCtx.refresh(); return dynCtx; }
From source file:org.nuunframework.spring.UsingSpringAsDIPlugin.java
@Override public Object dependencyInjectionDef() { ClassPathXmlApplicationContext parentCtx = new ClassPathXmlApplicationContext("context.xml"); StaticApplicationContext dynCtx = new StaticApplicationContext(); GenericBeanDefinition beanDef = new GenericBeanDefinition(); beanDef.setBeanClass(Service3Internal.class); beanDef.setScope("prototype"); dynCtx.registerBeanDefinition("service3", beanDef); dynCtx.setParent(parentCtx);/*from www .jav a 2 s .co m*/ dynCtx.refresh(); return dynCtx; }
From source file:com.auditbucket.spring.xml.ClientBeanDefinitionParser.java
public BeanDefinition parse(Element element, ParserContext parserContext) { // When node is not null, we should build a client. // When node is null, we want to build a transport client. String id = XMLParserUtil.getElementStringValue(element, "id"); String properties = XMLParserUtil.getElementStringValue(element, "properties"); BeanDefinition client;// ww w . j a v a2 s .c o m GenericBeanDefinition bdef = new GenericBeanDefinition(); bdef.setBeanClass(AuditBucketClientFactoryBean.class); BeanDefinitionBuilder clientBuilder = startClientBuilder(AuditBucketClientFactoryBean.class, properties); client = ClientBeanDefinitionParser.buildClientDef(clientBuilder); parserContext.getRegistry().registerBeanDefinition(id, client); return bdef; }
From source file:com.github.xdcrafts.flower.spring.impl.DefaultActionDefinitionFactory.java
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { actions.entrySet().forEach(entry -> { final String name = entry.getKey(); final String qualifiedName = Named.qualifiedName(this.namespace, name); final Object method = entry.getValue(); final MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("method", method); final GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(DefaultActionFactory.class); beanDefinition.setPropertyValues(propertyValues); registry.registerBeanDefinition(qualifiedName, beanDefinition); });/*from w w w.j a v a 2s .c om*/ }
From source file:fr.pilato.spring.elasticsearch.xml.NodeBeanDefinitionParser.java
public BeanDefinition parse(Element element, ParserContext parserContext) { GenericBeanDefinition bdef = new GenericBeanDefinition(); bdef.setBeanClass(ElasticsearchNodeFactoryBean.class); String id = element.getAttribute("id"); String name = element.getAttribute("name"); String settingsFile = element.getAttribute("settingsFile"); String properties = element.getAttribute("properties"); String taskExecutor = element.getAttribute("taskExecutor"); String async = element.getAttribute("async"); // Define NodeBeanDefinition BeanDefinition node = NodeBeanDefinitionParser.buildNodeDef(settingsFile, properties, async, taskExecutor); // Register NodeBeanDefinition if (id != null && id.length() > 0) { parserContext.getRegistry().registerBeanDefinition(id, node); } else {// w w w . j a va 2s . c o m parserContext.getRegistry().registerBeanDefinition(name, node); } return bdef; }
From source file:org.jacp.project.launcher.SpringLauncher.java
@Override public synchronized <T> T registerAndGetBean(Class<? extends T> type, final String id, final Scope scope) { if (this.factory.containsBean(id)) return getBean(type); final AutowireCapableBeanFactory factory = getContext().getAutowireCapableBeanFactory(); final BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory; final GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(type); beanDefinition.setScope(scope.getType()); beanDefinition.setAutowireCandidate(true); registry.registerBeanDefinition(id, beanDefinition); factory.autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false); return getBean(type); }