use of org.apache.cayenne.event.EventManager in project cayenne by apache.
the class DataContext method attachToChannel.
/**
* @since 3.1
*/
@Override
protected void attachToChannel(DataChannel channel) {
super.attachToChannel(channel);
if (mergeHandler != null) {
mergeHandler.setActive(false);
mergeHandler = null;
}
EventManager eventManager = channel.getEventManager();
if (eventManager != null) {
mergeHandler = new DataContextMergeHandler(this);
// listen to our channel events...
// note that we must reset listener on channel switch, as there is
// no
// guarantee that a new channel uses the same EventManager.
EventUtil.listenForChannelEvents(channel, mergeHandler);
}
if (!usingSharedSnaphsotCache && getObjectStore() != null) {
DataRowStore cache = getObjectStore().getDataRowCache();
if (cache != null) {
cache.setEventManager(eventManager);
}
}
}
use of org.apache.cayenne.event.EventManager in project cayenne by apache.
the class CayenneContext method attachToChannel.
/**
* @since 3.1
*/
@Override
protected void attachToChannel(DataChannel channel) {
super.attachToChannel(channel);
if (mergeHandler != null) {
mergeHandler.active = false;
mergeHandler = null;
}
EventManager eventManager = channel.getEventManager();
if (eventManager != null) {
mergeHandler = new CayenneContextMergeHandler(this);
// listen to our channel events...
// note that we must reset listener on channel switch, as there is
// no
// guarantee that a new channel uses the same EventManager.
EventUtil.listenForChannelEvents(channel, mergeHandler);
}
}
use of org.apache.cayenne.event.EventManager in project cayenne by apache.
the class BaseContext method fireDataChannelChanged.
/**
* @since 1.2
*/
protected void fireDataChannelChanged(Object postedBy, GraphDiff changes) {
EventManager manager = getEventManager();
if (manager != null) {
GraphEvent e = new GraphEvent(this, postedBy, changes);
manager.postEvent(e, DataChannel.GRAPH_CHANGED_SUBJECT);
}
}
use of org.apache.cayenne.event.EventManager in project cayenne by apache.
the class ClientRuntimeTest method testShutdown.
@Test
public void testShutdown() throws Exception {
Map<String, String> properties = new HashMap<>();
ClientRuntime runtime = ClientRuntime.builder().properties(properties).build();
// make sure objects to be shut down are resolved
EventManager em = runtime.getInjector().getInstance(EventManager.class);
assertNotNull(em);
assertTrue(em instanceof DefaultEventManager);
assertFalse(((DefaultEventManager) em).isStopped());
runtime.getInjector().shutdown();
assertTrue(((DefaultEventManager) em).isStopped());
}
Aggregations