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

  • Do not register a bean conditionally

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

    Thanks,
    Vinod

  • #2
    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.

    Comment


    • #3
      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.

      Comment

      Working...
      X