Results 1 to 5 of 5

Thread: Loading different set of beans based on value of a system property

  1. #1

    Default Loading different set of beans based on value of a system property

    Hi,

    I have 2 sets of beans. I want to load one of these sets based on a system property through spring context file.

    Can I do this using spring?

    Example: if the system property repositoryLoad = true

    i want to load
    <bean id="mapppingLoader" class="RepositoryMappingDefinitionLoader"></bean>
    <bean id="routingScriptLoader" class="RepositoryScriptDefinitionLoader"></bean>

    or else

    <bean id="mapppingLoader" class="CacheMappingDefinitionLoader"></bean>
    <bean id="routingScriptLoader" class="CacheMappingDefinitionLoader"></bean>

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    I suggest you read the reference guide, what you want can be achieved using profiles...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Quote Originally Posted by Marten Deinum View Post
    I suggest you read the reference guide, what you want can be achieved using profiles...
    Thanks Marten...

    But I am using Spring 3.0.5 not 3.1.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Then it might be worth an upgrade (should be a drop-in replacement).

    Else create a factorBean for each bean which returns a different instance based on the property.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5

    Default

    Thanks Marten for the reply..

    I think I wont be able to go with upgradation. I will do with factoryBean.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •