use of org.apache.cayenne.event.EventManager in project cayenne by apache.
the class CayenneContextGraphManager method send.
/**
* Wraps GraphDiff in a GraphEvent and sends it via EventManager with specified
* subject.
*/
void send(GraphDiff diff, EventSubject subject, Object eventSource) {
EventManager manager = (context.getChannel() != null) ? context.getChannel().getEventManager() : null;
if (manager != null) {
GraphEvent e = new GraphEvent(context, eventSource, diff);
manager.postEvent(e, subject);
}
}
use of org.apache.cayenne.event.EventManager in project cayenne by apache.
the class BaseContext method fireDataChannelRolledback.
/**
* @since 1.2
*/
protected void fireDataChannelRolledback(Object postedBy, GraphDiff changes) {
EventManager manager = getEventManager();
if (manager != null) {
GraphEvent e = new GraphEvent(this, postedBy, changes);
manager.postEvent(e, DataChannel.GRAPH_ROLLEDBACK_SUBJECT);
}
}
use of org.apache.cayenne.event.EventManager in project cayenne by apache.
the class BaseContext method fireDataChannelCommitted.
/**
* @since 1.2
*/
protected void fireDataChannelCommitted(Object postedBy, GraphDiff changes) {
EventManager manager = getEventManager();
if (manager != null) {
GraphEvent e = new GraphEvent(this, postedBy, changes);
manager.postEvent(e, DataChannel.GRAPH_FLUSHED_SUBJECT);
}
}
use of org.apache.cayenne.event.EventManager in project cayenne by apache.
the class DataContextFactoryTest method testCreateDataContextWithDedicatedCache.
@Test
public void testCreateDataContextWithDedicatedCache() throws Exception {
final EventManager eventManager = new MockEventManager();
final DataDomain domain = new DataDomain("d1");
domain.setSharedCacheEnabled(false);
Module testModule = binder -> {
binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class);
binder.bind(DataDomain.class).toInstance(domain);
binder.bind(EventManager.class).toInstance(eventManager);
binder.bind(QueryCache.class).toInstance(new MapQueryCache(5));
binder.bind(RuntimeProperties.class).toInstance(new DefaultRuntimeProperties(Collections.<String, String>emptyMap()));
binder.bind(ObjectMapRetainStrategy.class).to(DefaultObjectMapRetainStrategy.class);
binder.bind(ObjectStoreFactory.class).to(DefaultObjectStoreFactory.class);
binder.bind(TransactionFactory.class).to(DefaultTransactionFactory.class);
binder.bind(TransactionManager.class).to(DefaultTransactionManager.class);
binder.bind(DataRowStoreFactory.class).to(DefaultDataRowStoreFactory.class);
binder.bind(EventBridge.class).toProvider(NoopEventBridgeProvider.class);
binder.bind(DataRowStoreFactory.class).to(DefaultDataRowStoreFactory.class);
};
Injector injector = DIBootstrap.createInjector(testModule);
DataContextFactory factory = new DataContextFactory();
injector.injectMembers(factory);
DataContext c3 = (DataContext) factory.createContext();
assertNotNull(c3.getObjectStore().getDataRowCache());
assertNull(domain.getSharedSnapshotCache());
assertNotSame(c3.getObjectStore().getDataRowCache(), domain.getSharedSnapshotCache());
}
use of org.apache.cayenne.event.EventManager in project cayenne by apache.
the class DefaultDataRowStoreFactoryIT method testGetDataRowStoreWithBridge.
@Test
public void testGetDataRowStoreWithBridge() {
final DataDomain DOMAIN = new DataDomain("test");
final EventManager EVENT_MANAGER = new DefaultEventManager();
Module testModule = binder -> {
binder.bind(DataDomain.class).toInstance(DOMAIN);
binder.bind(EventManager.class).toInstance(EVENT_MANAGER);
binder.bind(TransactionManager.class).to(DefaultTransactionManager.class);
binder.bind(TransactionFactory.class).to(DefaultTransactionFactory.class);
binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class);
binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class);
binder.bind(EventBridge.class).toProvider(MockEventBridgeProvider.class);
binder.bind(DataRowStoreFactory.class).to(DefaultDataRowStoreFactory.class);
ServerModule.contributeProperties(binder);
};
Injector injector = DIBootstrap.createInjector(testModule);
DataRowStore dataStore = injector.getInstance(DataRowStoreFactory.class).createDataRowStore("test");
assertEquals(dataStore.getEventBridge().getClass(), MockEventBridge.class);
}
Aggregations