|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jdo.impl.fostore.RequestHandler
org.apache.jdo.impl.fostore.InsertHandler
org.apache.jdo.impl.fostore.UpdateHandler
Process requests to update instances in the datastore.
Nested Class Summary | |
(package private) static interface |
RequestHandler.HandlerFactory
Means by which subclasses are created. |
private class |
UpdateHandler.DoesNotExistException
Thrown by verify(org.apache.jdo.impl.fostore.OID, boolean, org.apache.jdo.impl.fostore.Block) if an object which should exist
in the database, does not. |
Field Summary | |
protected FOStoreServerConnection |
con
Connection on which the Request arrived. |
(package private) static RequestHandler.HandlerFactory |
factory
|
protected int |
length
Length of the data in the Request. |
(package private) static org.apache.commons.logging.Log |
logger
Logger |
private static org.apache.jdo.util.I18NHelper |
msg
I18N Support |
protected Reply |
reply
Subclasses use this Reply instance to send data back to their corresponding client-side request. |
Constructor Summary | |
protected |
UpdateHandler(Reply reply,
int length,
FOStoreServerConnection con)
Construct a new handler for processing updates. |
Method Summary | |
protected boolean |
getOkToFinish()
The RollbackHandler should override this and return false, so that finishers are not run when we are rolling back. |
(package private) RequestFinisher |
handleRequest()
Subclasses implement this to take care of individiual requests. |
(package private) static void |
handleRequests(FOStoreServerConnection con)
Handles all requests that can be read at this time from the given connection. |
protected Block |
readBlock(FOStoreInput in)
|
protected void |
setOkToCommit(boolean okToCommit)
The CommitHandler should override this and save the given value, then use it to determine whether or not to commit. |
protected void |
updateDB(OID realOID,
OID provOID,
Block block,
FOStoreDatabase db)
Replace a block in the database. |
protected boolean |
verify(OID oid,
boolean verifyFields,
Block block)
Verify before image versus database state of an object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final org.apache.jdo.util.I18NHelper msg
static final RequestHandler.HandlerFactory factory
protected final Reply reply
protected final int length
protected final FOStoreServerConnection con
static final org.apache.commons.logging.Log logger
Constructor Detail |
protected UpdateHandler(Reply reply, int length, FOStoreServerConnection con)
reply
- the Reply.length
- the length of data in the stream.con
- the connection to use.Method Detail |
RequestFinisher handleRequest() throws java.io.IOException, FOStoreDatabaseException
RequestHandler
handleRequest
in class InsertHandler
java.io.IOException
FOStoreDatabaseException
RequestHandler.handleRequest()
protected boolean verify(OID oid, boolean verifyFields, Block block) throws java.io.IOException, FOStoreDatabaseException, UpdateHandler.DoesNotExistException
oid
- OID of object to be verifiedverifyFields
- If true, verify that values of the data
corresponding to oid
in the database match those in the
given block; if false verify that object corresponding to
oid
exists.block
- Block of data for value verification; may be null if
verifyFields
is false.
verifyFields
.
java.io.IOException
- if stream errors.
FOStoreDatabaseException
- if any errors in the database.
UpdateHandler.DoesNotExistException
- if the object to be updated does not exist.protected void updateDB(OID realOID, OID provOID, Block block, FOStoreDatabase db) throws java.io.IOException, FOStoreDatabaseException
updateDB
in class InsertHandler
provOID
- provisional OID.realOID
- OID to use as key in the database.block
- Block to be inserted in database.db
- Database into which block is replaced.
java.io.IOException
- for stream errors.
FOStoreDatabaseException
- for any database error except for object not found.InsertHandler.updateDB(org.apache.jdo.impl.fostore.OID, org.apache.jdo.impl.fostore.OID, org.apache.jdo.impl.fostore.Block, org.apache.jdo.impl.fostore.FOStoreDatabase)
protected Block readBlock(FOStoreInput in) throws java.io.IOException
java.io.IOException
protected boolean getOkToFinish()
protected void setOkToCommit(boolean okToCommit)
static void handleRequests(FOStoreServerConnection con)
The data it generates for the client is documented; see ReplyHandler.processReplies(java.io.DataInput, org.apache.jdo.impl.fostore.Message)
.
If after all requests are thusly handled, none have indicated that the second round of handling, called finishing, is not to be done, then performs this second round. The finishers that are invoked are precisely those which were returned from each request's handleRequest invocation, and the finishers have their finish() methods invoked in the same order in which the requests were originally invoked.
Finally, writes the number of replies (at the beginning of the reply data, in a spot that was set aside for this purpose), and sends replies back to the client.
This method is very paranoid about error checking, which clutters it up some, but is necessary to ensure that the server keeps running.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |