org.springframework.extensions.surf.resource
Class ModelObjectResourceProvider

java.lang.Object
  extended by org.springframework.extensions.surf.resource.ModelObjectResourceProvider
All Implemented Interfaces:
ResourceProvider

public class ModelObjectResourceProvider
extends Object
implements ResourceProvider

An implementation of ResourceProvider which enables model objects to manage the configuration of named resources. Named resources can be retrieved from the model object, worked with and referenced programmatically. Resources are stored as part of the model object configuration. Examples: Alfresco Resource workspace://SpacesStore/NodeRef workspace/SpacesStore/Company Home/Data Dictionary URI (absolute or relative on endpoint) http://www:8080/a/b/c.gif /a/b/c.gif Web Application Files (relative to webapp always) /a/b/c.gif

Author:
muzquiano

Field Summary
protected  ModelObject object
           
protected  Map<String,Resource> resources
           
 
Constructor Summary
ModelObjectResourceProvider(ModelObject object)
          Instantiates a new model object resource provider.
 
Method Summary
 Resource addResource(String name, String resourceId)
          Adds/Creates a resource with the given name and resource id
 Resource addResource(String name, String protocolId, String endpointId, String objectId)
          Adds/Creates a resource with the given name, object id and endpoint id
 Resource getResource(String name)
          Looks up a resource with the given name
protected static org.dom4j.Element getResourceElement(ModelObject object, String name)
          Gets the resource element.
 Resource[] getResources()
          Returns the set of all resources
protected static org.dom4j.Element getResourcesElement(ModelObject object)
          Gets the resources element.
 Map<String,Resource> getResourcesMap()
          Returns the map of resources
 void removeResource(String name)
          Removes a resource with the given name
 void updateResource(String name, Resource resource)
          Updates a resource for the given name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

object

protected ModelObject object

resources

protected Map<String,Resource> resources
Constructor Detail

ModelObjectResourceProvider

public ModelObjectResourceProvider(ModelObject object)
Instantiates a new model object resource provider.

Parameters:
object - the object
Method Detail

getResource

public Resource getResource(String name)
Description copied from interface: ResourceProvider
Looks up a resource with the given name

Specified by:
getResource in interface ResourceProvider
Returns:

getResources

public Resource[] getResources()
Description copied from interface: ResourceProvider
Returns the set of all resources

Specified by:
getResources in interface ResourceProvider
Returns:

addResource

public Resource addResource(String name,
                            String resourceId)
Description copied from interface: ResourceProvider
Adds/Creates a resource with the given name and resource id

Specified by:
addResource in interface ResourceProvider
Returns:
resource

addResource

public Resource addResource(String name,
                            String protocolId,
                            String endpointId,
                            String objectId)
Description copied from interface: ResourceProvider
Adds/Creates a resource with the given name, object id and endpoint id

Specified by:
addResource in interface ResourceProvider
Returns:
resource

updateResource

public void updateResource(String name,
                           Resource resource)
Description copied from interface: ResourceProvider
Updates a resource for the given name

Specified by:
updateResource in interface ResourceProvider

removeResource

public void removeResource(String name)
Description copied from interface: ResourceProvider
Removes a resource with the given name

Specified by:
removeResource in interface ResourceProvider

getResourcesMap

public Map<String,Resource> getResourcesMap()
Description copied from interface: ResourceProvider
Returns the map of resources

Specified by:
getResourcesMap in interface ResourceProvider
Returns:

getResourcesElement

protected static org.dom4j.Element getResourcesElement(ModelObject object)
Gets the resources element.

Parameters:
object - the object
Returns:
the resources element

getResourceElement

protected static org.dom4j.Element getResourceElement(ModelObject object,
                                                      String name)
Gets the resource element.

Parameters:
object - the object
name - the name
Returns:
the resource element


Copyright © 2009 SpringSource, Inc. All Rights Reserved.