Announcement Announcement Module
Collapse
No announcement yet.
Do not register a bean conditionally Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • vinod.singh
    started a topic Do not register a bean conditionally

    Do not register a bean conditionally

    Is there any way to stop registering a bean in BeanDefinitionRegistry programmatically based on some condition?

    Thanks,
    Vinod

  • vinod.singh
    replied
    Actually I wanted to define environment specific properties in a single configuration file instead of taking refuge under PropertyPlaceholderConfigurer and create separate file for each environment. I want to configure it like below-

    Code:
    <property id="my.service.url" class="java.net.URL" value="http://localhost:8080/ws-app/MyService?wsdl" region="dev" />
    <property id="my.service.url" class="java.net.URL" value="http://10.9.32.167:8080/ws-app/MyService?wsdl" region="prod" />
    and at runtime load only one of the above property according to current environment. I achieved it by extending AbstractSingleBeanDefinitionParser, which was created to handle custom <property> element.

    Thanks, for the 'null' trick for postProcessBeforeInitialization, will use that for some other requirement.

    Leave a comment:


  • pedro
    replied
    I'm not sure what do you want to achieve, but you could add your BeanPostProcessor, and if you return null form postProcessBeforeInitialization it should not been registred.

    Leave a comment:

Working...
X