private static CompositeDataSourceConfiguration readConfiguration(CompositeDataSource dataSource, String confPath) { try (InputStream input = Configuration.getFileAsStream(confPath + "/datasources.xml", dataSource, "datasources.default.xml")) { CompositeDataSourceConfiguration conf = new CompositeDataSourceConfiguration(input); return conf; } catch (Exception ex) { Logger.getLogger(CompositeDataSourceConfiguration.class.getName()).log(Level.SEVERE, "Couldn't load DIIRT_HOME/" + confPath + "/datasources.xml", ex); return new CompositeDataSourceConfiguration(); } } }
public void programmaticCompositeDataSourceConfiguration() { // The recommended method to configure data sources is through // the configuration files in DIIRT_HOME. // If is needed, you can still change the configuration through // the programmatic API. This can be useful for unit testing // or standalone applications. You should not do this in shared // environment, like CS-Studio. // Create a composite data source, and add different data sources. // You can either add a DataSourceProvider or a DataSource. CompositeDataSource composite = new CompositeDataSource(); composite.putDataSource(new JCADataSourceProvider()); composite.putDataSource("sim", new SimulationDataSource()); // If no prefix is given to a channel, use JCA as default composite.setConfiguration(new CompositeDataSourceConfiguration().defaultDataSource("ca")); // Set the composite as the default PVManager.setDefaultDataSource(composite); // For more options, check CompositeDataSource. }