Announcement Announcement Module
Collapse
No announcement yet.
Multiple XmlWebApplicationContext for DispatcherServlet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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

    Karl

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

    Comment


    • #3
      take a look at

      http://forum.springframework.org/showthread.php?t=10728
      Last edited by robyn; May 19th, 2006, 05:02 AM.

      Comment


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

        Comment

        Working...
        X