Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OO Design issue with Data and RMI instance??

 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must implement all your classes. Take a carefull look to your class implmentations again
------------------
------------------------
Koray G��l�
(B.s. Computer Engineer)
 
Sachin Kombrabail
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic