Class SchemaDelegatingProperties

java.lang.Object
com.broadleafcommerce.common.jpa.data.SchemaDelegatingProperties

public class SchemaDelegatingProperties extends Object
Additional properties that define datasource configuration that employs SchemaDelegatingDataSource and included as part of a larger JpaPropertyRelated property file. This allows through configuration alone a setup that declares multiple datasources (each tied to a schema) backed by a common base datasource. This config is generally employed as part of a uber service installation where multiple services run together in a single JVM.

Configuration is achieved similar to the following:
 broadleaf:
   database:
     provider: jpa
   composite:
     datasource:
       url: 'jdbc:postgresql://localhost:5432/broadleaf'
       username: broadleaf
       password: demo
       hikari:
         maximumPoolSize: 10
       properties:
         hibernate:
           jdbc:
             lob:
               non_contextual_creation: true
   adminnavigation:
     liquibase:
       change-log: 'classpath:/db/changelog/adminnavigation.postgres.changelog-master.yaml'
       liquibase-schema: public
       default-schema: adminnavigation
     delegating:
       schema: adminnavigation
       delegate-ref: composite
 

Note, that an arbitrary datasource configuration (honoring structure described in DataSourceProperties) is included at broadleaf.composite (the broadleaf prefix is inferred by the system). This represents the base datasource to which connection retrieval is delegated. Then, in broadleaf.adminnavigation.delegating, we describe the properties fulfilled here in SchemaDelegatingProperties, which are realized in SchemaDelegatingDataSource. Note that delegate-ref is pointing back to the base datasource configuration.

The properties here are optional and can be defined instead of JpaPropertyRelated.getDatasource(). If JpaPropertyRelated.getDatasource() related properties are used in configuration instead, it is assumed the service wishes to utilize a traditional, isolated datasource. Several services in an overall uber configuration may use JpaPropertyRelated.getDatasource(), while others may instead composite datasource connection management through JpaPropertyRelated.getDelegating() related properties. Different combinations may be employed and there are no restrictions to quantity of either.
Author:
Jeff Fischer
  • Constructor Details

    • SchemaDelegatingProperties

      public SchemaDelegatingProperties()
  • Method Details

    • getSchema

      public String getSchema()
      The schema that borrowed connections should be initialized to in SchemaDelegatingDataSource.
    • setSchema

      public void setSchema(String schema)
      The schema that borrowed connections should be initialized to in SchemaDelegatingDataSource.
    • getDelegateRef

      public String getDelegateRef()
      The back-reference to another section of configuration that fully describes the base datasource backing the SchemaDelegatingDataSource.
    • setDelegateRef

      public void setDelegateRef(String delegateRef)
      The back-reference to another section of configuration that fully describes the base datasource backing the SchemaDelegatingDataSource.