org.apache.jdo.impl.fostore
Class LoginHandler

java.lang.Object
  extended byorg.apache.jdo.impl.fostore.RequestHandler
      extended byorg.apache.jdo.impl.fostore.LoginHandler

class LoginHandler
extends RequestHandler

Handler for LoginRequests.

Version:
1.0
Author:
Craig Russell

Nested Class Summary
(package private) static interface RequestHandler.HandlerFactory
          Means by which subclasses are created.
 
Field Summary
protected  FOStoreServerConnection con
          Connection on which the Request arrived.
(package private)  boolean create
          a flag to tell whether to create the database
(package private)  java.lang.String dbname
          the database name
static RequestHandler.HandlerFactory factory
          the factory used to create the handler for this request
protected  int length
          Length of the data in the Request.
(package private) static org.apache.commons.logging.Log logger
          Logger
protected  Reply reply
          Subclasses use this Reply instance to send data back to their corresponding client-side request.
(package private)  byte[] secret
          a message digest which is a shared secret
(package private)  long timestamp
          a pseudo random number
(package private)  java.lang.String user
          the user of the database
 
Constructor Summary
private LoginHandler(Reply reply, int length, FOStoreServerConnection con)
          Construct an instance of the LoginHandler to service this request.
 
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()
          Process the request by analyzing the database and user login information from the request buffer.
(package private) static void handleRequests(FOStoreServerConnection con)
          Handles all requests that can be read at this time from the given connection.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbname

java.lang.String dbname
the database name


user

java.lang.String user
the user of the database


timestamp

long timestamp
a pseudo random number


secret

byte[] secret
a message digest which is a shared secret


create

boolean create
a flag to tell whether to create the database


factory

public static final RequestHandler.HandlerFactory factory
the factory used to create the handler for this request


reply

protected final Reply reply
Subclasses use this Reply instance to send data back to their corresponding client-side request.


length

protected final int length
Length of the data in the Request.


con

protected final FOStoreServerConnection con
Connection on which the Request arrived.


logger

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

Constructor Detail

LoginHandler

private LoginHandler(Reply reply,
                     int length,
                     FOStoreServerConnection con)
Construct an instance of the LoginHandler to service this request.

Parameters:
reply - the reply for the request
length - the length of the request
con - the FOStoreServerConnection with the request
Method Detail

handleRequest

RequestFinisher handleRequest()
                        throws java.io.IOException,
                               FOStoreDatabaseException
Process the request by analyzing the database and user login information from the request buffer. This will create the database if needed, open it, and verify the user and password.

Specified by:
handleRequest in class RequestHandler
Returns:
null; there is no need for a finisher.
Throws:
java.io.IOException - if any problems
FOStoreDatabaseException

getOkToFinish

protected boolean getOkToFinish()
The RollbackHandler should override this and return false, so that finishers are not run when we are rolling back.


setOkToCommit

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.


handleRequests

static void handleRequests(FOStoreServerConnection con)
Handles all requests that can be read at this time from the given connection. Reads the number of requests, then reads each one and, in turn, invokes the handleRequest operation on each.

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.