Jetspeed 2
  1. Jetspeed 2
  2. JS2-809

Add table schema aware datasource proxy

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1, 2.1.2, 2.1.3, 2.2.0
    • Fix Version/s: 2.1.3, 2.2.0
    • Component/s: Persistence and DAO
    • Labels:
      None

      Description

      In some environments (DB2, Oracle, PostGres) the table schema may be not equally associated with the user name, provided in the jdbc connection parameters. At the moment it is not possible to set the table schema used for the db connections.

      This table schema aware datasource proxy optionally injects a schema selection sql statement into an existing database connection. It proxies a DataSource and executes an injected sql statement on every getConnection() call.

      The proxy can be configured via the spring configurations files and therefore allows to add table schema support to the import functionality only. This might come in handy if you have to import into a certain table schema and cannot rely on the web application container datasource configuration that might already support table schemas (like websphere does).

      The solution was inspired from http://forum.springframework.org/showthread.php?t=10728, although the runtime schema switching functionality was stripped.

      1. patch.diff
        8 kB
        Joachim Müller

        Activity

        Hide
        Joachim Müller added a comment -

        The proxy source and patches to some datasource configuration files.

        Show
        Joachim Müller added a comment - The proxy source and patches to some datasource configuration files.
        Hide
        Dennis Dam added a comment -

        the patch looks ok (especially since all the spring config is commented , although a couple of questions:

        • what are the differences between org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy (which you extend) and org.apache.commons.dbcp.BasicDataSource (the default datasource) . Why did you choose for the one from Spring ?
        Show
        Dennis Dam added a comment - the patch looks ok (especially since all the spring config is commented , although a couple of questions: what are the differences between org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy (which you extend) and org.apache.commons.dbcp.BasicDataSource (the default datasource) . Why did you choose for the one from Spring ? The property maxRetriedStarts in /src/webapp/WEB-INF/assembly requires the patch described in https://issues.apache.org/jira/browse/JS2-666 right ? In that case it might be an idea to either relate this issue to JS2-666 , or remove the property.
        Hide
        Joachim Müller added a comment -

        The usage of the TransactionAwareDataSourceProxy is an artifact from the source of the idea (http://forum.springframework.org/showthread.php?t=10728). There, it is required to change the database schema within a local transaction, so the getConnection() method must be transaction aware.

        Since this functionality is stripped in my patch, and probably is not needed here, the SchemaAwareDataSourceProxy could extend from BasicDataSource I guess.

        The fragment in the spring configuration (property maxRetriedStarts in /src/webapp/WEB-INF/assembly) is my mistake. I created the patch against an already patched version of the assembly file. Sorry about this, the two issues are not related at all!

        I will test the SchemaAwareDataSourceProxy extending from BasicDataSource and repost patches against the current trunk as soon as I have some spare time.

        Show
        Joachim Müller added a comment - The usage of the TransactionAwareDataSourceProxy is an artifact from the source of the idea ( http://forum.springframework.org/showthread.php?t=10728 ). There, it is required to change the database schema within a local transaction, so the getConnection() method must be transaction aware. Since this functionality is stripped in my patch, and probably is not needed here, the SchemaAwareDataSourceProxy could extend from BasicDataSource I guess. The fragment in the spring configuration (property maxRetriedStarts in /src/webapp/WEB-INF/assembly) is my mistake. I created the patch against an already patched version of the assembly file. Sorry about this, the two issues are not related at all! I will test the SchemaAwareDataSourceProxy extending from BasicDataSource and repost patches against the current trunk as soon as I have some spare time.
        Hide
        Ate Douma added a comment -

        Joachim,

        Did you find time to test and work on new patches?
        We're planning to finish up 2.1.3 this week.
        To be able to review and test a possible patch against 2.1.3 we will need it ASAP, otherwise it'll have to wait to 2.2.

        Show
        Ate Douma added a comment - Joachim, Did you find time to test and work on new patches? We're planning to finish up 2.1.3 this week. To be able to review and test a possible patch against 2.1.3 we will need it ASAP, otherwise it'll have to wait to 2.2.
        Hide
        Joachim Müller added a comment -

        Dennis, I was in a rush when I answered your questions: Of course we must use the TransactionAwareDataSourceProxy since we are proxying the DataSource and inject the target datasource into the proxy via spring (see spring configs).

        I am attaching the patch again, striped by the reference to the JS2-666 issue.

        Show
        Joachim Müller added a comment - Dennis, I was in a rush when I answered your questions: Of course we must use the TransactionAwareDataSourceProxy since we are proxying the DataSource and inject the target datasource into the proxy via spring (see spring configs). I am attaching the patch again, striped by the reference to the JS2-666 issue.
        Hide
        Joachim Müller added a comment -

        strip the relations to JS2-666.

        Show
        Joachim Müller added a comment - strip the relations to JS2-666 .
        Hide
        Dennis Dam added a comment -

        Joachim, I should have looked more careful as well: BasicDataSource and TransactionAwareDataSourceProxy are completely different things ofcourse, one is put in front of the other.

        The new patch looks fine by me, and it doesn't break anything afaics.

        Show
        Dennis Dam added a comment - Joachim, I should have looked more careful as well: BasicDataSource and TransactionAwareDataSourceProxy are completely different things ofcourse, one is put in front of the other. The new patch looks fine by me, and it doesn't break anything afaics.
        Hide
        Ate Douma added a comment -

        I'll review the new patch tomorrow

        Show
        Ate Douma added a comment - I'll review the new patch tomorrow
        Hide
        Ate Douma added a comment -

        Patch looks fine by me too and I'll commit it shortly.

        Show
        Ate Douma added a comment - Patch looks fine by me too and I'll commit it shortly.
        Hide
        Ate Douma added a comment -

        Patch applied.

        Show
        Ate Douma added a comment - Patch applied.

          People

          • Assignee:
            Ate Douma
            Reporter:
            Joachim Müller
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development