A Detailed Comparison of CORBA, DCOM and Java/RMI[9]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 qddabao 的 blog

java/rmi server object - all the classes that are required for java/rmi are defined in the java.rmi package. the java/rmi server object shown extends the unicastremoteobject class that has all of java/rmi's remoting methods defined and implements the stockmarket interface. the stockmarketimpl class and the get_price() method are declared as public so that they will be accessible from outside the package. the stockmarketimpl class implements all the operations declared in our java/rmi interface file. we need to provide a constructor which takes in a name of type string for our java/rmi object server class since the name of the java/rmi server class is used to establish a binding and associate a public name with this java/rmi server object in the rmiregistry. the get_price() method is capable of throwing a remoteexception since it is a remotable method.

the server main programs

corba server main - the first thing that has to be done by the main program is to initialize the corba orb using orb.init(). an object adapter (oa) sits on top of the orb, and is responsible for connecting the corba server object implementation to the corba orb. object adapters provide services like generation and interpretation of object references, method invocation, object activation and deactivation, and mapping object references to implementations. you have to initialize either the basic object adapter(boa) or the portable object adapter(poa) depending on what your orb supports. (note : i use inprise's visibroker as my corba orb and hence i conform to its implementation requirement where i need to init the boa). you do this by calling orb.boa_init(). we then create the corba server object with the call

stockmarketimpl stockmarketimpl = new stockmarketimpl("nasdaq");

note that we pass in a name "nasdaq" by which our object is identified by all corba services. we then inform the orb that the server object is ready to receive invocations by the statement:

boa.obj_is_ready( stockmarketimpl );

since we are using the corba object service's naming service for our clients to connect to us, we will have to bind our server object with a naming service, so that clients would be able to find us. the following code helps us to do that. (note : this ensures that our code will work with any corba orb. if our clients use the bind() method -specific to visibroker and orbix- to connect to the server object we do not need to do this.)
org.omg.corba.object object = orb.resolve_initial_references("nameservice");
namingcontext root = namingcontexthelper.narrow( object ) ;
namecomponent[] name = new namecomponent[1];
name[0] = new namecomponent("nasdaq", "");

本文关键:Corba DCOM RMI
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top