Package org.epics.gpclient.datasource
Class CompositeDataSource
- java.lang.Object
-
- org.epics.gpclient.datasource.DataSource
-
- org.epics.gpclient.datasource.CompositeDataSource
-
public class CompositeDataSource extends DataSource
A data source that can dispatch a request to multiple different data sources.This supports lazy initialization of DataSources: DataSourceProviders are initialized only if the a channel of the corresponding DataSource is opened. There is not penalty, then, if no channel is every opened.
- Author:
- carcassi
-
-
Field Summary
-
Fields inherited from class org.epics.gpclient.datasource.DataSource
exec
-
-
Constructor Summary
Constructors Constructor Description CompositeDataSource()
Creates a new CompositeDataSource.CompositeDataSource(CompositeDataSourceConfiguration conf)
Creates a new CompositeDataSource with the given configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes all DataSources that are registered in the composite.protected ChannelHandler
createChannel(String channelName)
Creates a channel handler for the given name.Map<String,ChannelHandler>
getChannels()
Returns the channel handlers for this data source.CompositeDataSourceConfiguration
getConfiguration()
The configuration used for the composite data source.Map<String,DataSourceProvider>
getDataSourceProviders()
Returns the data source providers registered to this composite data source.Map<String,DataSource>
getDataSources()
Returns the data sources used by this composite data source.void
putDataSource(String name, DataSource dataSource)
Adds/replaces the data source corresponding to the given name.void
putDataSource(DataSourceProvider dataSourceProvider)
Adds/replaces the data source corresponding to the given name.void
startRead(ReadSubscription readRecipe)
Starts the given read subscription.void
startWrite(WriteSubscription writeRecipe)
Starts the given write subscription.void
stopRead(ReadSubscription readRecipe)
Stops the given read subscription.void
stopWrite(WriteSubscription writeRecipe)
Stops the given write subscription.-
Methods inherited from class org.epics.gpclient.datasource.DataSource
channelHandlerLookupName, channelHandlerRegisterName
-
-
-
-
Constructor Detail
-
CompositeDataSource
public CompositeDataSource()
Creates a new CompositeDataSource.
-
CompositeDataSource
public CompositeDataSource(CompositeDataSourceConfiguration conf)
Creates a new CompositeDataSource with the given configuration.- Parameters:
conf
- the configuration for the new CompositeDataSource
-
-
Method Detail
-
getConfiguration
public CompositeDataSourceConfiguration getConfiguration()
The configuration used for the composite data source.- Returns:
- the configuration; can't be null
-
putDataSource
public void putDataSource(String name, DataSource dataSource)
Adds/replaces the data source corresponding to the given name.- Parameters:
name
- the name of the data sourcedataSource
- the data source to add/replace
-
putDataSource
public void putDataSource(DataSourceProvider dataSourceProvider)
Adds/replaces the data source corresponding to the given name.- Parameters:
dataSourceProvider
- the data source to add/replace
-
getDataSources
public Map<String,DataSource> getDataSources()
Returns the data sources used by this composite data source.Returns only the data sources that have been created.
- Returns:
- the registered data sources
-
getDataSourceProviders
public Map<String,DataSourceProvider> getDataSourceProviders()
Returns the data source providers registered to this composite data source.Returns all registered data sources.
- Returns:
- the registered data source providers
-
startRead
public void startRead(ReadSubscription readRecipe)
Description copied from class:DataSource
Starts the given read subscription.- Overrides:
startRead
in classDataSource
- Parameters:
readRecipe
- the subscription information
-
stopRead
public void stopRead(ReadSubscription readRecipe)
Description copied from class:DataSource
Stops the given read subscription.- Overrides:
stopRead
in classDataSource
- Parameters:
readRecipe
- the subscription information
-
startWrite
public void startWrite(WriteSubscription writeRecipe)
Description copied from class:DataSource
Starts the given write subscription.- Overrides:
startWrite
in classDataSource
- Parameters:
writeRecipe
- the subscription information
-
stopWrite
public void stopWrite(WriteSubscription writeRecipe)
Description copied from class:DataSource
Stops the given write subscription.- Overrides:
stopWrite
in classDataSource
- Parameters:
writeRecipe
- the subscription information
-
createChannel
protected ChannelHandler createChannel(String channelName)
Description copied from class:DataSource
Creates a channel handler for the given name. In the simplest case, this is the only method a data source needs to implement.- Specified by:
createChannel
in classDataSource
- Parameters:
channelName
- the name for a new channel- Returns:
- a new handler
-
close
public void close()
Closes all DataSources that are registered in the composite.- Overrides:
close
in classDataSource
-
getChannels
public Map<String,ChannelHandler> getChannels()
Description copied from class:DataSource
Returns the channel handlers for this data source.- Overrides:
getChannels
in classDataSource
- Returns:
- an unmodifiable collection
-
-