Java Code Examples for org.springframework.beans.factory.support.GenericBeanDefinition#setRole()
The following examples show how to use
org.springframework.beans.factory.support.GenericBeanDefinition#setRole() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationDrivenBeanDefinitionParser.java From spring-analysis-note with MIT License | 5 votes |
private GenericBeanDefinition createObjectMapperFactoryDefinition(@Nullable Object source) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(Jackson2ObjectMapperFactoryBean.class); beanDefinition.setSource(source); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); return beanDefinition; }
Example 2
Source File: MessageBrokerBeanDefinitionParser.java From spring-analysis-note with MIT License | 5 votes |
private RuntimeBeanReference registerMessageConverter( Element element, ParserContext context, @Nullable Object source) { Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters"); ManagedList<Object> converters = new ManagedList<>(); if (convertersElement != null) { converters.setSource(source); for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) { Object object = context.getDelegate().parsePropertySubElement(beanElement, null); converters.add(object); } } if (convertersElement == null || Boolean.valueOf(convertersElement.getAttribute("register-defaults"))) { converters.setSource(source); converters.add(new RootBeanDefinition(StringMessageConverter.class)); converters.add(new RootBeanDefinition(ByteArrayMessageConverter.class)); if (jackson2Present) { RootBeanDefinition jacksonConverterDef = new RootBeanDefinition(MappingJackson2MessageConverter.class); RootBeanDefinition resolverDef = new RootBeanDefinition(DefaultContentTypeResolver.class); resolverDef.getPropertyValues().add("defaultMimeType", MimeTypeUtils.APPLICATION_JSON); jacksonConverterDef.getPropertyValues().add("contentTypeResolver", resolverDef); // Use Jackson factory in order to have JSR-310 and Joda-Time modules registered automatically GenericBeanDefinition jacksonFactoryDef = new GenericBeanDefinition(); jacksonFactoryDef.setBeanClass(Jackson2ObjectMapperFactoryBean.class); jacksonFactoryDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); jacksonFactoryDef.setSource(source); jacksonConverterDef.getPropertyValues().add("objectMapper", jacksonFactoryDef); converters.add(jacksonConverterDef); } } ConstructorArgumentValues cargs = new ConstructorArgumentValues(); cargs.addIndexedArgumentValue(0, converters); RootBeanDefinition messageConverterDef = new RootBeanDefinition(CompositeMessageConverter.class, cargs, null); String name = MESSAGE_CONVERTER_BEAN_NAME; registerBeanDefByName(name, messageConverterDef, context, source); return new RuntimeBeanReference(name); }
Example 3
Source File: AnnotationDrivenBeanDefinitionParser.java From java-technology-stack with MIT License | 5 votes |
private GenericBeanDefinition createObjectMapperFactoryDefinition(@Nullable Object source) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(Jackson2ObjectMapperFactoryBean.class); beanDefinition.setSource(source); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); return beanDefinition; }
Example 4
Source File: MessageBrokerBeanDefinitionParser.java From java-technology-stack with MIT License | 5 votes |
private RuntimeBeanReference registerMessageConverter( Element element, ParserContext context, @Nullable Object source) { Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters"); ManagedList<Object> converters = new ManagedList<>(); if (convertersElement != null) { converters.setSource(source); for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) { Object object = context.getDelegate().parsePropertySubElement(beanElement, null); converters.add(object); } } if (convertersElement == null || Boolean.valueOf(convertersElement.getAttribute("register-defaults"))) { converters.setSource(source); converters.add(new RootBeanDefinition(StringMessageConverter.class)); converters.add(new RootBeanDefinition(ByteArrayMessageConverter.class)); if (jackson2Present) { RootBeanDefinition jacksonConverterDef = new RootBeanDefinition(MappingJackson2MessageConverter.class); RootBeanDefinition resolverDef = new RootBeanDefinition(DefaultContentTypeResolver.class); resolverDef.getPropertyValues().add("defaultMimeType", MimeTypeUtils.APPLICATION_JSON); jacksonConverterDef.getPropertyValues().add("contentTypeResolver", resolverDef); // Use Jackson factory in order to have JSR-310 and Joda-Time modules registered automatically GenericBeanDefinition jacksonFactoryDef = new GenericBeanDefinition(); jacksonFactoryDef.setBeanClass(Jackson2ObjectMapperFactoryBean.class); jacksonFactoryDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); jacksonFactoryDef.setSource(source); jacksonConverterDef.getPropertyValues().add("objectMapper", jacksonFactoryDef); converters.add(jacksonConverterDef); } } ConstructorArgumentValues cargs = new ConstructorArgumentValues(); cargs.addIndexedArgumentValue(0, converters); RootBeanDefinition messageConverterDef = new RootBeanDefinition(CompositeMessageConverter.class, cargs, null); String name = MESSAGE_CONVERTER_BEAN_NAME; registerBeanDefByName(name, messageConverterDef, context, source); return new RuntimeBeanReference(name); }
Example 5
Source File: EmbeddedCassandraContextCustomizer.java From embedded-cassandra with Apache License 2.0 | 5 votes |
private static void registerCassandraInitializerBeanDefinition(CqlDataSet dataSet, ConfigurableApplicationContext context, BeanDefinitionRegistry registry) { GenericBeanDefinition bd = new GenericBeanDefinition(); bd.setBeanClass(CassandraInitializer.class); bd.setLazyInit(false); bd.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); bd.setScope(BeanDefinition.SCOPE_SINGLETON); bd.setInstanceSupplier(() -> new CassandraInitializer(context, dataSet)); registry.registerBeanDefinition(CassandraInitializer.class.getName(), bd); }
Example 6
Source File: ConfigurationPropertiesBindingPostProcessorRegistrar.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
private void registerConfigurationPropertiesBindingPostProcessor( BeanDefinitionRegistry registry) { GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setBeanClass(ConfigurationPropertiesBindingPostProcessor.class); definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); registry.registerBeanDefinition( ConfigurationPropertiesBindingPostProcessor.BEAN_NAME, definition); }
Example 7
Source File: ConfigurationPropertiesBindingPostProcessorRegistrar.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
private void registerConfigurationBeanFactoryMetadata( BeanDefinitionRegistry registry) { GenericBeanDefinition definition = new GenericBeanDefinition(); definition.setBeanClass(ConfigurationBeanFactoryMetadata.class); definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); registry.registerBeanDefinition(ConfigurationBeanFactoryMetadata.BEAN_NAME, definition); }
Example 8
Source File: TeiidPostProcessor.java From teiid-spring-boot with Apache License 2.0 | 5 votes |
@Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { if (!registry.containsBeanDefinition(BEAN_NAME)) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(TeiidPostProcessor.class); beanDefinition.setRole(BeanDefinition.ROLE_APPLICATION); // We don't need this one to be post processed otherwise it can cause a // cascade of bean instantiation that we would rather avoid. beanDefinition.setSynthetic(true); registry.registerBeanDefinition(BEAN_NAME, beanDefinition); } }
Example 9
Source File: AnnotationDrivenBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 5 votes |
private GenericBeanDefinition createObjectMapperFactoryDefinition(Object source) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(Jackson2ObjectMapperFactoryBean.class); beanDefinition.setSource(source); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); return beanDefinition; }
Example 10
Source File: AnnotationDrivenBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 5 votes |
private GenericBeanDefinition createObjectMapperFactoryDefinition(Object source) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(Jackson2ObjectMapperFactoryBean.class); beanDefinition.setSource(source); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); return beanDefinition; }
Example 11
Source File: MessageBrokerBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 5 votes |
private RuntimeBeanReference registerMessageConverter(Element element, ParserContext context, Object source) { Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters"); ManagedList<? super Object> converters = new ManagedList<Object>(); if (convertersElement != null) { converters.setSource(source); for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) { Object object = context.getDelegate().parsePropertySubElement(beanElement, null); converters.add(object); } } if (convertersElement == null || Boolean.valueOf(convertersElement.getAttribute("register-defaults"))) { converters.setSource(source); converters.add(new RootBeanDefinition(StringMessageConverter.class)); converters.add(new RootBeanDefinition(ByteArrayMessageConverter.class)); if (jackson2Present) { RootBeanDefinition jacksonConverterDef = new RootBeanDefinition(MappingJackson2MessageConverter.class); RootBeanDefinition resolverDef = new RootBeanDefinition(DefaultContentTypeResolver.class); resolverDef.getPropertyValues().add("defaultMimeType", MimeTypeUtils.APPLICATION_JSON); jacksonConverterDef.getPropertyValues().add("contentTypeResolver", resolverDef); // Use Jackson factory in order to have JSR-310 and Joda-Time modules registered automatically GenericBeanDefinition jacksonFactoryDef = new GenericBeanDefinition(); jacksonFactoryDef.setBeanClass(Jackson2ObjectMapperFactoryBean.class); jacksonFactoryDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); jacksonFactoryDef.setSource(source); jacksonConverterDef.getPropertyValues().add("objectMapper", jacksonFactoryDef); converters.add(jacksonConverterDef); } } ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addIndexedArgumentValue(0, converters); RootBeanDefinition messageConverterDef = new RootBeanDefinition(CompositeMessageConverter.class, cavs, null); return new RuntimeBeanReference(registerBeanDef(messageConverterDef, context, source)); }
Example 12
Source File: WebAdminComponentScanRegistrar.java From wallride with Apache License 2.0 | 5 votes |
private void addWebAdminComponentScanBeanPostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(WebAdminComponentScanBeanPostProcessor.class); beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(toArray(packagesToScan)); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); // We don't need this one to be post processed otherwise it can cause a // cascade of bean instantiation that we would rather avoid. beanDefinition.setSynthetic(true); registry.registerBeanDefinition(BEAN_NAME, beanDefinition); }
Example 13
Source File: WebGuestComponentScanRegistrar.java From wallride with Apache License 2.0 | 5 votes |
private void addWebGuestComponentScanBeanPostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(WebGuestComponentScanBeanPostProcessor.class); beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(toArray(packagesToScan)); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); // We don't need this one to be post processed otherwise it can cause a // cascade of bean instantiation that we would rather avoid. beanDefinition.setSynthetic(true); registry.registerBeanDefinition(BEAN_NAME, beanDefinition); }
Example 14
Source File: AlfrescoRestRegistrar.java From alfresco-mvc with Apache License 2.0 | 5 votes |
private void processDispatcherWebscript(AnnotationAttributes webscriptAttributes, BeanDefinitionRegistry registry) { String webscript = webscriptAttributes.getString("name"); Assert.hasText(webscript, "Webscript name cannot be empty!"); Class<?> servletContext = webscriptAttributes.getClass("servletContext"); ServletConfigOptions[] servletConfigOptions = (ServletConfigOptions[]) webscriptAttributes .get("servletConfigOptions"); Class<? extends WebApplicationContext> servletContextClass = webscriptAttributes .getClass("servletContextClass"); HttpMethod[] httpMethods = (HttpMethod[]) webscriptAttributes.get("httpMethods"); boolean inheritGlobalProperties = (Boolean) webscriptAttributes.get("inheritGlobalProperties"); GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(DispatcherWebscript.class); DispatcherWebscript ws = new DispatcherWebscript(webscript, inheritGlobalProperties); ws.setContextClass(servletContextClass); ws.setContextConfigLocation(servletContext.getName()); ws.addServletConfigOptions(servletConfigOptions); beanDefinition.setInstanceSupplier(() -> ws); beanDefinition.setRole(BeanDefinition.ROLE_APPLICATION); registry.registerBeanDefinition(webscript, beanDefinition); for (HttpMethod httpMethod : httpMethods) { registry.registerAlias(webscript, getWebscriptName(webscript, httpMethod)); } }