org.apache.muse.core
Interface ResourceManager

All Superinterfaces:
Initialization, Shutdown
All Known Implementing Classes:
OSGiResourceManager, SimpleResourceManager

public interface ResourceManager
extends Initialization, Shutdown

ResourceManager defines the interface for creating and storing resources that can be targeted by other resources (internal and external to a Muse-derived application). The resources' endpoint references (EPRs) are used to differentiate between resources in concrete implementations. This is the implied resource pattern required by WS-Addressing.

Note that ResourceManager does not initiate any lifecycle events - the addResource() method does not create a resource, and the removeResource() method does not destroy a resource. Other components can use the createResource() method to instantiate a resource and addResource() to make it visible to remote clients.

Author:
Dan Jemiolo (danj)
See Also:
Shutdown.shutdown()

Method Summary
 void addListener(ResourceManagerListener listener)
           
 void addResource(EndpointReference epr, Resource resource)
          Add a resource to the manager, associated with the given EPR.
 void addResourceDefinitions(Collection definitions)
           
 Resource createResource(String contextPath)
          Finds the resource type definition associated with the given context path (defined in muse.xml), instantiates an instance of the resource class, and sets the basic values (EPR, initialization parameters, etc.) and Muse components (Environment, log file, etc.) that it needs to operate.
 Environment getEnvironment()
           
 int getNumberOfResources()
           
 Resource getResource(EndpointReference epr)
           
 String getResourceContextPath(Class capabilityClass)
          This method allows you to find a resource type's endpoint URI given the Java interface or concrete class of one of its capabilities.
 Collection getResourceContextPaths()
           
 Collection getResourceContextPaths(Class capabilityClass)
          This method is just like getResourceContextPath(Class) except that it returns multiple endpoints that use the capability.
 Iterator getResourceEPRs()
           
 Iterator getResourceEPRs(String contextPath)
          This method allows you to search for the EPRs for all instances of a given resource type (where each resource type has a unique context path).
 boolean isUsingPersistence(String contextPath)
           
 void removeListener(ResourceManagerListener listener)
          Stops the given listener from receiving notifications about the addition and removal of resource instances.
 void removeResource(EndpointReference epr)
          Removes the EPR-resource pair from the manager.
 void removeResourceDefinitions(Collection definitions)
          Removes each ResourceDefinition in the given Collection.
 void setEnvironment(Environment env)
           
 
Methods inherited from interface org.apache.muse.core.Initialization
hasBeenInitialized, initialize
 
Methods inherited from interface org.apache.muse.core.Shutdown
hasBeenShutdown, shutdown
 

Method Detail

addListener

void addListener(ResourceManagerListener listener)
Parameters:
listener - A listener that will be fired whenever a resource is added or removed from the resource.

addResource

void addResource(EndpointReference epr,
                 Resource resource)
                 throws SoapFault
Add a resource to the manager, associated with the given EPR.

Parameters:
epr - The unique EPR identifying the resource instance.
resource -
Throws:
SoapFault -
  • If there is already a resource with the same EPR.
See Also:
getResource(EndpointReference)

addResourceDefinitions

void addResourceDefinitions(Collection definitions)
Parameters:
definitions - The ResourceDefinition objects that will be used to generate new resource instances.

createResource

Resource createResource(String contextPath)
                        throws SoapFault
Finds the resource type definition associated with the given context path (defined in muse.xml), instantiates an instance of the resource class, and sets the basic values (EPR, initialization parameters, etc.) and Muse components (Environment, log file, etc.) that it needs to operate.

The Resource object returned by this method has not been initialized yet. Once the Resource.initialize() method has been called, the resource should be added to the ResourceManager with the addResource() method.

Parameters:
contextPath - The context path for the resource type that is to be instantiated. This value is specified with the context-path element in muse.xml.
Returns:
An instance of the resource class. It will have a proper EPR, all of its capabilities, and references to all of the basic Muse components (Environment, log file, etc.). Calling code may further modify the resource before calling initialize() and making it available to clients.
Throws:
SoapFault

getEnvironment

Environment getEnvironment()
Returns:
The manager's access point for things such as the WS-Addressing context, file system resources, and more.

getNumberOfResources

int getNumberOfResources()
Returns:
The number of resource instances stored by the manager.

getResource

Resource getResource(EndpointReference epr)
Parameters:
epr - The unique EPR that is associated with the desired resource.
Returns:
The resource associated with the given EPR, or null if no such resource exists.

getResourceContextPath

String getResourceContextPath(Class capabilityClass)
This method allows you to find a resource type's endpoint URI given the Java interface or concrete class of one of its capabilities.

Parameters:
capabilityClass - An interface or concrete class for one of the capabilities in the application's resource types. This value may be defined in resource-type/capability/java-capability-class in muse.xml.
Returns:
A unique URL for the resource type that is partially-defined by the given capability's interface or class, or null if no such type exists.

getResourceContextPaths

Collection getResourceContextPaths()
Returns:
A collection containing the context paths for all resource types specified in muse.xml. The collection may be empty.

getResourceContextPaths

Collection getResourceContextPaths(Class capabilityClass)
This method is just like getResourceContextPath(Class) except that it returns multiple endpoints that use the capability.


getResourceEPRs

Iterator getResourceEPRs()
Returns:
An iterator over the collection of resource EPRs.

getResourceEPRs

Iterator getResourceEPRs(String contextPath)
This method allows you to search for the EPRs for all instances of a given resource type (where each resource type has a unique context path).

Parameters:
contextPath -
Returns:
An iterator over the collection of resource EPRs whose wsa:Address includes the given context path.

isUsingPersistence

boolean isUsingPersistence(String contextPath)
Parameters:
contextPath -
Returns:
True if the resource type was specified with the use-router-persistence flag set to 'true' in muse.xml.

removeListener

void removeListener(ResourceManagerListener listener)
Stops the given listener from receiving notifications about the addition and removal of resource instances.

Parameters:
listener -

removeResource

void removeResource(EndpointReference epr)
                    throws SoapFault
Removes the EPR-resource pair from the manager. This does not destroy the resource - it merely removes it from the external view.

Parameters:
epr - The unique EPR that maps to the resource being removed.
Throws:
SoapFault -
  • If the EPR does not map to a resource.

removeResourceDefinitions

void removeResourceDefinitions(Collection definitions)
Removes each ResourceDefinition in the given Collection. After this method has returned, the application will no longer service requests for the given resource types. It will be as though they were never deployed.

Parameters:
definitions -

setEnvironment

void setEnvironment(Environment env)


Copyright © 2005-2011 Apache Web Services - Muse. All Rights Reserved.