Class DataSourceUtil

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

public class DataSourceUtil extends Object
Utility for creating proxied DataSource instances that also expose the RoutableDataSource interface for participation in a composite, routing RoutingJpaDataSource instance. Such a composite datasource is capable of delegating data source duty to one or more backing data sources at runtime based on DataRouteContext ThreadLocal state. This state is meant to identify the desired backing datasource for the current flow while still allowing a common data repository implementation for multiple flows.
Author:
Jeff Fischer
  • Constructor Details

    • DataSourceUtil

      public DataSourceUtil()
  • Method Details

    • createRoutableInstance

      public static RoutableDataSource createRoutableInstance(DataSource original, String key, Class<?>... supportingClasses)
      Create a RoutableDataSource proxy wrapping a DataSource.
      Parameters:
      original - The original DataSource.
      key - The lookup key for the route.
      supportingClasses - Any DataRouteSupporting extensions that this route supports.
      Returns:
      The proxied data source.
    • createRoutableInstance

      public static RoutableDataSource createRoutableInstance(DataSource original, String key, int order, Class<?>... supportingClasses)
      Create a RoutableDataSource proxy wrapping a DataSource.
      Parameters:
      original - The original DataSource.
      key - The lookup key for the route.
      order - The order in which the routable datasources will be reviewed for matches in RoutingJpaDataSource.
      supportingClasses - Any DataRouteSupporting extensions that this route supports.
      Returns:
      The proxied data source.