use of org.neo4j.kernel.impl.transaction.xaframework.XaDataSource in project neo4j-mobile-android by neo4j-contrib.
the class TxModule method registerDataSource.
/**
* Use this method to add data source that can participate in transactions
* if you don't want a data source configuration file.
*
* @param name
* The data source name
* @param className
* The (full) class name of class
* @param resourceId
* The resource id identifying datasource
* @param params
* The configuration map for the datasource
* @throws LifecycleException
*/
public XaDataSource registerDataSource(String dsName, String className, byte[] resourceId, Map<?, ?> params) {
XaDataSourceManager xaDsMgr = xaDsManager;
String name = dsName.toLowerCase();
if (xaDsMgr.hasDataSource(name)) {
throw new TransactionFailureException("Data source[" + name + "] has already been registered");
}
try {
XaDataSource dataSource = xaDsMgr.create(className, params);
xaDsMgr.registerDataSource(name, dataSource, resourceId);
return dataSource;
} catch (Exception e) {
throw new TransactionFailureException("Could not create data source [" + name + "], see nested exception for cause of error", e.getCause());
}
}
use of org.neo4j.kernel.impl.transaction.xaframework.XaDataSource in project neo4j-mobile-android by neo4j-contrib.
the class XaDataSourceManager method getBranchId.
synchronized byte[] getBranchId(XAResource xaResource) {
if (xaResource instanceof XaResource) {
byte[] branchId = ((XaResource) xaResource).getBranchId();
if (branchId != null) {
return branchId;
}
}
Iterator<Map.Entry<String, XaDataSource>> itr = dataSources.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry<String, XaDataSource> entry = itr.next();
XaDataSource dataSource = entry.getValue();
XAResource resource = dataSource.getXaConnection().getXaResource();
try {
if (resource.isSameRM(xaResource)) {
String name = entry.getKey();
return sourceIdMapping.get(name);
}
} catch (XAException e) {
throw new TransactionFailureException("Unable to check is same resource", e);
}
}
throw new TransactionFailureException("Unable to find mapping for XAResource[" + xaResource + "]");
}
use of org.neo4j.kernel.impl.transaction.xaframework.XaDataSource in project neo4j-mobile-android by neo4j-contrib.
the class XaDataSourceManager method unregisterAllDataSources.
synchronized void unregisterAllDataSources() {
branchIdMapping.clear();
sourceIdMapping.clear();
Iterator<XaDataSource> itr = dataSources.values().iterator();
while (itr.hasNext()) {
XaDataSource dataSource = itr.next();
dataSource.close();
}
dataSources.clear();
}
use of org.neo4j.kernel.impl.transaction.xaframework.XaDataSource in project graphdb by neo4j-attic.
the class MasterUtil method packResponseWithoutTransactionStream.
public static <T> Response<T> packResponseWithoutTransactionStream(GraphDatabaseService graphDb, SlaveContext context, T response) {
XaDataSource ds = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager().getXaDataSource(Config.DEFAULT_DATA_SOURCE_NAME);
StoreId storeId = ((NeoStoreXaDataSource) ds).getStoreId();
return new Response<T>(response, storeId, TransactionStream.EMPTY);
}
use of org.neo4j.kernel.impl.transaction.xaframework.XaDataSource in project graphdb by neo4j-attic.
the class Client method getMyStoreId.
protected StoreId getMyStoreId() {
if (myStoreId == null) {
XaDataSource ds = ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager().getXaDataSource(Config.DEFAULT_DATA_SOURCE_NAME);
myStoreId = ((NeoStoreXaDataSource) ds).getStoreId();
}
return myStoreId;
}
Aggregations