I have a project where I am using Java RMI to make objects remotely accessible to other objects. I need to make the following class remote:
public interface MarketBB extends Remote
{
public ArrayList<CloudEntry> getMarketBB() throws RemoteException;
public void moveAMP(int fromCloud, int toCloud) throws RemoteException;
}
The problem that I have is that because the ArrayList is holding CloudEntry objects, when the getMarketBB method is called from another object, nothing is returned.
Is there a way of making the ArrayList of CloudEntry classes remotely accessible?
Here is the code for the CloudEntry class:
public class CloudEntryImpl implements CloudEntry {
int cloudId;
String cloudName;
double speedGHz;
double costPerGhzH;
double commsCost;
double commsTime;
int noAMPs;
//constructor, get and set methods for fields
}
And the CloudEntry interface:
public interface CloudEntry extends Remote {
public void setNoAmps(int noAmps) throws RemoteException;
public String getCloudName() throws RemoteException;
public String getCloudDetails() throws RemoteException;
}
Your CloudEntryImpl
is not serializable. Try changing it to:
public class CloudEntryImpl extends UnicastRemoteObject implements CloudEntry {
//...
}