Class DelegatingDataSourceFactory
- java.lang.Object
-
- org.apache.cayenne.configuration.server.DelegatingDataSourceFactory
-
- All Implemented Interfaces:
DataSourceFactory
public class DelegatingDataSourceFactory extends Object implements DataSourceFactory
ADataSourceFactorythat delegates DataSource creation to another factory, which is determined dynamically per DataNodeDescriptor. The delegate class may be explicitly defined in theDataNodeDescriptor. If not, and if the descriptor has a configuration resource attached to it,XMLPoolingDataSourceFactoryis used.If the environment contains properties cayenne.jdbc.url.domain_name.node_name (or cayenne.jdbc.url) and cayenne.jdbc.driver.domain_name.node_name (or cayenne.jdbc.driver), any DataSourceFactory configured in the DataNodeDescriptor is ignored, and the
PropertyDataSourceFactoryis used.- Since:
- 3.1
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<DataSource,ScopeEventListener>managedDataSourcesprotected AdhocObjectFactoryobjectFactoryprotected RuntimePropertiesproperties
-
Constructor Summary
Constructors Constructor Description DelegatingDataSourceFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidattachToScope(DataSource dataSource)Ensure that DataSource implementations returned from this factory receiveBeforeScopeEndevents.DataSourcegetDataSource(DataNodeDescriptor nodeDescriptor)Returns DataSource object based on the configuration provided in the "nodeDescriptor".protected DataSourceFactorygetDataSourceFactory(DataNodeDescriptor nodeDescriptor)protected booleanshouldConfigureDataSourceFromProperties(DataNodeDescriptor nodeDescriptor)voidshutdown()
-
-
-
Field Detail
-
objectFactory
protected AdhocObjectFactory objectFactory
-
properties
protected RuntimeProperties properties
-
managedDataSources
protected Map<DataSource,ScopeEventListener> managedDataSources
-
-
Method Detail
-
getDataSource
public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception
Description copied from interface:DataSourceFactoryReturns DataSource object based on the configuration provided in the "nodeDescriptor".- Specified by:
getDataSourcein interfaceDataSourceFactory- Throws:
Exception
-
shutdown
@BeforeScopeEnd public void shutdown()
-
attachToScope
protected void attachToScope(DataSource dataSource)
Ensure that DataSource implementations returned from this factory receiveBeforeScopeEndevents.
-
getDataSourceFactory
protected DataSourceFactory getDataSourceFactory(DataNodeDescriptor nodeDescriptor)
-
shouldConfigureDataSourceFromProperties
protected boolean shouldConfigureDataSourceFromProperties(DataNodeDescriptor nodeDescriptor)
-
-