Results 1 to 4 of 4

Thread: Multiple XmlWebApplicationContext for DispatcherServlet

  1. #1
    Join Date
    Dec 2004
    Location
    Italy
    Posts
    4

    Default 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. #2
    Join Date
    Dec 2004
    Posts
    29

    Default

    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. #3
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    71

    Default

    Last edited by robyn; May 19th, 2006 at 05:02 AM.

  4. #4
    Join Date
    Dec 2004
    Location
    Italy
    Posts
    4

    Default

    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.

Similar Threads

  1. Replies: 6
    Last Post: Sep 1st, 2005, 09:18 AM
  2. Replies: 3
    Last Post: Apr 21st, 2005, 03:19 PM
  3. Replies: 1
    Last Post: Mar 9th, 2005, 03:52 PM
  4. Replies: 1
    Last Post: Feb 25th, 2005, 07:12 AM
  5. Multiple Pages
    By afida in forum Swing
    Replies: 12
    Last Post: Feb 16th, 2005, 08:42 AM

Posting Permissions

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