You create a data source by extending the DataSource abstract class and other supporting classes.

A DataSource requires an @CasDataSource annotation. The annotation has several important attributes you can configure:

The listModules task of the CAS Server Command-line Utility and the listModules()call of the CAS Server API both return the attribute values you specify in the @CasDataSource annotations.

To create a data source extension:

  1. Create a Java project in your development environment of your choice.

    If you are creating several extensions in one plug-in, you can use the same Java project for each extension.

  2. Add the CAS Extension API libraries to your compile classpath. These include all the libraries available in <install path>\CAS\version\lib\cas-extension-api.

  3. Create a subclass of DataSource and specify the PipelineComponentConfiguration subclass that the extension uses. The DataSource requires a zero-argument constructor.

    For example:

    public class CsvDataSource extends DataSource<CsvDataSourceRuntime,CsvDataSourceConfig>{
    
    }
  4. Add a @CasDataSource annotation to the DataSource class.

    For example:

    @CasDataSource(displayName="CSV File", description="Reads comma separated files")
    public class CsvDataSource extends DataSource<CsvDataSourceRuntime,CsvDataSourceConfig>{
    
    }
  5. Implement the getConfigurationClass() method to return the appropriate PipelineComponentConfiguration subclass.

    For example:

    public Class<CsvDataSourceConfig> getConfigurationClass() {
    		return CsvDataSourceConfig.class;
    }
  6. Implement the createDataSourceRuntime() method to create an implementation of the DataSourceRuntime class.

    For example:

    public CsvDataSourceRuntime createDataSourceRuntime(
    			CsvDataSourceConfig config, PipelineComponentRuntimeContext context) {
    		return new CsvDataSourceRuntime(context, config);
    	}
  7. Implement the getRuntimeClass() method to return the runtime class the data source creates.

    For example:

    	public Class<CsvDataSourceRuntime> getRuntimeClass() {
    		return CsvDataSourceRuntime.class;
    	}
  8. Optionally, override the deleteInstance() method. CAS Server calls deleteInstance() when it removes an extension. In this method, you can perform any clean up that is necessary when CAS Server calls deleteInstance() to remove the extension from an acquisition. The default implementation of deleteInstance() is empty.



Copyright © Legal Notices