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.routing
Class RouterFilePersistence

    java.lang.Object
      org.apache.muse.core.AbstractFilePersistence
          org.apache.muse.core.routing.RouterFilePersistence

All Implemented Interfaces:
  InitializationParameters, Persistence, ResourceManagerListener, RouterPersistence

public class RouterFilePersistence
extends AbstractFilePersistence
implements RouterPersistence

RouterFilePersistence is a component that saves router entries (EPRs and their resource types) to XML files on disk.

Author:
  Dan Jemiolo (danj)

Constructor Summary
`RouterFilePersistence()`

Method Summary
`protected void` | `createResourceFile(EndpointReference epr, Resource resource, java.io.File resourceFile)` This method should be overridden by concrete file-based persistence classes to create the given file and fill it with the appropriate XML content. Classes that are only interested in the serialization of a certain capability's data can use the Resource object to get access to said capability. This implementation serializes the EPR to XML, then writes the wsa:ReferenceParameters element to the file.
`protected java.lang.String` | `getFilePrefix()`
`protected Resource` | `reloadResource(java.lang.String contextPath, org.w3c.dom.Element resourceXML)` This method should be overridden by concrete file-based persistence classes to update a resource instance with the saved data from the XML fragment. The resource instance may be created by this method, or it may exist prior to invocation. This implementation treats the XML fragment as a wsa:ReferenceParameters element.
`void` | `resourceAdded(EndpointReference epr, Resource resource)` This implementation checks to see if the resource type is one that is being persisted, and if so, creates a file for the instance.
`void` | `resourceRemoved(EndpointReference epr)` This implementation checks to see if the resource type is one that is being persisted, and if so, tries to delete the resource's file.

Methods inherited from class org.apache.muse.core.AbstractFilePersistence
`createResourceFile, destroyResourceFile, getContextPath, getFileNumber, getFileNumberTables, getInitializationParameter, getInitializationParameters, getNextFileName, getNextFileNumber, getPersistenceDirectory, getPersistenceLocation, getResourceManager, getResourceTypeDirectory, reload, reloadResources, setInitializationParameters, setPersistenceLocation, setResourceManager`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.muse.core.Persistence
`getPersistenceLocation, getResourceManager, reload, setPersistenceLocation, setResourceManager`

Methods inherited from interface org.apache.muse.core.InitializationParameters
`getInitializationParameter, getInitializationParameters, setInitializationParameters`

Constructor Detail

### RouterFilePersistence

    public RouterFilePersistence()

Method Detail

### createResourceFile

    protected void createResourceFile(EndpointReference epr,
                                      Resource resource,
                                      java.io.File resourceFile)
                               throws SoapFault

  This method should be overridden by concrete file-based persistence classes to create the given file and fill it with the appropriate XML content. Classes that are only interested in the serialization of a certain capability's data can use the Resource object to get access to said capability.
  This implementation serializes the EPR to XML, then writes the wsa:ReferenceParameters element to the file. If the EPR had no reference parameters, an empty element is written.

  Specified by:
    `createResourceFile` in class `AbstractFilePersistence`
  Parameters:
    `epr` - The EPR that maps to the given Resource in the ResourceManager.
    `resource` - The resource instance whose state is being persisted.
    `resourceFile` - The File object that represents the yet-to-be-created XML file that will contain the content generated by this method. The implementation of this method must be sure to create the File on disk somehow.
  Throws:
    `SoapFault` -
    - If there is an error generating the proper content for the persistence file.
    - If there is an I/O error while reading or writing to the file system.

### getFilePrefix

    protected java.lang.String getFilePrefix()

  Specified by:
    `getFilePrefix` in class `AbstractFilePersistence`
  Returns:
    The string 'resource-instance-'.
  See Also:
    `AbstractFilePersistence.getNextFileNumber(String)`

### reloadResource

    protected Resource reloadResource(java.lang.String contextPath,
                                      org.w3c.dom.Element resourceXML)
                               throws SoapFault

  This method should be overridden by concrete file-based persistence classes to update a resource instance with the saved data from the XML fragment. The resource instance may be created by this method, or it may exist prior to invocation.
  This implementation treats the XML fragment as a wsa:ReferenceParameters element. It creates an EPR for the given resource type (context path) and then adds the reference parameters to it. Finally, it creates an instance of the resource type and (re-)sets the EPR that it has constructed.

  Specified by:
    `reloadResource` in class `AbstractFilePersistence`
  Parameters:
    `contextPath` - The context path of the instance's resource type.
    `resourceXML` - The persisted data that must be reloaded.
  Returns:
    The Resource instance whose state (or part of it) has been reloaded from XML. The Resource may have already existed prior to the method being called, and simply had one of its capabilities updated with saved data; it may also have been created by the method and initialized right before return.
  Throws:
    `SoapFault`

### resourceAdded

    public void resourceAdded(EndpointReference epr,
                              Resource resource)
                       throws SoapFault

  This implementation checks to see if the resource type is one that is being persisted, and if so, creates a file for the instance.

  Specified by:
    `resourceAdded` in interface `ResourceManagerListener`
  Parameters:
    `epr` - The unique EPR that is being associated with the new resource. This value should always be used over Resource.getEndpointReference() because some applications may choose to map multiple EPRs to the same resource instance, and thus getEndpointReference() will not provide an accurate value.
    `resource` - The resource instance being associated with the given EPR.
  Throws:
    `SoapFault`

### resourceRemoved

    public void resourceRemoved(EndpointReference epr)
                         throws SoapFault

  This implementation checks to see if the resource type is one that is being persisted, and if so, tries to delete the resource's file.

  Specified by:
    `resourceRemoved` in interface `ResourceManagerListener`
  Parameters:
    `epr` - The unique EPR of the resource that has been destroyed - the Resource object is not provided because it would most likely be in an inconsistent state. At this point, the resource has already been 'destroyed'.
  Throws:
    `SoapFault`

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