net.refractions.udig.project
Interface IResourceCachingInterceptor


public interface IResourceCachingInterceptor

Controls the caching of resources returned by: ILayer#getResource(Class, org.eclipse.core.runtime.IProgressMonitor).

Example: If a new feature store was returned each time then every plugin that is interested in events would need to create a resource interceptor and every request for a FeatureStore would result in both a new FeatureStore and a new listener for every interested plugin. Since the Datastore's Listener manager often keeps the listeners indefinately then we would very quickly have 10s to 100s of listeners that can't be garbage collected and possibly featurestores as well.

The "active" caching strategy is stored in the ProjectPlugin.getPlugin().getPreferenceStore().getString( "P_LAYER_RESOURCE_CACHING_STRATEGY" ).

Set the preference to activate a custom Caching strategy.

Since:
1.1.0
Author:
Jesse

Method Summary
<T> T
get(ILayer layer, java.lang.Class<T> requestedType)
          Obtains the resource from the cache.
<T> boolean
isCached(ILayer layer, IGeoResource geoResource, java.lang.Class<T> requestedType)
          Called to see if the resource should be obtained from cache
<T> void
put(ILayer layer, T resource, java.lang.Class<T> requestedType)
          Caches the resource.
 

Method Detail

isCached

<T> boolean isCached(ILayer layer,
                     IGeoResource geoResource,
                     java.lang.Class<T> requestedType)
Called to see if the resource should be obtained from cache

Type Parameters:
T - the type of the resource. Can be most any type of Object
Parameters:
layer - the layer that the resource is being obtained from
geoResource - the resource obtained from the GeoResource. NO interceptors have ran on the resource.
requestedType - the type of object that the caller requested
Returns:
true if the resource should be obtained from the cache.

get

<T> T get(ILayer layer,
          java.lang.Class<T> requestedType)
Obtains the resource from the cache.

Type Parameters:
T - the type of the resource. Can be most any type of Object
Parameters:
layer - the layer that the resource is being obtained from
requestedType - the type of object that the caller requested
Returns:
the cached instance of the resource.

put

<T> void put(ILayer layer,
             T resource,
             java.lang.Class<T> requestedType)
Caches the resource.

Type Parameters:
T - the type of the resource. Can be most any type of Object
Parameters:
layer - the layer that the resource is being obtained from
resource - the resource obtained from the GeoResource. All the PRE interceptors have ran on the resource.
requestedType - the type of object that the caller requested