protected List<IContainer> getVisibleContainers(Resource resource) { IResourceDescription description = descriptionManager.getResourceDescription(resource); IResourceDescriptions resourceDescriptions = getResourceDescriptions(resource); String cacheKey = getCacheKey("VisibleContainers", resource.getResourceSet()); OnChangeEvictingCache.CacheAdapter cache = new OnChangeEvictingCache().getOrCreate(resource); List<IContainer> result = null; result = cache.get(cacheKey); if (result == null) { result = containerManager.getVisibleContainers(description, resourceDescriptions); // SZ: I'ld like this dependency to be moved to the implementation of the // container manager, but it is not aware of a CacheAdapter if (resourceDescriptions instanceof IResourceDescription.Event.Source) { IResourceDescription.Event.Source eventSource = (Source) resourceDescriptions; DelegatingEventSource delegatingEventSource = new DelegatingEventSource(eventSource); delegatingEventSource.addListeners(Lists.newArrayList(Iterables.filter(result, IResourceDescription.Event.Listener.class))); delegatingEventSource.initialize(); cache.addCacheListener(delegatingEventSource); } cache.set(cacheKey, result); } return result; }