Yay
Yay

Reputation: 3

Convert rmi interface to CORBA .idl

how can I convert my rmi interface into an .idl file in CORBA. Im currently working in a chat application. So here's my interface:

import java.rmi.*;

public interface ChatServer extends Remote{
      void register(ChatClient c) throws RemoteException;
      void broadcast(String s) throws RemoteException;
}

I tried doing it but it said theres and error with the "void" and ChatClient being an undeclared type. How can I solve this? Thank you for your help :)

p.s I got the rmi code in the internet, I only need it as my reference so that I can convert it to CORBA application.

Upvotes: 0

Views: 194

Answers (1)

Victor Stafusa
Victor Stafusa

Reputation: 14593

You may try to extend java.io.Serializable:

import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface ChatServer extends Remote, Serializable {
    void register(ChatClient c) throws RemoteException;
    void broadcast(String s) throws RemoteException;
}
import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface ChatClient extends Remote, Serializable {
    void register(ChatServer c) throws RemoteException;
    void broadcast(String s) throws RemoteException;
}

The reason for that all the parameters and all the non-void return types must be Serializable things. String is Serializable.

Other than that, this seems to be a very poor design. Those interfaces are intended to denote which are the operations offered by each endpoint. On the other hand, Serializable stuff are the data transfered between endpoints. By creating classes/objects/interfaces that uses both hats, it tends to surely become a big mess.

A better idea would be:

import java.io.Serializable;

public class ClientId implements Serializable {
   // Data used to identify the client.
}
import java.io.Serializable;

public class ServerId implements Serializable {
   // Data used to identify the server.
}
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface ChatServer extends Remote {
    void register(ClientId c) throws RemoteException;
    void broadcast(String s) throws RemoteException;
}
import java.rmi.Remote;
import java.rmi.RemoteException;

public interface ChatClient extends Remote {
    void register(ServerId c) throws RemoteException;
    void broadcast(String s) throws RemoteException;
}

Upvotes: 1

Related Questions