Announcement Announcement Module
No announcement yet.
Multiple XmlWebApplicationContext for DispatcherServlet Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple XmlWebApplicationContext for DispatcherServlet

    I am new to spring and have the following problem.

    In my application I have multiple identical database for a single deployed application to allowed several clients to use the same application or a single client to have multiple environments. The database conection to use depends on information stored about each login. I also need to be able ot create new connections without blocking the server for other clients.

    I had thought of creating a XmlWebApplicationContext, if not already created, for each connection as users logged in but looking at the api it only seems possible to have one per DispatcherServlet.

    does anyone has a solution which doesn't involve have a deploy per database connection or having multiple DispatcherServlet definitions in web.xml


  • #2
    It looks like you do not need WebApplicationContexts in your situation at all.

    Spring's Contexts are about pre-wiring the beans/services.
    However you need to create database connections programmatically at run-time, thus you cannot pre-wire them because they don't exist yet.

    My recommendation is to not use ApplicationContext for this task. Instead, create database connections programmatically.
    If you really need it to be context, you might want to wire the beans programmatically (not XML based) at runtime.


    • #3
      take a look at
      Last edited by robyn; May 19th, 2006, 06:02 AM.


      • #4
        thanks for the advice. I also found a post on dynamic datasources and tried this which seems to work. When the usere needs to acces the database if a beanfactory for that connection hasn't been created a create and use a proprtypostprocessor to change the datasource properties and hibernate dialect.