org.deegree.commons.config
Class AbstractResourceManager<T extends Resource>

java.lang.Object
  extended by org.deegree.commons.config.AbstractBasicResourceManager
      extended by org.deegree.commons.config.AbstractResourceManager<T>
All Implemented Interfaces:
ExtendedResourceManager<T>, ResourceManager
Direct Known Subclasses:
CoverageBuilderManager, FeatureStoreManager, LayerStoreManager, MetadataStoreManager, ProcessManager, RemoteOWSManager, RemoteOWSStoreManager, StyleStoreManager, ThemeManager, WebServicesConfiguration

public abstract class AbstractResourceManager<T extends Resource>
extends AbstractBasicResourceManager
implements ExtendedResourceManager<T>

Version:
$Revision: 31619 $, $Date: 2011-08-23 14:56:28 +0200 (Tue, 23 Aug 2011) $
Author:
Andreas Schmitz, last edited by: $Author: mschneider $

Field Summary
protected  String name
           
protected  HashMap<String,ExtendedResourceProvider<T>> nsToProvider
           
 
Fields inherited from class org.deegree.commons.config.AbstractBasicResourceManager
dir, idToState, workspace
 
Constructor Summary
AbstractResourceManager()
           
 
Method Summary
 ResourceState<T> activate(String id)
          Activates the resource with the given identifier.
protected  void add(T resource)
          Called when a new Resource has been successfully initialized.
 T create(String id, URL configUrl)
          Is used to obtain a resource instance from a configuration url and register it.
 ResourceState<T> deactivate(String id)
          Deactivates the resource with the given identifier.
 T get(String id)
          Is used to obtain a resource instance from an id.
protected  ExtendedResourceProvider<T> getProvider(File file)
           
protected  ResourceState<T> processResourceConfig(File configFile)
          Processes the given resource configuration file and returns the resulting resource state.
protected  void remove(String id)
           
protected  void remove(T resource)
          Called when a formerly active Resource is going to be destroyed.
 void shutdown()
          Is called upon workspace shutdown.
 void startup(DeegreeWorkspace workspace)
          Is called upon workspace startup.
 
Methods inherited from class org.deegree.commons.config.AbstractBasicResourceManager
createResource, deleteResource, getState, getStates, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.deegree.commons.config.ExtendedResourceManager
getMetadata, initMetadata
 
Methods inherited from interface org.deegree.commons.config.ResourceManager
createResource, deleteResource, getDependencies, getState, getStates
 

Field Detail

nsToProvider

protected final HashMap<String,ExtendedResourceProvider<T extends Resource>> nsToProvider

name

protected String name
Constructor Detail

AbstractResourceManager

public AbstractResourceManager()
Method Detail

add

protected void add(T resource)
Called when a new Resource has been successfully initialized.

Parameters:
resource -

remove

protected void remove(T resource)
Called when a formerly active Resource is going to be destroyed.

Parameters:
resource -

create

public T create(String id,
                URL configUrl)
                          throws ResourceInitException
Description copied from interface: ExtendedResourceManager
Is used to obtain a resource instance from a configuration url and register it. The creation is usually delegated to an appropriate ResourceProvider.

Specified by:
create in interface ExtendedResourceManager<T extends Resource>
Parameters:
id - the desired id of the new resource
configUrl - the configuration url of the new resource
Returns:
the new resource instance
Throws:
ResourceInitException - if an error occurred while creating the resource

get

public T get(String id)
Description copied from interface: ExtendedResourceManager
Is used to obtain a resource instance from an id.

Specified by:
get in interface ExtendedResourceManager<T extends Resource>
Returns:
null, if no such resource has been registered

shutdown

public void shutdown()
Description copied from interface: ResourceManager
Is called upon workspace shutdown.

Specified by:
shutdown in interface ResourceManager

startup

public void startup(DeegreeWorkspace workspace)
             throws ResourceInitException
Description copied from interface: ResourceManager
Is called upon workspace startup.

Specified by:
startup in interface ResourceManager
Throws:
ResourceInitException

getProvider

protected ExtendedResourceProvider<T> getProvider(File file)
Specified by:
getProvider in class AbstractBasicResourceManager

remove

protected void remove(String id)
Specified by:
remove in class AbstractBasicResourceManager

processResourceConfig

protected ResourceState<T> processResourceConfig(File configFile)
                                                           throws IOException
Processes the given resource configuration file and returns the resulting resource state.

This method does not update the resource / state maps.

Parameters:
configFile - configuration file, must not be null
Returns:
resource state, never null
Throws:
IOException - if the resource filename is invalid / could not be processed

activate

public ResourceState<T> activate(String id)
Description copied from interface: ResourceManager
Activates the resource with the given identifier.

Specified by:
activate in interface ResourceManager
Parameters:
id - resource identifier, must not be null
Returns:
resource state after activation (may be unsuccessful), but never null

deactivate

public ResourceState<T> deactivate(String id)
Description copied from interface: ResourceManager
Deactivates the resource with the given identifier.

Specified by:
deactivate in interface ResourceManager
Parameters:
id - resource identifier, must not be null
Returns:
resource state after deactivation (may be unsuccessful), but never null


Copyright © 2011. All Rights Reserved.