org.modeshape.graph.request
Class Request

java.lang.Object
  extended by org.modeshape.graph.request.Request
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CacheableRequest, ChangeRequest, CompositeRequest, CompositeRequestChannel.LastRequest, SearchRequest, VerifyWorkspaceRequest

public abstract class Request
extends Object
implements Serializable

The abstract base class for all classes representing requests to be executed against a RepositoryConnection.

See Also:
Serialized Form

Constructor Summary
protected Request()
           
 
Method Summary
 void cancel()
          Cancel this request.
protected  void checkNotFrozen()
          Utility method to check that the request is not frozen, and if it is to throw an IllegalStateException.
 boolean freeze()
          Freeze this request to prevent any further modification.
 Throwable getError()
          Get the error associated with this request, if there is such an error.
abstract  RequestType getType()
          Returns the type of the request
 boolean hasError()
          Return whether there is an error associated with this request
 boolean isCancelled()
          Check whether this request has been cancelled.
 boolean isFrozen()
          Determine whether this request has been frozen, preventing any further updates.
abstract  boolean isReadOnly()
          Return whether this request only reads information.
 void setError(Throwable error)
          Set the error for this request.
 void setLatchForFreezing(CountDownLatch latch)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Request

protected Request()
Method Detail

setLatchForFreezing

public void setLatchForFreezing(CountDownLatch latch)

setError

public void setError(Throwable error)
Set the error for this request.

Parameters:
error - the error to be associated with this request, or null if this request is to have no error
Throws:
IllegalStateException - if the request is frozen

hasError

public boolean hasError()
Return whether there is an error associated with this request

Returns:
true if there is an error, or false otherwise

getError

public Throwable getError()
Get the error associated with this request, if there is such an error.

Returns:
the error, or null if there is none

isCancelled

public boolean isCancelled()
Check whether this request has been cancelled. Although it is a recommendation that the result of this method be followed wherever possible, it is not required to immediately stop processing the request if this method returns true. For example, if processing is almost complete, it may be appropriate to simply finish processing the request.

This method is safe to be called by different threads.

Returns:
true if this request has been cancelled, or false otherwise.

cancel

public void cancel()
Cancel this request. After this method is called, the cancellation flag is set, and any current or future processing of the request may be affected by the cancellation. (Note however, that processors may choose to not respect this request.)

This method is safe to be called by different threads.

Throws:
IllegalStateException - if the request is frozen

isReadOnly

public abstract boolean isReadOnly()
Return whether this request only reads information.

Returns:
true if this request reads information, or false if it requests that the repository content be changed in some way

isFrozen

public boolean isFrozen()
Determine whether this request has been frozen, preventing any further updates.

Returns:
true if the request has been frozen, or false otherwise

freeze

public boolean freeze()
Freeze this request to prevent any further modification. This method does nothing if the request is already frozen.

Returns:
true if this request was frozen, or false if it was already frozen

checkNotFrozen

protected void checkNotFrozen()
                       throws IllegalStateException
Utility method to check that the request is not frozen, and if it is to throw an IllegalStateException.

Throws:
IllegalStateException - if the request is frozen

getType

public abstract RequestType getType()
Returns the type of the request

Returns:
the type of the request


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