com.gigaspaces.datasource.dotnet
Class DotNetDataSourceAdapter

java.lang.Object
  extended by com.gigaspaces.serialization.pbs.commands.DispatcherObjectProxy
      extended by com.gigaspaces.serialization.pbs.commands.ConstructableDispatcherObjectProxy
          extended by com.gigaspaces.datasource.dotnet.DotNetDataSourceAdapter
All Implemented Interfaces:
BulkDataPersister, ManagedDataSource<IGSEntry>, SQLDataProvider<IGSEntry>

public class DotNetDataSourceAdapter
extends com.gigaspaces.serialization.pbs.commands.ConstructableDispatcherObjectProxy
implements SQLDataProvider<IGSEntry>, BulkDataPersister

 DotNetDataSourceAdapter is a proxy to a custom .Net implementation of space external data source.
 Every method call by the space will be executed remotely in a custom .Net implementation of the
 ISqlDataSource interface which is correlated to the Java SqlDataProvider and BulkDataPersister interface.
 
 
  <b>Configuration</b>
 
  To use the DotNetDataSourceAdapter the space schema XML configuration file should include the following.
 
  <space-config>
  <persistent>
  <enabled>true</enabled>
  <StorageAdapterClass>com.gigaspaces.datasource.DataAdapter</StorageAdapterClass>
 
  </persistent>
 
  <external-data-source>
  <data-source-class>com.gigaspaces.datasource.dotnet.DotNetAdapter</data-source-class>
  <data-class>System.Object</data-class>
  <init-properties-file><properties file></init-properties-file>
  </external-data-source>
 
  </space-config>
 
  You need to configure <properties file> file, in it you can choose between the two options: 
  1) Use a .Net configuration file in order to configure the .Net SqlDataSource implementation
  in this case define the following and point it to your .Net config file:
  dotnet-config-file=<.Net config file>
  2) Configure everything in the java properties file:
  dotnet-implementation-name=<.Net fully qualified Type name of the implementation of the ISqlDataSource interface>
  dotnet-assembly-file=<.Net assembly file path containing the ISqlDataSource implementation>
  dotnet-dependencies-files=<Additional .Net assemblies that needs to be loaded>
  
  Any additional implementation's custom properties can also be put into this file
 

Since:
6.5

Field Summary
static String AssemblyFileProperty
           
static String ConfigFileProperty
           
static String DependenciesProperty
           
static String ImplementationNameProperty
           
static String IteratorBatchSizeProperty
           
 
Fields inherited from class com.gigaspaces.serialization.pbs.commands.DispatcherObjectProxy
autoDisposeOnGC, contextAppDomainId, handleInjected, isDisposed
 
Fields inherited from interface com.gigaspaces.datasource.ManagedDataSource
DATA_CLASS_PROPS, NUMBER_OF_PARTITIONS, STATIC_PARTITION_NUMBER
 
Constructor Summary
DotNetDataSourceAdapter()
           
DotNetDataSourceAdapter(long dotnetEdsHandleId, int contextAppDomainId, Properties customProperties)
           
 
Method Summary
 void executeBulk(List<BulkItem> bulk)
          Execute given bulk of operations.
 void init(Properties prop)
          Initialize and configure the data source using given properties.
 DataIterator<IGSEntry> initialLoad()
           Creates and returns an iterator over all the entries that should be loaded into space.
 DataIterator<IGSEntry> iterator(SQLQuery<IGSEntry> query)
          
 Create an iterator over all objects that match the given SQLQuery.
 void setConfigFile(String configFile)
          Inject a .Net config file (Should be called prior to init, otherwise its effect is dismissed
 void setIteratorBatchSize(int size)
          Inject an iterator batch size file
 void shutdown()
          Close the data source and clean any used resources.
 
Methods inherited from class com.gigaspaces.serialization.pbs.commands.ConstructableDispatcherObjectProxy
setAssemblyFile, setCustomProperties, setDependencies, setHandleId, setImplementationName
 
Methods inherited from class com.gigaspaces.serialization.pbs.commands.DispatcherObjectProxy
getHandleId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ConfigFileProperty

public static final String ConfigFileProperty
See Also:
Constant Field Values

IteratorBatchSizeProperty

public static final String IteratorBatchSizeProperty
See Also:
Constant Field Values

ImplementationNameProperty

public static final String ImplementationNameProperty
See Also:
Constant Field Values

AssemblyFileProperty

public static final String AssemblyFileProperty
See Also:
Constant Field Values

DependenciesProperty

public static final String DependenciesProperty
See Also:
Constant Field Values
Constructor Detail

DotNetDataSourceAdapter

public DotNetDataSourceAdapter(long dotnetEdsHandleId,
                               int contextAppDomainId,
                               Properties customProperties)

DotNetDataSourceAdapter

public DotNetDataSourceAdapter()
Method Detail

setConfigFile

public void setConfigFile(String configFile)
Inject a .Net config file (Should be called prior to init, otherwise its effect is dismissed

Parameters:
configFile -

setIteratorBatchSize

public void setIteratorBatchSize(int size)
Inject an iterator batch size file

Parameters:
size -

iterator

public DataIterator<IGSEntry> iterator(SQLQuery<IGSEntry> query)
                                throws DataSourceException
 Create an iterator over all objects that match the given SQLQuery.
 SQLQuery contains a string representation of SQL 'where' clause.
 The format matches the PreparedStatement format(field1 = ? and field2 > ? and ....).
 The prepared values are accessible by SQLQuery.getPreparedValues() method
 
 Example implementation with SQL PreparedStatement:
 
 
 PreparedStatement st = con.prepareStatement(query.getSelectAllQuery());
 
 int index = 0;
 
 if(query.hasPreparedValues())
 {
        for(Iterator iter = query.getPreparedValues().iterator();iter.hasNext())
        {
                st.setObject(++index,iter.next());
        }
 }
 
 ResultSet rs = st.executeQuery();
 
 return new ResultSetIterator(rs);
 
 

Specified by:
iterator in interface SQLDataProvider<IGSEntry>
Returns:
a DataIterator or null if no data was found that match the given template
Throws:
DataSourceException
See Also:
ResultSetIterator

init

public void init(Properties prop)
          throws DataSourceException
Initialize and configure the data source using given properties.
Called when space is started.
The properties are loaded from a file that can be defined in the space schema or as a property named:

space-config.ExternalDataSource.properties-file partitionId and number of partitions are also in the Properties - can be read with STATIC_PARTITION_NUMBER and NUMBER_OF_PARTITIONS

Specified by:
init in interface ManagedDataSource<IGSEntry>
Parameters:
prop - - contains user defined param and Partition data
Throws:
DataSourceException

initialLoad

public DataIterator<IGSEntry> initialLoad()
                                   throws DataSourceException
Creates and returns an iterator over all the entries that should be loaded into space.

Specified by:
initialLoad in interface ManagedDataSource<IGSEntry>
Returns:
a DataIterator or null if no data should be loaded into space
Throws:
DataSourceException

shutdown

public void shutdown()
              throws DataSourceException
Close the data source and clean any used resources.
Called before space shutdown.

Specified by:
shutdown in interface ManagedDataSource<IGSEntry>
Throws:
DataSourceException

executeBulk

public void executeBulk(List<BulkItem> bulk)
                 throws DataSourceException
Execute given bulk of operations.
Each BulkItem contains one of the following operation -

WRITE - given object should be inserted to the data store,
UPDATE - given object should be updated in the data store,
REMOVE - given object should be deleted from the data store

If the implementation uses transactions,
all the bulk operations must be executed in one transaction.

Specified by:
executeBulk in interface BulkDataPersister
Parameters:
bulk - list of data object and the operation to apply on that object
Throws:
DataSourceException - when the data store fails to persist the given list of objects