Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

To Calahan: this is an example of what doesn't work with my ORB

To Calahan: this is an example of what doesn't work with my ORB

To Calahan: this is an example of what doesn't work with my ORB

 In one of my previous posts I told I have a problem using my Java ORB. The code looks as:

import org.omg.CosNaming.*;
import org.omg.CORBA.*;

public class __main__ {
public static String __argomenti__ [] = new String[2];

public static void main(String args[]){
 int __count__;
 char[] __buffer__ = new char[1024];
 String __temp__ = "";
 String __temp1__ = "";
 java.io.FileReader rd = new java.io.FileReader("Config1.txt";
 while ((__count__ = rd.read(__buffer__, 0, 1024)) != -1)
  __temp__ = new String(__buffer__, 0, __count__);
  __temp1__ = __temp1__ + __temp__;
 __argomenti__[0] = "-ORBInitialHost";
 __argomenti__[1] = __temp1__.trim();
 ORB orb = ORB.init(__argomenti__,null);
 org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService";
 NamingContext ncRef = NamingContextHelper.narrow(objRef);
 contatoreServant c;
 NameComponent nc = new NameComponent("contatore", "ogg1";
 NameComponent pathc[] = {nc};
 contatoreServant d;
 NameComponent nd = new NameComponent("contatore", "ogg2";
 NameComponent pathd[] = {nd};
 c  =  new contatoreServant ( new String2("User1" );
 contatore contatoreServantRefogg1 = new _contatoreTie(c);
 ncRef.rebind(pathc, contatoreServantRefogg1);
 d  =  new contatoreServant ( new String2("User2" );
 contatore contatoreServantRefogg2 = new _contatoreTie(d);
 ncRef.rebind(pathd, contatoreServantRefogg2);
 java.lang.Object sync = new java.lang.Object();
 catch(Exception e)
 } // end __main__ class

When a client uses an object of type contatore the ORB uses only the first one connected to reply (in this example the one identified by "c" to the request..
Is there a way to solve this problem without making many changes or I have to think of another solution?

PS To Calahan: Thanks for your reply, how would you adapt your bank example to this ? The interface of "contatore" doesn't matter at all..

RE: To Calahan: this is an example of what doesn't work with my ORB

OK - from looking at your code you are connecting to this contatore object, now even though you say the word [b]new[/b] you are not getting a whole new object. What you are getting is a new local proxy object on the client siude which is connected to the remote contatore ORB. In effect you have to references to the same object.

To get two objects you would either need to register two contatore objects with the naming service (fine in a small system) or register a factory object in the naming service (good idea for a system with many objects). What you need to remember is that each contatore object ieUSER1 or USER2 , is a seperate object in your CORBA framework.

What you should do is have a contatoreFactory object which returns objects of type contatore this will give you a seperarte remote object for each instance.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close