aspose file tools*
The moose likes Distributed Java and the fly likes Someone pls explain these technologies... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Someone pls explain these technologies..." Watch "Someone pls explain these technologies..." New topic
Author

Someone pls explain these technologies...

Joe Tseng
Greenhorn

Joined: Nov 09, 2004
Posts: 23
My interest in using Java-based distributed computing technologies has piqued, but I'm getting what is seemingly conflicting, IMO definitely confusing information. From what I have read so far, here are my questions:

  • What I want to do is create lightweight agents that can talk back and forth to a central server; is CORBA for me, is it actually something else I want to use, or is that ability not available for Java right now?
  • What are the differences between CORBA, RMI, and RMI-IIOP? How are they related to each other?
  • I read some online information re: RMI and it seems like you still need a web server to make it all work; is that true, or did I misread something?
  • Can anyone suggest any helpful documentation? It seems to me the books on these topics are somewhat out of date.


  • [ December 13, 2004: Message edited by: Joe Tseng ]
    omar bili
    Ranch Hand

    Joined: Aug 13, 2004
    Posts: 177
    Hi Joe
    CORBA, RMI will make some objects accessible from distant
    This will allow you to call methods on the server.
    If you are new to all this you can start with the RMI, witch is
    Java to java objects unlike CORBA, coz CORBA can be used
    With different programming languages like C++ to java .
    Finally NO, You don�t need a web server to make the RMI work.
    Here is a simple example that may allow you to run the RMI on ur
    machine.

    1.interface declaration :

    import java.rmi.* ;
    import java.util.* ;

    public interface Car extends Remote
    {
    Vector getData() throws RemoteException ;
    boolean isConnected() throws RemoteException ;
    }


    2.interface implementation :
    /* this class access an database you can put whatever you like in the methode getData */


    import java.rmi.* ;
    import java.rmi.server.UnicastRemoteObject;
    import java.sql.* ;
    import sun.jdbc.odbc.* ;
    import java.util.* ;

    public class CarImpl extends UnicastRemoteObject implements Car {
    CarImpl() throws RemoteException {}

    public boolean isConnected() throws RemoteException {
    return true ;
    }


    public Vector getData() throws RemoteException {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
    Connection con = DriverManager.getConnection("jdbc dbc:ALIGDB","","") ;

    Statement stmt = con.createStatement() ;
    String sq = "select * from cars " ;
    ResultSet rs = stmt.executeQuery(sq) ;



    Vector data = new Vector() ;
    Vector v ;
    while(rs.next()) {
    v = new Vector() ;
    v.add(rs.getString(1)) ;
    v.add(rs.getString(2)) ;
    v.add(rs.getString(3)) ;

    data.add(v);

    }

    return data ;
    }
    catch(Exception exc) {
    System.out.println("Error: "+ exc.getMessage()) ;
    return null ;
    }

    }
    }

    3.
    generate the stubs and the skeleton by compiling the CarImpl
    with the rmic compiler.

    On the dos prompt.
    C:/rmic CarImpl

    This step is not necessary if you are using Java 5

    3.create the server.
    import java.rmi.* ;

    public class Server {

    public static void main(String[] args) {

    try{
    CarImpl carImpl = new CarImpl() ;
    Naming.rebind("//127.0.0.1/CARS", carImpl) ;
    }

    catch(Exception exc) {
    System.out.println("Error: "+exc.getMessage()) ;

    }
    }
    }


    4.
    create the client
    import java.rmi.* ;
    import java.sql.* ;
    import java.util.* ;

    public class Client {
    public static void main(String[] args) {
    try{
    Car car = (Car)Naming.lookup("//127.0.0.1/CARS") ;
    /* you usually put the server�s IP /*

    if (car.isConnected()) {
    System.out.println("Connected to Server \n\n") ;
    }
    Vector data = car.getData() ;
    Vector v = new Vector();
    for (int i = 0 ; i < data.size() ; i++) {
    v = (Vector)data.elementAt(i) ;
    System.out.println(v.elementAt(0) + "\t " + v.elementAt(1) + "\t " + v.elementAt(2)) ;
    }
    System.out.println("\n\n") ;
    }


    catch(Exception exc) {
    System.out.println("Error: "+ exc.getMessage()) ;
    }

    }
    }


    before running the server you must run the rmiregistry
    on the dos prompt:

    c:/rmiregistry
    then run the server
    then run several clients on different machines



    Regards, Omar
    William Brogden
    Author and all-around good cowpoke
    Rancher

    Joined: Mar 22, 2000
    Posts: 12823
        
        5
    What I want to do is create lightweight agents that can talk back and forth to a central server; is CORBA for me, is it actually something else I want to use, or is that ability not available for Java right now?

    Why not use a servlet based central server and send messages with HTTP? That makes for a pretty lightweight client and can avoid problems with firewalls.

    You need to define some more characteristics of the system you want to build - how many clients, local or WAN, can message delivery be unreliable, etc.

    Bill
    Joe Tseng
    Greenhorn

    Joined: Nov 09, 2004
    Posts: 23
    Why not use a servlet based central server and send messages with HTTP? That makes for a pretty lightweight client and can avoid problems with firewalls.

    You need to define some more characteristics of the system you want to build - how many clients, local or WAN, can message delivery be unreliable, etc.


    OK here goes nothing... I am interested in creating a system where I could have a server talk to a lightweight agent and vice versa. The server could get a directive from an admin or a cron job and send that directive to the affected agents. The agents would be event-driven or job-driven and send messages back to the server. I figure the agents could work with both servers and workstations/PCs, thus IMO the need for the small size.

    Unless I'm shown otherwise, I didn't believe this kind of interaction could (or should) be done using web services, since bidirectional communications required the use of web servers on both ends, and I want to have the agent side of the equation as small and compartmentalized as possible.
    William Brogden
    Author and all-around good cowpoke
    Rancher

    Joined: Mar 22, 2000
    Posts: 12823
        
        5
    The current (November 04) JDJ has an article "Distributed Notification with Java RMI" which appears to be what you are talking about. Basically, each client needs to register itself with the RMI server - it can then get events from the server.
    Bill
    Joe Tseng
    Greenhorn

    Joined: Nov 09, 2004
    Posts: 23
    Thank you all for the responses; your suggestions should help me out quite a bit.
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Someone pls explain these technologies...