Results 1 to 2 of 2

Thread: ApplicationContext.xml at individual class level

  1. #1
    Join Date
    Nov 2012
    Posts
    1

    Default ApplicationContext.xml at individual class level

    Hello Spring experts

    You can tell I am new to spring FW from my post.

    Is it possible to configure applicationContext.xml (basically context configuration file) at a class level or a servlet level in a web application? Like how we can configure mvc config file per servlet in web.xml.
    What I am trying to do is
    I have a service impl class and I am setting its property via applicationContext.xml bean definition.
    <bean id="genericSupportService" class="com.xyz.genric.GenericSupportServiceImpl">
    <property name="wsConfigUrl" value="a/b/c" />

    I have 2 servlets. When the request comes thru servlet 1, the value of a/b/c is perfectly fine.
    But for requests routed thru servlet 2, I want the same property wsConfigUrl to assume d/e/f.
    I can use setters and keep changing the value back and forth between a/b/c and d/e/f but dont think it is an elegant solution. At the same time I think bean scope being prototype is also an overkill. Ideally I think I want to load one bean per servlet with different values using different configurations.

    Hope I made sense with my question. Greatly appreaciate any insight.

    Thanks

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

    Default

    You already gave yourself the solution..

    Ideally I think I want to load one bean per servlet with different values using different configurations.
    What is preventing you from doing so?
    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

Posting Permissions

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