|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.omg.PortableServer.Servant
ParkNPark.interfaces.ClientManagerPOA
ParkNPark.middletier.ClientManagerImpl
public class ClientManagerImpl
Server object that will manage communication between the client and the database.
Field Summary | |
---|---|
(package private) PreparedStatement |
checkDuplicate
Statements used for duplicate message detection |
private int |
clientID
Client's ID used for fault-tolerance |
private Connection |
conn
Connection to the database |
private int |
level
Level that client is in |
private int |
lot
Lot that client is in |
private static int |
MAX_ATTEMPTS
Maximum number of attempts when trying to execute commends on database |
private static boolean |
PRINT_LEVELS_STATUS
|
private static boolean |
PRINT_LOTS_STATUS
Flags used to print out the status of lots and levels |
private int |
seq
Client's current operation sequence number used for fault-tolerance |
(package private) PreparedStatement |
updateSequence
|
Constructor Summary | |
---|---|
ClientManagerImpl()
Create a client manager for a new client that will hold information specific to the client. |
|
ClientManagerImpl(int clientID)
Create a client manager for an existing client that will hold information specific to the client. |
Method Summary | |
---|---|
private boolean |
alreadyCompleted(int seq)
Checks if the current client request has already been completed. |
void |
closeClientManager()
Closes the client manager and frees server resources associated with it, including the client manager's activation in the server's CORBA portable object adapter |
int[] |
enterLot(int seq,
int lot)
Moves the client's car into the lot with the given lot number and returns an array of level numbers that have available spaces |
void |
exitLot(int seq)
Removes the client's car from the lot that it is currently in |
int |
getClientID()
Returns the client's ID, which can be used in the client manager factory's getExistingClientManager() method |
int |
getCurrentLevel()
Returns the car's current level number |
int[] |
getLots()
Returns an array of valid lot numbers in the system, sorted by the lot number in ascending order |
int |
getMaxLevel()
Returns the top level number of the car's current parking lot |
int |
getMinLevel()
Returns the bottom level number of the car's current parking lot |
int[] |
getOtherLotAvailability(int lot)
Returns an array of other lots that have availability, sorted by lot distance such that closer lots are listed first |
int |
getSeqNum()
Returns the client's sequence number, which can be used if the client loses track of it |
int |
moveDownLevel(int seq)
Moves the car from its present level to the level beneath it |
int |
moveUpLevel(int seq)
Moves the car from its present level to the level above it |
private void |
printLevelsStatus(String message,
int seq)
Print the status of all the levels in the current lot |
private void |
printLotsStatus(String message,
int seq)
Print the status of all the lots |
private void |
setupDatabaseConn()
Set up the database connection |
private void |
updateClientData(int seq,
int lot,
int level)
Updates the client table, which is used for duplicate detection. |
Methods inherited from class ParkNPark.interfaces.ClientManagerPOA |
---|
_all_interfaces, _invoke, _this, _this |
Methods inherited from class org.omg.PortableServer.Servant |
---|
_default_POA, _get_delegate, _get_interface_def, _is_a, _non_existent, _object_id, _orb, _poa, _set_delegate, _this_object, _this_object |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int MAX_ATTEMPTS
private static final boolean PRINT_LOTS_STATUS
private static final boolean PRINT_LEVELS_STATUS
private int clientID
private int seq
private int lot
private int level
private Connection conn
PreparedStatement checkDuplicate
PreparedStatement updateSequence
Constructor Detail |
---|
public ClientManagerImpl(int clientID) throws ServiceUnavailableException, InvalidClientException
clientID
- seq
-
ServiceUnavailableException
- Thrown when a database exception prevented the client
manager from being created successfully
InvalidClientException
public ClientManagerImpl() throws ServiceUnavailableException
ServiceUnavailableException
- Thrown when a database exception prevented the client
manager from being created successfullyMethod Detail |
---|
private void setupDatabaseConn() throws ServiceUnavailableException
ServiceUnavailableException
- Thrown if a problem came up while connecting to the database server
or setting it up after connectingpublic void closeClientManager() throws ServiceUnavailableException
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from closing the client manager. The client manager remains
open if this exception gets thrownpublic int[] enterLot(int seq, int lot) throws AlreadyInLotException, LotNotFoundException, LotFullException, ServiceUnavailableException
seq
- The latest sequence number of the clientlot
- The lot number to enter
AlreadyInLotException
- Thrown when the client's car is already in a lot
LotNotFoundException
- Thrown if the given lot number is not known to the system
LotFullException
- Thrown if the given lot is full
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the car from entering the lotpublic void exitLot(int seq) throws NotInLotException, NotOnExitLevelException, ServiceUnavailableException
seq
- The latest sequence number of the client
NotInLotException
- Thrown if the car is not in a lot
NotOnExitLevelException
- Thrown if the car is in a lot but is not on a permitted
exit level
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the car from exiting the lotpublic int getClientID()
public int getSeqNum()
public int getCurrentLevel() throws NotInLotException, ServiceUnavailableException
NotInLotException
- Thrown if the car is not in a lot
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from returning the car's current levelpublic int[] getLots() throws ServiceUnavailableException
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from discovering the its defined lotspublic int getMaxLevel() throws NotInLotException, ServiceUnavailableException
NotInLotException
- Thrown if the car is not in a lot
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from returning the current lot's highest levelpublic int getMinLevel() throws NotInLotException, ServiceUnavailableException
NotInLotException
- Thrown if the car is not in a lot
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the system from returning the current lot's lowest levelpublic int[] getOtherLotAvailability(int lot) throws LotNotFoundException, ServiceUnavailableException
lot
- The lot to get lot distances from
LotNotFoundException
- Thrown if the given lot number is not known to the system
ServiceUnavailableException
- Thrown if the database cannot be contacted or if
some other reason prevents the system from discovering the availability of other lotspublic int moveDownLevel(int seq) throws NotInLotException, AtBottomLevelException, ServiceUnavailableException
seq
- The latest sequence number of the client
NotInLotException
- Thrown if the car is not in a lot
AtTopLevelException
- Thrown if the car is already on the lowest level
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some other reason prevents the car from moving to the lower level
AtBottomLevelException
public int moveUpLevel(int seq) throws NotInLotException, AtTopLevelException, ServiceUnavailableException
seq
- The latest sequence number of the client
NotInLotException
- Thrown if the car is not in a lot
AtTopLevelException
- Thrown if the car is already on the highest level
ServiceUnavailableException
- Thrown if the database cannot be contacted or if some
other reason prevents the car from moving to the next highest levelprivate boolean alreadyCompleted(int seq) throws ServiceUnavailableException
seq
-
ServiceUnavailableException
private void updateClientData(int seq, int lot, int level) throws ServiceUnavailableException
seq
- lot
- level
-
ServiceUnavailableException
private void printLotsStatus(String message, int seq)
message
- The message to display with the statusseq
- The client request sequence numberprivate void printLevelsStatus(String message, int seq)
message
- The message to display with the statusseq
- The client request sequence number
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |