How to make remote access to an archaist

I have a project in which I use Java RMI to make objects remotely accessible to other objects. I need to make the following class pool:

public interface MarketBB extends Remote
{
   public ArrayList<CloudEntry> getMarketBB() throws RemoteException; 
   public void moveAMP(int fromCloud, int toCloud) throws RemoteException;
}

The problem is that since ArrayList supports CloudEntry objects, when the getMarketBB method is called from another object, nothing is returned.

Is there a way to make access to the ArrayList CloudEntry classes available?

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 CloudEntry interface:

public interface CloudEntry extends Remote {

    public void setNoAmps(int noAmps) throws RemoteException;

    public String getCloudName() throws RemoteException;

    public String getCloudDetails() throws RemoteException;

}
+3
source share
2 answers

Yours is CloudEntryImplnot serializable. Try changing it to:

public class CloudEntryImpl extends UnicastRemoteObject implements CloudEntry {
    //...
}
0
source

getMarketBB () returns a copy of the ArrayList array. You cannot force it to return a "live" view of the list.

, , . IMHO RMI .

public void addCloudEntry(CloudEntry ce);
public CloudEntry getCloudEntry(int i);
0

Source: https://habr.com/ru/post/1794147/


All Articles