org.apache.jdo.impl.fostore
Class AbstractRequest

java.lang.Object
  extended byorg.apache.jdo.impl.fostore.AbstractRequest
All Implemented Interfaces:
Request
Direct Known Subclasses:
AbstractFieldRequest, ActivateClassRequest, BeginTxRequest, CommitRequest, CreateOIDRequest, DeleteRequest, DumpRequest, FetchRequest, GetClassRequest, GetExtentRequest, GetInstancesRequest, LoginRequest, RollbackRequest

abstract class AbstractRequest
extends java.lang.Object
implements Request

Base implementation for all Request subtypes. Provides RequestId, and representation of Request types for all subclasses. Ergo, when you add a Request type you must add it's request type representation here.

Author:
Dave Bristor

Field Summary
protected  FOStoreSchemaUID fsuid
          uid corresponding to the same java.lang.Class that initializes jdoClass.
protected  org.apache.jdo.model.jdo.JDOClass jdoClass
          Class meta data of the object represented by the constructor's given state manager
protected static int LENGTH_COOKIE
           
private  int lengthPos
           
(package private) static org.apache.commons.logging.Log logger
          Logger
protected static org.apache.jdo.util.I18NHelper msg
           
protected  FOStoreOutput out
          Stream to which request writes itself.
protected  FOStorePMF pmf
          PersistenceManagerFactory via which request is being done.
private  RequestId requestId
           
private  RequestType requestType
           
private  boolean sealed
           
protected  org.apache.jdo.state.StateManagerInternal sm
          The state manager which is the subject of this request.
 
Constructor Summary
protected AbstractRequest(Message m, FOStorePMF pmf)
           
protected AbstractRequest(org.apache.jdo.state.StateManagerInternal sm, Message m, FOStorePMF pmf)
           
 
Method Summary
private  void beginRequest()
          Writes the header of the request.
 void doRequest()
          Does whatever it is that the kind of request does in actually making a request of the store.
protected abstract  void doRequestBody()
          Subclasses must implement in this method the actual writing of their Request type-specific data.
private  void endRequest()
          Write the length.
protected  RequestId getId()
           
 org.apache.jdo.state.StateManagerInternal getStateManager()
          Get the StateManager associated with this request, null if none.
 void handleReply(Status status, java.io.DataInput in, int length)
          Processes the results of the effect of the request in the store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sm

protected org.apache.jdo.state.StateManagerInternal sm
The state manager which is the subject of this request.


pmf

protected final FOStorePMF pmf
PersistenceManagerFactory via which request is being done.


out

protected final FOStoreOutput out
Stream to which request writes itself.


jdoClass

protected org.apache.jdo.model.jdo.JDOClass jdoClass
Class meta data of the object represented by the constructor's given state manager


fsuid

protected FOStoreSchemaUID fsuid
uid corresponding to the same java.lang.Class that initializes jdoClass.


msg

protected static final org.apache.jdo.util.I18NHelper msg

logger

static final org.apache.commons.logging.Log logger
Logger


lengthPos

private int lengthPos

LENGTH_COOKIE

protected static final int LENGTH_COOKIE
See Also:
Constant Field Values

requestId

private final RequestId requestId

requestType

private RequestType requestType

sealed

private boolean sealed
Constructor Detail

AbstractRequest

protected AbstractRequest(org.apache.jdo.state.StateManagerInternal sm,
                          Message m,
                          FOStorePMF pmf)

AbstractRequest

protected AbstractRequest(Message m,
                          FOStorePMF pmf)
Method Detail

getId

protected RequestId getId()

doRequest

public final void doRequest()
                     throws java.io.IOException
Description copied from interface: Request
Does whatever it is that the kind of request does in actually making a request of the store.

Specified by:
doRequest in interface Request
Throws:
java.io.IOException - in case of errors with the stream.
See Also:
Request.doRequest()

beginRequest

private final void beginRequest()
                         throws java.io.IOException
Writes the header of the request. The header is always:

request id
request type
length
No, we don't really know the length yet. We write out any old integer, and then later (in endRequest) come back and write in the real length.

Throws:
java.io.IOException

doRequestBody

protected abstract void doRequestBody()
                               throws java.io.IOException
Subclasses must implement in this method the actual writing of their Request type-specific data.

Throws:
java.io.IOException

endRequest

private final void endRequest()
                       throws java.io.IOException
Write the length. Remember, in beginRequest we only wrote a placeholder.

Throws:
java.io.IOException

getStateManager

public org.apache.jdo.state.StateManagerInternal getStateManager()
Get the StateManager associated with this request, null if none.

Specified by:
getStateManager in interface Request
Returns:
the StateManager.

handleReply

public void handleReply(Status status,
                        java.io.DataInput in,
                        int length)
                 throws java.io.IOException
Processes the results of the effect of the request in the store. To be invoked after the store has processed the request, and has returned information about that request, such as its status and any accompanying data.

Parameters:
in - the input stream.
length - the length of data in the stream.
status - Indication as to the success, failure, etc. of the request as handled by the store.
Throws:
java.io.IOException - if any problems reading the stream.