AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing "Hello World" String from one Corba Server to anothe

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
milesd
Guest





PostPosted: Thu Jan 19, 2006 9:58 pm    Post subject: Passing "Hello World" String from one Corba Server to anothe Reply with quote



Hello, I am rather new to Corba, and would like to know how to pass a
simple "Hello World" string "upstream" from one "Server" to another
"Server".


I have a corba RoomBooking Client and Server (which are below). I can
get client to call the server via a myRoom naming reference via
tnameserv - no worries.


WHAT I cannot figure out is how to get a number of room booking servers

to pass an object (could just be a "Hello World" string) from one
server to another server.


For example if I had started a client, and two server.


1. The client would call the first server, and pass a "Hello World
Message" to that server.
2. Server One accepts the "Hello World" message, and then Forks
(creates a thread), AND passes the message up-stream to server two (by
getting the Name context of Server Two).
3. Server Two receives the "Hello World" message, Forks and Passes it
back to the Client which called Server One with the initial message.


What I cannot figure out is how Servers One or Two fork (so they can
also accept connections) BUT also can pass a message upstream to
another Server.


Can someone please provide an easy to understand example, tutorial URL,

Chapter in a book. Source code would be very useful as a reference.


cheers


Miles.


----
// Client some code snipped


public HashMap getListofRooms() {


BindingListHolder blh = new BindingListHolder();
BindingIteratorHolder bih = new BindingIteratorHolder();
BindingHolder bh = new BindingHolder();


room_context.list(0, blh, bih);


Room myRoom;
HashMap myHash = new HashMap();


try {


if ( bih.value != null ) {
while ( bih.value.next_one( bh )) {
myRoom = RoomHelper.narrow( room_context.resolve(
bh.value.binding_name ));


if (myRoom != null) {
System.out.println( "FOUND ROOM: " +
myRoom.name() );
myHash.put( myRoom.name(), myRoom );
myRoom = null;
}
}
}
} catch (Exception e) {
System.out.println( e );
}


return ( myHash );
}


String hello = helloRef.sayHello();
----


AND a Corba Server which calls


public class RoomServer {
public static void main(String[] args) {
String context_name, str_name;


// You must specify your room name as a single argument


if ( args.length != 1 ) {
System.out.println("Usage: RoomServer roomName");
System.exit( 1 );
}


System.out.println("ROOM NAME: " + args[0]);


// context reference name


context_name = new String("BuildingApplications/Rooms");


try {
//init
ORB orb = ORB.init( args, null );
POA poa = POAHelper.narrow(
orb.resolve_initial_references(
"RootPOA"));
poa.the_POAManager().activate();


// create the Room object and export the object
reference
org.omg.CORBA.Object room_obj =
poa.servant_to_reference( new RoomImpl( args[0]
) );


// register with CORBA naming service
str_name = context_name + "/" + args[0];


NamingContextExt root = NamingContextExtHelper.narrow(
orb.resolve_initial_references("NameService")
);


try {
// make sure the "rooms" context is bound is
bound correctly
root.bind_new_context( root.to_name(
context_name ));
} catch( AlreadyBound ab ) {
// does not matter .
} catch( NotFound nf ) {
System.err.println("Context " + context_name +
" not found,
start MeetingFactoryServer first.");
System.err.println("exiting ...");
}


root.bind( root.to_name( str_name), room_obj );


// wait for incoming requests to be serviced
orb.run();
} catch( AlreadyBound already_bound ) {
System.err.println("Room " + context_name + args[0] +
" already bound.");
System.err.println("exiting ...");
} catch(UserException ue) {
ue.printStackTrace();
} catch(SystemException se) {
System.err.println(se);
}
}

}


//end


Reply

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.