{
try
{
final CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
final NodeCache cache = new NodeCache(entry.getClient(), path, dataIsCompressed);
cache.start(buildInitial);
Closer closer = new Closer()
{
@Override
public void close()
{
try
{
cache.close();
}
catch ( IOException e )
{
log.error("Could not close left-over NodeCache for path: " + path, e);
}
}
};
String id = entry.addThing(cache, closer);
NodeCacheListener listener = new NodeCacheListener()
{
@Override
public void nodeChanged()
{
entry.addEvent(new RpcCuratorEvent(RpcCuratorEventType.NODE_CACHE, path));
}
};
cache.getListenable().addListener(listener);
return new NodeCacheProjection(id);
}
catch ( Exception e )
{