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

  • Overload a bean implementation

    Hi everyone,

    I've decided to add a DAO/ORM layer to the phonebook. In this context i decided to use spring-core to glue together my dao with the app, without any modification to the app.
    I can easily change the PhoneBook implementation by changing this line in the service-layer.xml

    Code:
    		<bean id="phoneBook" class="org.springframework.webflow.samples.phonebook.domain.ArrayListPhoneBook"/>
    However my plan is not to touched to this orignal source code, including the original config file. Is there anyway , to say to spring-core, in a different config file, that the <bean id="phonebook" ... > is overload by a new implementation ?


    PS : I post this in the webflow forum because i wanted people reading to be familliar with the phonebook samples. If administrators want to move it to spring core, it's ok with me...

  • #2
    Well, what you would typically do is use a different context definition file. E.g. replace the use of the "service-layer.xml" file that defines the phoneBook bean with use of a "orm-service-layer.xml" context that defines a different ORM based implementation of the phoneBook bean.

    The change woul happen in the web.xml deployment descriptor (contextConfigLocation).

    Erwin

    Comment


    • #3
      Well that's force me to replace the service-layer.xml file, isn't it ?

      My goals is actually to change the implementation without any change to the phonebook package... Is there no way to override a bean ?

      Comment


      • #4
        You don't necessarily have to change the service-layer.xml file, but replace it with another one by changing web.xml.

        Anyway you look at it, you'll have to edit web.xml since even if there was a "bean override" feature, you'd still have to add the context definition with your overriding bean to web.xml.

        Erwin

        Comment

        Working...
        X