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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RoutableDataSourcecreateRoutableInstance(DataSource original, String key, int order, Class<?>... supportingClasses) Create aRoutableDataSourceproxy wrapping aDataSource.static RoutableDataSourcecreateRoutableInstance(DataSource original, String key, Class<?>... supportingClasses) Create aRoutableDataSourceproxy wrapping aDataSource.
-
Constructor Details
-
DataSourceUtil
public DataSourceUtil()
-
-
Method Details
-
createRoutableInstance
public static RoutableDataSource createRoutableInstance(DataSource original, String key, Class<?>... supportingClasses) Create aRoutableDataSourceproxy wrapping aDataSource.- Parameters:
original- The originalDataSource.key- The lookup key for the route.supportingClasses- AnyDataRouteSupportingextensions that this route supports.- Returns:
- The proxied data source.
-
createRoutableInstance
public static RoutableDataSource createRoutableInstance(DataSource original, String key, int order, Class<?>... supportingClasses) Create aRoutableDataSourceproxy 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- AnyDataRouteSupportingextensions that this route supports.- Returns:
- The proxied data source.
-