Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-570

Creating datasources using the DatasourcesFraction should be straight forward

    Details

    • Type: Enhancement
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.0.0.Final
    • Fix Version/s: 2016.12.1
    • Component/s: core
    • Labels:
      None

      Description

      At current creating a datasource programatically is quite involved and requires hoop jumping

      We have to create a module for our driver:

      <?xml version="1.0" ?>
      <module xmlns="urn:jboss:module:1.3" name="org.postgresql">
          <resources>
              <artifact name="org.postgresql:postgresql:${version.postgresql}"/>
          </resources>
          <dependencies>
              <module name="javax.api"/>
              <module name="javax.transaction.api"/>
          </dependencies>
      </module>
      

      Then we need to define a driver and the datasource using our DatasourcesFraction:

      new DatasourcesFraction()
      .jdbcDriver("org.postgresql", (d) -> {
          d.driverClassName("org.postgresql.Driver");
          d.xaDatasourceClass("org.postgresql.xa.PGXADataSource");
          d.driverModuleName("org.postgresql");
      })
      .dataSource("MyDS", (ds) -> {
          ds.driverName("org.postgresql");
          ds.connectionUrl("jdbc:postgresql://localhost:5432/mydb");
          ds.userName("postgres");
          ds.password("password");
      });
      

      The 80% use case for adding drivers should be as straight forward as:

      Include the driver dependency in your pom.xml and then:

      new DatasourcesFraction()
      .dataSource("MyDS", (ds) -> {
          ds.driverName("org.postgresql");
          ds.connectionUrl("jdbc:postgresql://localhost:5432/mydb");
          ds.userName("postgres");
          ds.password("password");
      });
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  justinwyer Justin Wyer
                • Votes:
                  1 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: