if (key == null)
{
throw new NullPointerException();
}
final ResourceFactoryCache factoryCache = getFactoryCache();
// ok, we have a handle to the data, and the data is current.
// Lets check whether we also have a cached result.
final Resource resource = factoryCache.get(key, target);
if (resource != null)
{
if (backend.isResourceUnchanged(this, resource))
{
// mama, look i am a good cache manager ...
return resource;
}
else
{
// someone evil changed one of the dependent resources ...
factoryCache.remove(resource);
}
}
final ResourceData loadedData = load(key);
final Resource newResource;
if (loadedData instanceof ResourceBundleData)
{
final ResourceBundleData resourceBundleData = (ResourceBundleData) loadedData;
final ResourceManager derivedManager = resourceBundleData.deriveManager(this);
newResource = backend.create(derivedManager, resourceBundleData, context, target);
if (isResourceCacheable(newResource))
{
if (EHCacheModule.CACHE_MONITOR.isDebugEnabled())
{
EHCacheModule.CACHE_MONITOR.debug("Storing created bundle-resource for key: " + key);
}
factoryCache.put(newResource);
if (key != newResource.getSource())
{
factoryCache.put(new BundleCacheResourceWrapper(newResource, key));
}
}
else
{
if (EHCacheModule.CACHE_MONITOR.isDebugEnabled())
{
EHCacheModule.CACHE_MONITOR.debug("Created bundle-resource is not cacheable for " + key);
}
}
}
else
{
newResource = backend.create(this, loadedData, context, target);
if (isResourceCacheable(newResource))
{
if (EHCacheModule.CACHE_MONITOR.isDebugEnabled())
{
EHCacheModule.CACHE_MONITOR.debug("Storing created resource for key: " + key);
}
factoryCache.put(newResource);
}
else
{
if (EHCacheModule.CACHE_MONITOR.isDebugEnabled())
{