|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--suncertify.common.QueryInterfaceImpl
QueryInterface implementation for accessing Database. It have the same as DBMain interface but thay are additionally equipped with client login parameter and two additional method dataBase login and logout. Each method checks if client is logged in and sets the thread name to the login name value (important for locking mechnism) and execute appriopriate method on underlaying DBMain object additionally basic logging is being made.
Constructor Summary | |
QueryInterfaceImpl()
Creates QueryInterfaceImpl instance. |
|
QueryInterfaceImpl(DBMain data,
LoggerSupport logger)
Creates QueryInterfaceImpl instance. |
|
QueryInterfaceImpl(LoggerSupport logger)
Creates QueryInterfaceImpl instance. |
Method Summary | |
void |
closeDB()
The method closes the db file - created for secure server shutdown you should never use the QueryImpl object after calling this method!! |
int |
create(java.lang.String[] data,
java.lang.String clientId)
Creates a new record in the database. |
static java.lang.String |
createObjectURL(java.lang.String host,
int port)
Method formats URL string for binding remote object named DBServerQuery. |
void |
delete(int recNo,
java.lang.String clientId)
Deletes a record, making the record number and associated disk storage available for reuse. |
int[] |
find(java.lang.String[] criteria,
java.lang.String clientId)
Returns an array of record numbers that match the specified criteria. |
java.lang.String |
getClientList()
Returns the String - list of the currently logged in clients |
boolean |
isLocked(int recNo,
java.lang.String clientId)
Determines if a record is currenly locked. |
void |
lock(int recNo,
java.lang.String clientId)
Locks a record so that it can only be updated or deleted by this client. |
java.lang.String |
logIn()
The method performs client login. |
void |
logIn(java.lang.String login)
The method performs client login. |
void |
logOut(java.lang.String clientId)
The method performs client logout - no others connections with such login will be available |
java.lang.String[] |
read(int recNo,
java.lang.String clientId)
Reads a record from the file. |
void |
unlock(int recNo,
java.lang.String clientId)
Releases the lock on a record. |
void |
update(int recNo,
java.lang.String[] data,
java.lang.String clientId)
Modifies the fields of a record. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public QueryInterfaceImpl() throws IncorrectDataFile, java.io.IOException
java.io.IOException
- - is thrown if file does not exist or cannot be opened
IncorrectDataFile
- - is thrown when magic cookie value is incorrectpublic QueryInterfaceImpl(LoggerSupport logger) throws IncorrectDataFile, java.io.IOException
logger
- - the logger reference
java.io.IOException
- - is thrown if file does not exist or cannot be opened
IncorrectDataFile
- - is thrown when magic cookie value is incorrectpublic QueryInterfaceImpl(DBMain data, LoggerSupport logger)
data
- - the DBMain referencelogger
- - the logger referenceMethod Detail |
public int create(java.lang.String[] data, java.lang.String clientId) throws DuplicateKeyException, ClientNotLoggedInException
create
in interface QueryInterface
data
- the array string representig values of the fields of the new recordclientId
- the unique identifier of the clienent thet is performing request
DuplicateKeyException
- - thrown when record could not be created
java.rmi.RemoteException
- - required for remote access
ClientNotLoggedInException
- - is thrown when client login passed as argument is
not a valid client login (e.g. client has not been logged in)QueryInterface.create(String[], String)
,
DBMain.create(String[])
public void delete(int recNo, java.lang.String clientId) throws RecordNotFoundException, ClientNotLoggedInException
delete
in interface QueryInterface
recNo
- the index of the record to deleteclientId
- the unique identifier of the clienent thet is performing request
RecordNotFoundException
- is thrown if a specified record does not exist or is
marked as deleted in the database file.
java.rmi.RemoteException
- - required for remote access
ClientNotLoggedInException
- - is thrown when client login passed as argument is
not a valid client login (e.g. client has not been logged in)QueryInterface.delete(int, String)
,
DBMain.delete(int)
public int[] find(java.lang.String[] criteria, java.lang.String clientId) throws RecordNotFoundException, ClientNotLoggedInException
find
in interface QueryInterface
criteria
- String array representing the criteria for each record fieldclientId
- the unique identifier of the clienent thet is performing request
RecordNotFoundException
- is thrown if a specified record does not exist or is
marked as deleted in the database file.
java.rmi.RemoteException
- - required for remote access
ClientNotLoggedInException
- - is thrown when client login passed as argument is
not a valid client login (e.g. client has not been logged in)QueryInterface.find(String[], String)
,
DBMain.find(String[])
public boolean isLocked(int recNo, java.lang.String clientId) throws RecordNotFoundException, ClientNotLoggedInException
isLocked
in interface QueryInterface
clientId
- the unique identifier of the clienent thet is performing requestrecNo
- the index of the record to check
RecordNotFoundException
- is thrown if a specified record does not exist or is
marked as deleted in the database file.
java.rmi.RemoteException
- - required for remote access
ClientNotLoggedInException
- - is thrown when client login passed as argument is
not a valid client login (e.g. client has not been logged in)QueryInterface.isLocked(int, String)
,
DBMain.isLocked(int)
public void lock(int recNo, java.lang.String clientId) throws RecordNotFoundException, ClientNotLoggedInException
lock
in interface QueryInterface
recNo
- the index of the record to lockclientId
- the unique identifier of the clienent thet is performing request
RecordNotFoundException
- is thrown if a specified record does not exist or is
marked as deleted in the database file.
java.rmi.RemoteException
- - required for remote access
ClientNotLoggedInException
- - is thrown when client login passed as argument is
not a valid client login (e.g. client has not been logged in)QueryInterface.lock(int, String)
,
DBMain.lock(int)
public java.lang.String[] read(int recNo, java.lang.String clientId) throws RecordNotFoundException, ClientNotLoggedInException
read
in interface QueryInterface
recNo
- the index of the requested recordclientId
- the unique identifier of the clienent thet is performing request
RecordNotFoundException
- is thrown if a specified record does not exist or is
marked as deleted in the database file.
java.rmi.RemoteException
- - required for remote access
ClientNotLoggedInException
- - is thrown when client login passed as argument is
not a valid client login (e.g. client has not been logged in)QueryInterface.read(int, String)
,
DBMain.read(int)
public void unlock(int recNo, java.lang.String clientId) throws RecordNotFoundException, ClientNotLoggedInException
unlock
in interface QueryInterface
recNo
- the index of the record to lockclientId
- the unique identifier of the clienent thet is performing request
RecordNotFoundException
- is thrown if a specified record does not exist or is
marked as deleted in the database file.
java.rmi.RemoteException
- - required for remote access
ClientNotLoggedInException
- - is thrown when client login passed as argument is
not a valid client login (e.g. client has not been logged in)QueryInterface.unlock(int, String)
,
DBMain.unlock(int)
public void update(int recNo, java.lang.String[] data, java.lang.String clientId) throws RecordNotFoundException, ClientNotLoggedInException
update
in interface QueryInterface
recNo
- the index of the record to operate ondata
- the new set of data for the requested recordclientId
- the unique identifier of the clienent thet is performing request
RecordNotFoundException
- is thrown if a specified record does not exist or is
marked as deleted in the database file.
java.rmi.RemoteException
- - required for remote access
ClientNotLoggedInException
- - is thrown when client login passed as argument is
not a valid client login (e.g. client has not been logged in)QueryInterface.update(int,String[], String)
,
DBMain.update(int, String[])
public void logIn(java.lang.String login) throws java.rmi.RemoteException
logIn
in interface QueryInterface
login
- client login
java.rmi.RemoteException
- - required for remote accessQueryInterface.logIn(String)
public java.lang.String logIn() throws java.rmi.RemoteException
logIn
in interface QueryInterface
java.rmi.RemoteException
- - required for remote accessQueryInterface.logIn(String)
public void logOut(java.lang.String clientId) throws java.rmi.RemoteException, ClientNotLoggedInException
logOut
in interface QueryInterface
clientId
- uniqe client identifier
java.rmi.RemoteException
- - required for remote access
ClientNotLoggedInException
- - is thrown when client login passed as argument is
not a valid client login (e.g. client has not been logged in)public java.lang.String getClientList()
public void closeDB()
public static java.lang.String createObjectURL(java.lang.String host, int port)
host
- - the name of the host on which object existsport
- - the port where object can be found
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |