wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes OO Design issue with Data and RMI instance?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "OO Design issue with Data and RMI instance??" Watch "OO Design issue with Data and RMI instance??" New topic
Author

OO Design issue with Data and RMI instance??

Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
I have the following problems see below..
package suncertify.db;
import java.io.*;
import java.util.*;
import java.rmi.*;
public interface DataClient extends Remote
{
public FieldInfo [] getFieldInfo()throws RemoteException;
public DataInfo getRecord(int recNum)throws DatabaseException, RemoteException;
public DataInfo find(String toMatch)throws DatabaseException, RemoteException;
public void add(String [] newData)throws DatabaseException, RemoteException;
public void modify(DataInfo newData)throws DatabaseException, RemoteException;
public void delete(DataInfo toDelete)throws DatabaseException, RemoteException;
public void close() throws RemoteException;
public void lock(int record)throws IOException, RemoteException;
public void unlock(int record)throws RemoteException;
public DataInfo[] criteriaFind(String criteria) throws DatabaseException, RemoteException;
public String[] getComboValues(int fieldNum) throws DatabaseException, RemoteException;
public int getMatchCount(String matchCount) throws DatabaseException,RemoteException;
}

package suncertify.db;
import java.io.*;
import java.util.*;
public class DataClientLocal implements DataClient
{
public DataClientLocal(String dbname){
try
{
Data dbInstance = new Data(dbname);
}
catch(Exception ex)
{
System.out.println("Database connection failed");
}
}
}
//next code>DataClientRMI
package suncertify.db;
import java.io.*;
import java.util.*;
import java.rmi.*;
public class DataClientRMI implements DataClient
{
public DataClientRMI(){
try
{
////////
}
catch(Exception ex)
{
System.out.println("Database connection failed");
}
}
}

then on the client:::::
public switchMode
{
DataClient data =null;
if(localmode)
{
data = new DataClientLocal(arg1,...)
}
else
{
data = new DataClientRMI(arg1,...)
}
}
Problem is when I try to compile these above classes::
DataClientRMI
DataClientLocal
//I get the errors these two classes must be declared abstract but if I do this I cant create an instance of these 2 classes in myabove switchMode().
Any suggestions or solutions for my code.Perhaps I am missing something here???
Thanks Lisa

ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
Have you implement all methods in in the interface ? If you did not implement all methods in an interface your class implemented, you will get such error message you had.
ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
Have you implemented all methods in the interface ? If you did not implement all methods in the interface, you will get such error message when you compile your class.

koray guclu
Ranch Hand

Joined: Feb 23, 2001
Posts: 59
You must implement all your classes. Take a carefull look to your class implmentations again
------------------
------------------------
Koray G��l�
(B.s. Computer Engineer)


-----------------------------------------------------<BR> Koray GUCLU ~ the sky has no limit ~<BR> (B.s. Computer Engineer)<BR> Frankfurt am Main, Germany<BR> web : <A HREF="http://www.geocities.com/korayguclu/<BR rel="nofollow">" TARGET=_blank>http://www.geocities.com/korayguclu/<BR></A> mail: korayguclu@yahoo.com<BR>-----------------------------------------------------
Sachin Kombrabail
Greenhorn

Joined: Aug 28, 2000
Posts: 14
I am assuming that you intentionally do not want to implement all the methods that you have defined in your interface. One solution is to go back and implement all the methods of the interface. The other solution is to define an Adapter class. This class implements the interface and has empty implements for each. You can then subclass that adapter and define only those methods that you want. So first decide whether you want to implement all the methods or not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OO Design issue with Data and RMI instance??