org.apache.jdo.impl.fostore
Class GetExtentRequest

java.lang.Object
  extended byorg.apache.jdo.impl.fostore.AbstractRequest
      extended byorg.apache.jdo.impl.fostore.GetExtentRequest
All Implemented Interfaces:
Request

class GetExtentRequest
extends AbstractRequest

Represents a request to get the extent of a class and possibly its subclasses.

Author:
Dave Bristor

Field Summary
private  java.lang.Class cls
          The class of the extent sought by this request.
private  FOStoreExtent extent
          Extent returned to user.
protected  FOStoreSchemaUID fsuid
          uid corresponding to the same java.lang.Class that initializes jdoClass.
private  java.util.ArrayList instances
          List of returned instances
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
           
(package private) static org.apache.commons.logging.Log logger
          Logger
private static int maxInstances
          Maximum number of instances that should be returned at a time.
protected static org.apache.jdo.util.I18NHelper msg
           
private  java.util.ArrayList oids
          List of returned object Ids
protected  FOStoreOutput out
          Stream to which request writes itself.
private  org.apache.jdo.pm.PersistenceManagerInternal pm
          The PersistenceManagerInternal that is making this request.
protected  FOStorePMF pmf
          PersistenceManagerFactory via which request is being done.
protected  org.apache.jdo.state.StateManagerInternal sm
          The state manager which is the subject of this request.
private  boolean subclasses
          If true retrieve instances of cls and its subclasses, otherwise just of cls.
 
Constructor Summary
(package private) GetExtentRequest(FOStoreExtent extent, java.lang.Class cls, boolean subclasses, Message m, org.apache.jdo.pm.PersistenceManagerInternal pm)
           
 
Method Summary
 void doRequest()
          Does whatever it is that the kind of request does in actually making a request of the store.
protected  void doRequestBody()
          Subclasses must implement in this method the actual writing of their Request type-specific data.
(package private)  javax.jdo.Extent getExtent()
          Returns the Extent associated with this request
protected  RequestId getId()
           
(package private)  java.util.ArrayList getInstances()
          Returns the list of instances
(package private)  int getMaxInstances()
          Returns max number of instances
(package private)  java.util.ArrayList getOIDs()
          Returns the list of object id's
 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)
          Handles replies to GetExtentRequests.
(package private) static java.util.ArrayList readInstances(java.io.DataInput in, int numInstances, FOStoreModel model, org.apache.jdo.pm.PersistenceManagerInternal pm, java.lang.Class cls)
          Reads instances from given DataInput using a FieldFetcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pm

private final org.apache.jdo.pm.PersistenceManagerInternal pm
The PersistenceManagerInternal that is making this request.


cls

private final java.lang.Class cls
The class of the extent sought by this request.


subclasses

private final boolean subclasses
If true retrieve instances of cls and its subclasses, otherwise just of cls.


maxInstances

private static final int maxInstances
Maximum number of instances that should be returned at a time.


extent

private FOStoreExtent extent
Extent returned to user.


instances

private java.util.ArrayList instances
List of returned instances


oids

private java.util.ArrayList oids
List of returned object Ids


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


LENGTH_COOKIE

protected static final int LENGTH_COOKIE
See Also:
Constant Field Values
Constructor Detail

GetExtentRequest

GetExtentRequest(FOStoreExtent extent,
                 java.lang.Class cls,
                 boolean subclasses,
                 Message m,
                 org.apache.jdo.pm.PersistenceManagerInternal pm)
Method Detail

doRequestBody

protected void doRequestBody()
                      throws java.io.IOException
Description copied from class: AbstractRequest
Subclasses must implement in this method the actual writing of their Request type-specific data.

Specified by:
doRequestBody in class AbstractRequest
Throws:
java.io.IOException
See Also:
AbstractRequest.doRequestBody(), InsertRequest.doRequestBody()

handleReply

public void handleReply(Status status,
                        java.io.DataInput in,
                        int length)
                 throws java.io.IOException
Handles replies to GetExtentRequests. The format of the reply is:
 int: count of number of instances in the extent
 int: count of the number of instances returned
 int: count of the number of oids returned
 that many instances
 
The number of instances returned + number of oid returned = number of instances in the extent. This is for performance: we don't want to return *all* the instances at once: we return some, plus information so that we can get the rest, if the user requests so.

The status might be Status.WARN, in which case there were OID's in the database extent which were unreadable. But the count should be for the actual number of objects returned.

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.

readInstances

static java.util.ArrayList readInstances(java.io.DataInput in,
                                         int numInstances,
                                         FOStoreModel model,
                                         org.apache.jdo.pm.PersistenceManagerInternal pm,
                                         java.lang.Class cls)
                                  throws java.io.IOException
Reads instances from given DataInput using a FieldFetcher.

Parameters:
in - DataInput from which instances are read.
numInstances - Number of instances to read from in.
model - Model required to by FieldFetcher.
pm - PersistenceManagerInternal required FieldFetcher.
cls - Candidate Class for which instances are being obtained.
Returns:
ArrayList of instances read.
Throws:
java.io.IOException

getMaxInstances

int getMaxInstances()
Returns max number of instances


getInstances

java.util.ArrayList getInstances()
Returns the list of instances


getOIDs

java.util.ArrayList getOIDs()
Returns the list of object id's


getExtent

javax.jdo.Extent getExtent()
Returns the Extent associated with this request


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()

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.