Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.muse.core
Interface ResourceManager

All Superinterfaces:
  Initialization, Shutdown

All Known Implementing Classes:
  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(java.util.Collection definitions)`
`Resource` | `createResource(java.lang.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)`
`java.lang.String` | `getResourceContextPath(java.lang.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.
`java.util.Collection` | `getResourceContextPaths()`
`java.util.Collection` | `getResourceContextPaths(java.lang.Class capabilityClass)` This method is just like getResourceContextPath(Class) except that it returns multiple endpoints that use the capability.
`java.util.Iterator` | `getResourceEPRs()`
`java.util.Iterator` | `getResourceEPRs(java.lang.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(java.lang.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(java.util.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

    public void addListener(ResourceManagerListener listener)

  Parameters:
    `listener` - A listener that will be fired whenever a resource is added or removed from the resource.

### addResource

    public 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

    public void addResourceDefinitions(java.util.Collection definitions)

  Parameters:
    `definitions` - The ResourceDefinition objects that will be used to generate new resource instances.

### createResource

    public Resource createResource(java.lang.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

    public Environment getEnvironment()

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

### getNumberOfResources

    public int getNumberOfResources()

  Returns:
    The number of resource instances stored by the manager.

### getResource

    public 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

    public java.lang.String getResourceContextPath(java.lang.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

    public java.util.Collection getResourceContextPaths()

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

### getResourceContextPaths

    public java.util.Collection getResourceContextPaths(java.lang.Class capabilityClass)

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

### getResourceEPRs

    public java.util.Iterator getResourceEPRs()

  Returns:
    An iterator over the collection of resource EPRs.

### getResourceEPRs

    public java.util.Iterator getResourceEPRs(java.lang.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

    public boolean isUsingPersistence(java.lang.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

    public void removeListener(ResourceManagerListener listener)

  Stops the given listener from receiving notifications about the addition and removal of resource instances.

  Parameters:
    `listener` -

### removeResource

    public 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

    public void removeResourceDefinitions(java.util.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

    public void setEnvironment(Environment env)

Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD