Archived

This forum has been archived. Please start a new discussion on GitHub.

Implementing Stats with Java

Hi,

I am getting confused trying to implement my own Ice.Stats with Java.

The only working solution I found is something like

class MyStats extends LocalObjectImpl implements Stats{

public void bytesSent(String prot, int num) {
System.out.println(prot+": sent "+num+" bytes");
}

public void bytesReceived(String prot, int num) {
System.out.println(prot+": received "+num+" bytes");
}
}

Is it correct? Well, it works but it seems strange to me (but it is probably because it is the first time I implement ICE local objects)

Indeed MyStats must at least implements Stats so that I can pass it to the setStats member of the communicator, but as always with IceJ I cannot implement directely the Stats interface (for Ice objects I have to extend the _*Disp class). In this particular case Java complains about
"The inherited method Object.clone() cannot hide the public abstract method in LocalObject"

I tried to implement _StatsOperationNC, but of course MyStat is then no longer a Stats.

Could you just validate my construction?

Thank you very much in advance for your help.

Comments

  • mes
    mes California
    Hi,

    Yes, the simplest approach is to extend Ice.LocalObjectImpl and implement Ice.Stats. If you would prefer not to extend LocalObjectImpl, then your class must implement the methods defined by the LocalObject interface, as well as those in Stats. If you look at the definition of LocalObjectImpl, you'll see that it's very trivial.

    Take care,
    - Mark
  • Hi,

    thank you for your reply. I am happy to see I was right.

    Sincerly,
    Sylvain