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

## org.modeshape.graph.request.processor
Class RequestProcessor

    java.lang.Object
      org.modeshape.graph.request.processor.RequestProcessor

Direct Known Subclasses:
  JcrRequestProcessor, LoggingRequestProcessor, MapRequestProcessor, PathRequestProcessor, Processor, SearchEngineProcessor

    @NotThreadSafe
    public abstract class RequestProcessor

extends Object

A component that is used to process and execute `Request`s. This class is intended to be subclassed and methods overwritten to define the behavior for executing the different kinds of requests. Abstract methods must be overridden, but non-abstract methods all have meaningful default implementations.

Nested Class Summary
`protected class` | `RequestProcessor.LocationWithDepth` A class that represents a location at a known depth

Constructor Summary
`protected` | `RequestProcessor(String sourceName, ExecutionContext context, Observer observer)`
`protected` | `RequestProcessor(String sourceName, ExecutionContext context, Observer observer, DateTime now)`
`protected` | `RequestProcessor(String sourceName, ExecutionContext context, Observer observer, DateTime now, CachePolicy defaultCachePolicy)`

Method Summary
`protected int` | `absoluteMaximumDepthForBranchReads()` This method is called from `process(ReadBranchRequest)` when determining the maximum depth for the subgraph.
`void` | `close()` Close this processor, allowing it to clean up any open resources.
`protected void` | `completeRequest(Request request)`
`List<ChangeRequest>` | `getChanges()` Obtain the list of `ChangeRequest`s that were successfully processed by this processor.
`protected CachePolicy` | `getDefaultCachePolicy()`
`ExecutionContext` | `getExecutionContext()` The execution context that this process is operating within.
`DateTime` | `getNowInUtc()` Get the 'current time' for this processor, which is usually a constant during its lifetime.
`String` | `getSourceName()` Get the name of the source against which this processor is executing.
`protected boolean` | `includeChildrenInSubgraph(Location location, Map<Name,Property> properties, boolean topOfSubgraph)` This method is called from `process(ReadBranchRequest)` when determining whether particular nodes should be included in subgraph reads.
`void` | `notifyObserverOfChanges()` Take any of the changes that have been accumulated by this processor and notify the observer.
`void` | `process(AccessQueryRequest request)` Process a request to query a workspace with an access query, which is is a low-level atomic query that is part of a larger, planned query.
`abstract void` | `process(CloneBranchRequest request)` Process a request to clone a branch into a new workspace.
`abstract void` | `process(CloneWorkspaceRequest request)` Process a request to clone an existing workspace as a new workspace.
`void` | `process(CollectGarbageRequest request)` Process a request to collect garbage.
`void` | `process(CompositeRequest request)` Process a request that is composed of multiple other (non-composite) requests.
`abstract void` | `process(CopyBranchRequest request)` Process a request to copy a branch into another location.
`abstract void` | `process(CreateNodeRequest request)` Process a request to create a node at a specified location.
`abstract void` | `process(CreateWorkspaceRequest request)` Process a request to create a new workspace.
`abstract void` | `process(DeleteBranchRequest request)` Process a request to delete a branch at a specified location.
`void` | `process(DeleteChildrenRequest request)` Process a request to delete all of the child nodes under the supplied existing node.
`abstract void` | `process(DestroyWorkspaceRequest request)` Process a request to permanently destroy a workspace.
`void` | `process(FullTextSearchRequest request)` Process a request to search a workspace.
`void` | `process(FunctionRequest functionRequest)` Process a function request.
`abstract void` | `process(GetWorkspacesRequest request)` Process a request to get the information about the available workspaces.
`void` | `process(LockBranchRequest request)` Process a request to lock a node or branch within a workspace The default implementation of this method does nothing, as most connectors will not support locking.
`abstract void` | `process(MoveBranchRequest request)` Process a request to move a branch at a specified location into a different location.
`abstract void` | `process(ReadAllChildrenRequest request)` Process a request to read all of the children of a node.
`abstract void` | `process(ReadAllPropertiesRequest request)` Process a request to read the properties of a node at the supplied location.
`void` | `process(ReadBlockOfChildrenRequest request)` Process a request to read a block of the children of a node.
`void` | `process(ReadBranchRequest request)` Process a request to read a branch or subgraph that's below a node at a specified location.
`void` | `process(ReadNextBlockOfChildrenRequest request)` Process a request to read the next block of the children of a node, starting after a previously-retrieved child.
`void` | `process(ReadNodeRequest request)` Process a request to read the properties and children of a node at the supplied location.
`void` | `process(ReadPropertyRequest request)` Process a request to read a single property of a node at the supplied location.
`void` | `process(RemovePropertyRequest request)` Process a request to remove the specified property from a node.
`void` | `process(RenameNodeRequest request)` Process a request to rename a node specified location into a different location.
`void` | `process(Request request)` Process a request by determining the type of request and delegating to the appropriate `process` method for that type.
`void` | `process(SetPropertyRequest request)` Process a request to set the specified property on a node.
`void` | `process(UnlockBranchRequest request)` Process a request to unlock a node or branch within a workspace The default implementation of this method does nothing, as most connectors will not support locking.
`abstract void` | `process(UpdatePropertiesRequest request)` Process a request to remove the specified properties from a node.
`void` | `process(UpdateValuesRequest request)` Process a request to add and/or remove the specified values from a property on the given node.
`void` | `process(VerifyNodeExistsRequest request)` Process a request to verify that a node exists at the supplied location.
`abstract void` | `process(VerifyWorkspaceRequest request)` Process a request to verify a named workspace.
`protected void` | `processUnknownRequest(Request request)` Method that is called by `process(Request)` when the request was found to be of a request type that is not known by this processor.
`protected void` | `recordChange(ChangeRequest request)` Record the supplied change request for publishing through the event mechanism.
`protected void` | `setCacheableInfo(CacheableRequest request)` Set the supplied request to have the default cache policy and the `current time in UTC`.
`protected void` | `setCacheableInfo(CacheableRequest request, CachePolicy cachePolicy)` Set the supplied request to have the supplied cache policy and the `current time in UTC`.

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

Constructor Detail

### RequestProcessor

    protected RequestProcessor(String sourceName,
                               ExecutionContext context,
                               Observer observer)

### RequestProcessor

    protected RequestProcessor(String sourceName,
                               ExecutionContext context,
                               Observer observer,
                               DateTime now)

### RequestProcessor

    protected RequestProcessor(String sourceName,
                               ExecutionContext context,
                               Observer observer,
                               DateTime now,
                               CachePolicy defaultCachePolicy)

Method Detail

### recordChange

    protected void recordChange(ChangeRequest request)

  Record the supplied change request for publishing through the event mechanism.

  Parameters:
    `request` - the completed change request; may not be null, and may not be cancelled or have an error

### getSourceName

    public final String getSourceName()

  Get the name of the source against which this processor is executing.

  Returns:
    the repository source name; never null or empty

### getExecutionContext

    public final ExecutionContext getExecutionContext()

  The execution context that this process is operating within.

  Returns:
    the execution context; never null

### getNowInUtc

    public final DateTime getNowInUtc()

  Get the 'current time' for this processor, which is usually a constant during its lifetime.

  Returns:
    the current time in UTC; never null

### getDefaultCachePolicy

    protected final CachePolicy getDefaultCachePolicy()

  Returns:
    defaultCachePolicy

### setCacheableInfo

    protected void setCacheableInfo(CacheableRequest request)

  Set the supplied request to have the default cache policy and the `current time in UTC`.

  Parameters:
    `request` - the cacheable request

### setCacheableInfo

    protected void setCacheableInfo(CacheableRequest request,
                                    CachePolicy cachePolicy)

  Set the supplied request to have the supplied cache policy and the `current time in UTC`.

  Parameters:
    `request` - the cacheable request
    `cachePolicy` - the cache policy for the request; may be null if there is to be no cache policy

### process

    public void process(Request request)

  Process a request by determining the type of request and delegating to the appropriate `process` method for that type.

  This method does nothing if the request is null.

  Parameters:
    `request` - the general request

### completeRequest

    protected void completeRequest(Request request)

### process

    public void process(CompositeRequest request)

  Process a request that is composed of multiple other (non-composite) requests. If any of the embedded requests `has an error` after it is processed, each of the embedded requests will be marked with the error and the submitted composite request will be marked with an error. If one of the embedded requests attempts to `make a change` and results in an error, then the processing of all remaining embedded requests is aborted and the composite request will be marked with only this error from the change request.

  This method does nothing if the request is null.

  Parameters:
    `request` - the composite request

### processUnknownRequest

    protected void processUnknownRequest(Request request)

  Method that is called by `process(Request)` when the request was found to be of a request type that is not known by this processor. By default this method sets an `unsupported request error` on the request.

  Parameters:
    `request` - the unknown request

### process

    public abstract void process(VerifyWorkspaceRequest request)

  Process a request to verify a named workspace.

  This method does nothing if the request is null.

  Parameters:
    `request` - the request

### process

    public abstract void process(GetWorkspacesRequest request)

  Process a request to get the information about the available workspaces.

  This method does nothing if the request is null.

  Parameters:
    `request` - the request

### process

    public abstract void process(CreateWorkspaceRequest request)

  Process a request to create a new workspace.

  This method does nothing if the request is null.

  Parameters:
    `request` - the request

### process

    public abstract void process(CloneBranchRequest request)

  Process a request to clone a branch into a new workspace.

  This method does nothing if the request is null.

  Parameters:
    `request` - the request

### process

    public abstract void process(CloneWorkspaceRequest request)

  Process a request to clone an existing workspace as a new workspace.

  This method does nothing if the request is null.

  Parameters:
    `request` - the request

### process

    public abstract void process(DestroyWorkspaceRequest request)

  Process a request to permanently destroy a workspace.

  This method does nothing if the request is null.

  Parameters:
    `request` - the request

### process

    public abstract void process(CopyBranchRequest request)

  Process a request to copy a branch into another location.

  This method does nothing if the request is null.

  Parameters:
    `request` - the copy request

### process

    public abstract void process(CreateNodeRequest request)

  Process a request to create a node at a specified location.

  This method does nothing if the request is null.

  Parameters:
    `request` - the create request

### process

    public abstract void process(DeleteBranchRequest request)

  Process a request to delete a branch at a specified location.

  This method does nothing if the request is null.

  Parameters:
    `request` - the delete request
  Throws:
    `ReferentialIntegrityException` - if the delete could not be performed because some references to deleted nodes would have remained after the delete operation completed

### process

    public void process(DeleteChildrenRequest request)

  Process a request to delete all of the child nodes under the supplied existing node.

  This method does nothing if the request is null.

  Parameters:
    `request` - the delete request
  Throws:
    `ReferentialIntegrityException` - if the delete could not be performed because some references to deleted nodes would have remained after the delete operation completed

### process

    public abstract void process(MoveBranchRequest request)

  Process a request to move a branch at a specified location into a different location.

  This method does nothing if the request is null.

  Parameters:
    `request` - the move request

### process

    public abstract void process(ReadAllChildrenRequest request)

  Process a request to read all of the children of a node.

  This method does nothing if the request is null.

  Parameters:
    `request` - the read request

### process

    public void process(ReadBlockOfChildrenRequest request)

  Process a request to read a block of the children of a node. The block is defined by a `starting index` and a `maximum number of children to include in the block`.

  This method does nothing if the request is null. The default implementation converts the command to a `ReadAllChildrenRequest`, and then finds the children within the block. Obviously for large numbers of children, this implementation may not be efficient and may need to be overridden.

  Parameters:
    `request` - the read request

### process

    public void process(ReadNextBlockOfChildrenRequest request)

  Process a request to read the next block of the children of a node, starting after a previously-retrieved child.

  This method does nothing if the request is null. The default implementation converts the command to a `ReadAllChildrenRequest`, and then finds the children within the block. Obviously for large numbers of children, this implementation may not be efficient and may need to be overridden.

  Parameters:
    `request` - the read request

### process

    public void process(ReadBranchRequest request)

  Process a request to read a branch or subgraph that's below a node at a specified location.

  This method does nothing if the request is null. The default implementation processes the branch by submitting the equivalent requests to `read the nodes` and the `children`. It starts by doing this for the top-level node, then proceeds for each of the children of that node, and so forth.

  Parameters:
    `request` - the request to read the branch

### absoluteMaximumDepthForBranchReads

    protected int absoluteMaximumDepthForBranchReads()

  This method is called from `process(ReadBranchRequest)` when determining the maximum depth for the subgraph. By default, this method returns `Integer.MAX_VALUE`, signaling that the ReadBranchRequest's `maximum depth` should be honored. However, subclasses can override this method to return a constant value that will be used if less than the ReadBranchRequest's maximum depth.

  Returns:
    the maximum read depth allowed by the processor; must be positive

### includeChildrenInSubgraph

    protected boolean includeChildrenInSubgraph(Location location,
                                                Map<Name,Property> properties,
                                                boolean topOfSubgraph)

  This method is called from `process(ReadBranchRequest)` when determining whether particular nodes should be included in subgraph reads. For example, some processor implementations might want to always exclude nodes with certain names from all subgraph reads. If this is the case, subclasses should override this method (which always returns true), and determine whether the node at the supplied location should be included in the subgraph.

  Parameters:
    `location` - the location of the parent node; never null
    `properties` - the properties of the parent node; never null
    `topOfSubgraph` - true if the parent node (identified by the location) is the root of the subgraph
  Returns:
    true if the child nodes should be read and included in the subgraph, or false otherwise

### process

    public abstract void process(ReadAllPropertiesRequest request)

  Process a request to read the properties of a node at the supplied location.

  This method does nothing if the request is null.

  Parameters:
    `request` - the read request

### process

    public void process(ReadNodeRequest request)

  Process a request to read the properties and children of a node at the supplied location.

  This method does nothing if the request is null. Unless overridden, this method converts the single request into a `ReadAllChildrenRequest` and a `ReadAllPropertiesRequest`.

  Parameters:
    `request` - the read request

### process

    public void process(ReadPropertyRequest request)

  Process a request to read a single property of a node at the supplied location.

  This method does nothing if the request is null. Unless overridden, this method converts the request that `reads the node` and simply returns the one property.

  Parameters:
    `request` - the read request

### process

    public void process(VerifyNodeExistsRequest request)

  Process a request to verify that a node exists at the supplied location.

  This method does nothing if the request is null. Unless overridden, this method converts the request that `reads the node` and uses the result to determine if the node exists.

  Parameters:
    `request` - the read request

### process

    public void process(RemovePropertyRequest request)

  Process a request to remove the specified property from a node.

  This method does nothing if the request is null. Unless overridden, this method converts this request into a `UpdatePropertiesRequest`.

  Parameters:
    `request` - the request to remove the property

### process

    public void process(SetPropertyRequest request)

  Process a request to set the specified property on a node.

  This method does nothing if the request is null. Unless overridden, this method converts this request into a `UpdatePropertiesRequest`.

  Parameters:
    `request` - the request to set the property

### process

    public abstract void process(UpdatePropertiesRequest request)

  Process a request to remove the specified properties from a node.

  This method does nothing if the request is null.

  Parameters:
    `request` - the remove request

### process

    public void process(UpdateValuesRequest request)

  Process a request to add and/or remove the specified values from a property on the given node.

  This method does nothing if the request is null.

  Parameters:
    `request` - the remove request

### process

    public void process(RenameNodeRequest request)

  Process a request to rename a node specified location into a different location.

  This method does nothing if the request is null. Unless overridden, this method converts the rename into a `move`. However, this only works if the `request` has a `path` for its `location`. (If not, this method throws an `UnsupportedOperationException` and must be overridden.)

  Parameters:
    `request` - the rename request

### process

    public void process(LockBranchRequest request)

  Process a request to lock a node or branch within a workspace

  The default implementation of this method does nothing, as most connectors will not support locking. Any implementation of this method should do nothing if the request is null.

  Implementations that do support locking should throw a `LockFailedException` if the request could not be fulfilled.

  Parameters:
    `request` - the request

### process

    public void process(UnlockBranchRequest request)

  Process a request to unlock a node or branch within a workspace

  The default implementation of this method does nothing, as most connectors will not support locking. Any implementation of this method should do nothing if the request is null.

  Parameters:
    `request` - the request

### process

    public void process(AccessQueryRequest request)

  Process a request to query a workspace with an access query, which is is a low-level atomic query that is part of a larger, planned query.

  The default implementation of this method behaves as though the implementation does not support queries by setting an error on the request

  Parameters:
    `request` - the request

### process

    public void process(FullTextSearchRequest request)

  Process a request to search a workspace.

  The default implementation of this method behaves as though the implementation does not support full-text searches by setting an error on the request

  Parameters:
    `request` - the request

### process

    public void process(CollectGarbageRequest request)

  Process a request to collect garbage.

  The default implementation of this method does nothing.

  Parameters:
    `request` - the request

### process

    public void process(FunctionRequest functionRequest)

  Process a function request.

  The default implementation applies the function.

  Parameters:
    `functionRequest` - the request

### close

    public void close()

  Close this processor, allowing it to clean up any open resources.

### getChanges

    public List<ChangeRequest> getChanges()

  Obtain the list of `ChangeRequest`s that were successfully processed by this processor.

  Note that this list is modified during processing and thus should only be accessed by the caller when this processor has been `closed`.

  Also, if this processor encounters errors while processing `change requests`, the processor does not throw out any of the changes. Thus it is up to the caller to decide whether any of the changes are to be kept.

  Returns:
    the list of successful changes; never null but possibly empty.

### notifyObserverOfChanges

    public void notifyObserverOfChanges()

  Take any of the changes that have been accumulated by this processor and notify the observer. This should only be called after `close()` has been called.

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

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.