}
// If under a transaction, don't start monitoring
DirectoryResource rootDirectory = project.getRoot().reify(DirectoryResource.class);
if (rootDirectory != null && rootDirectory.getUnderlyingResourceObject().exists())
{
final ResourceMonitor monitor = rootDirectory.monitor();
ListenerRegistration<ResourceListener> registration = monitor.addResourceListener(new ResourceListener()
{
@Override
public void processEvent(ResourceEvent event)
{
for (ProjectCache cache : caches)
{
try
{
cache.evict(project);
}
finally
{
caches.release(cache);
}
}
monitor.cancel();
}
});
this.listeners.add(registration);
}
}