Class DataSourceUtil
java.lang.Object
com.broadleafcommerce.common.jpa.data.DataSourceUtil
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic RoutableDataSource
createRoutableInstance
(DataSource original, String key, int order, Class<?>... supportingClasses) Create aRoutableDataSource
proxy wrapping aDataSource
.static RoutableDataSource
createRoutableInstance
(DataSource original, String key, Class<?>... supportingClasses) Create aRoutableDataSource
proxy wrapping aDataSource
.
-
Constructor Details
-
DataSourceUtil
public DataSourceUtil()
-
-
Method Details
-
createRoutableInstance
public static RoutableDataSource createRoutableInstance(DataSource original, String key, Class<?>... supportingClasses) Create aRoutableDataSource
proxy wrapping aDataSource
.- Parameters:
original
- The originalDataSource
.key
- The lookup key for the route.supportingClasses
- AnyDataRouteSupporting
extensions that this route supports.- Returns:
- The proxied data source.
-
createRoutableInstance
public static RoutableDataSource createRoutableInstance(DataSource original, String key, int order, Class<?>... supportingClasses) Create aRoutableDataSource
proxy wrapping aDataSource
.- Parameters:
original
- The originalDataSource
.key
- The lookup key for the route.order
- The order in which the routable datasources will be reviewed for matches inRoutingJpaDataSource
.supportingClasses
- AnyDataRouteSupporting
extensions that this route supports.- Returns:
- The proxied data source.
-