• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overall Design ? Pls Help Mark, Peter , Rajeev and others

 
Amit Kr Kumar
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in the stage of submitting the assignment. But i still have doubts regarding the design i have created. Pls help
My Design is as follows :
1) Data.java is given to me by Sun which reads the binary file and give info. I have created a interface called FBNDataService which contains all the methods which are there in Data.java. The structure of FBNDataService Interface is :
public interface FBNDataService
{
public void add(String[] newData) throws DatabaseException , Exception;
public void close() throws Exception;
public DataInfo[] criteriaFind(String criteria) throws DatabaseException , Exception;
public void delete(DataInfo toDelete) throws DatabaseException , Exception;
public DataInfo find(String toMatch) throws DatabaseException , Exception;
public FieldInfo[] getFieldInfo() throws Exception;
public DataInfo getRecord(int recNum) throws DatabaseException , Exception;
public int getRecordCount() throws Exception;
public void modify(DataInfo newData) throws DatabaseException , Exception;
public void lock(int record , FBNClientID objFBNClientID) throws DatabaseException , IOException , Exception;
public void unlock(int record , FBNClientID objFBNClientID) throws Exception;
}
I have modified Data.java and implements criteria and locking methods inside it. Also i have made Data.java implementing FBNDataService
2) I have created FBNRemoteDataService interface which extends Remote and FBNDataService. Thus all the methods in FBNDataService automatically gets inhertited.
public interface FBNRemoteDataService extends FBNDataService, Remote
{
public static final String SERVICENAME = "FBNRemoteDataService";
}
3) I have created a implementation class of FBNRemoteDataService called FBNRemoteDataServiceImpl which implements FBNRemoteDataService and extends UNICastRemoteObject. This class have a constructor which takes the object of Data.java as params. This class Adapts Data.java and any method called on this class automatically calls Data.java. All the methods of this class throws RemoteException.
public final class FBNRemoteDataServiceImpl extends UnicastRemoteObject implements FBNRemoteDataService
{
private FBNDataService objFBNDataService = null;
protected FBNRemoteDataServiceImpl(String dbname) throws IOException , RemoteException , Exception
{
objFBNDataService = (FBNDataService)new Data(dbname);
}
public void add(String[] newData) throws DatabaseException , RemoteException , Exception
{
objFBNDataService.add(newData);
}
........
}

4) I have created FBNLocalDataServiceImpl which implements FBNDataService and adapts Data.java
public class FBNLocalDataServiceImpl implements FBNDataService
{
private FBNDataService objFBNDataService = null;

public FBNLocalDataServiceImpl(String strLocalDB) throws IOException
{
objFBNDataService = (FBNDataService)new Data(strLocalDB);
}
public void add(String[] newData) throws DatabaseException , Exception
{
objFBNDataService.add(newData);
}
....
}
5) I have a connection factory called FBNConnectionFactory which has two methods :
static FBNDataService getConnection(host,port)
{
return objFBNDataService = (FBNRemoteDataService)Naming.lookup(....)
}
static FBNDataService getConnection(localdb) .
{
return objFBNDataService = (FBNLocalDataService)new Data(localdb)
}
Both returns FBNDataService which is first typecast by this method
e.g
objFBNDataService = (FBNLocalDataService)new Data(localdb)
objFBNDataService = (FBNRemoteDataService)Naming.lookup(....)
Here Factory pattern is thus being used.
6) I have business logic class at client end called FBNFlightServices which contains methods like bookSeats etc. This class takes the reference of connection ie FBNDataService in the constructor, without knowing whether its local mode or remote mode and use this connection to talk to DB. All its methods throws FBNException which GUI needs to catch.
protected FBNFlightServices(FBNDataService connection) throws Exception
{
}
protected bookSeats()
{
}

7)client gui makes use of this FBNFlightService class to perform various operations.
8) My RMI Server binds FBNRemoteDataServiceImpl for lookup by client
Doubts
(1) is is correct to make Data.java implementing FBNDataInterface ?
(2) All the methods in my FBNDataService interface is throwing java.lang.Exception apart from other exceptions like ioexception,DBconnection etc. This is so as i need to make this interface compatible with FBNRemoteDataService whose all methods are throwing RemoteException. This compatibality is required as i am using factory pattern and typecasting FBNRemoteDataService and FBNLocalDataService to FBNDataService interface.
but i dont think its a good idea that FBNDataService Interface throws java.lang.Exception unneccessarily. Is there any other way ?
(3) i think FBNLocalDataServiceImpl class is unneccesarrily there as FBNDataService can serve as a local connection ? Any comment ?
e.g
objFBNDataService = (FBNDataService)new Data(localdb)
instead of
objFBNDataService = (FBNLocalDataService)new Data(localdb)
(4) The most important point :
The SCJD assignment instruction says that "To connect with your server, you should create a client program. This implementation should include a class that implements the same public methods as the suncertify.db.Data class, although it will need different constructors to allow it to support the network configuration"
I dont know where and how my design is satisfying this requirement. Lot of confusion here ....This is the biggest doubt i have which is stopping me in submitting my assignment
(5) another issue is where to place db.db file, i mean which package/directory.
(6) Do i nead to pass the name and path of db.db file while starting the server or should i hardcode in my server. i am asking so becoz instruction says :
When you submit your assignment, you must ensure that it is packaged in such a way that it is completely clear how the examiner should run it using a java command line. Specifically, you should document clear, simple command lines that allow your programs to be run on any Java 2 platform, regardless of the underlying hardware and operating system. These command lines may only take configuration parameters selected from this list:
DNS name of the server
Port number used by the server
Data file name(s)
java.rmi.server.codebase
security manager policy file
As far as client is concerned in local mode i am asking the client to enter local db path in GUI
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic