use of org.apache.cayenne.access.DataContext in project cayenne by apache.
the class DataContextFactory method createdFromDataDomain.
protected ObjectContext createdFromDataDomain(DataDomain parent) {
// for new dataRowStores use the same name for all stores
// it makes it easier to track the event subject
DataRowStore snapshotCache = (parent.isSharedCacheEnabled()) ? parent.getSharedSnapshotCache() : dataRowStoreFactory.createDataRowStore(parent.getName());
DataContext context = newInstance(parent, objectStoreFactory.createObjectStore(snapshotCache));
context.setValidatingObjectsOnCommit(parent.isValidatingObjectsOnCommit());
context.setQueryCache(new NestedQueryCache(queryCache));
context.setTransactionFactory(transactionFactory);
return context;
}
use of org.apache.cayenne.access.DataContext in project cayenne by apache.
the class ClientLocalRuntimeTest method testGetConnection.
@Test
public void testGetConnection() {
final DataContext serverContext = mock(DataContext.class);
Module serverModule = binder -> binder.bind(ObjectContextFactory.class).toInstance(new ObjectContextFactory() {
public ObjectContext createContext(DataChannel parent) {
return null;
}
public ObjectContext createContext() {
return serverContext;
}
});
ClientRuntime runtime = ClientRuntime.builder().local(DIBootstrap.createInjector(serverModule)).build();
ClientConnection connection = runtime.getConnection();
assertNotNull(connection);
assertTrue(connection instanceof LocalConnection);
LocalConnection localConnection = (LocalConnection) connection;
assertTrue(localConnection.getChannel() instanceof ClientServerChannel);
ClientServerChannel clientServerChannel = (ClientServerChannel) localConnection.getChannel();
assertSame(serverContext, clientServerChannel.getParentChannel());
}
Aggregations