CORBAs Portable Object Adaptor (POA) owes a good part of its flexibility the fact that starting with the root POA a whole tree of child POAs may be created, each of it with a different configuration given by different policies.
The POA which creates the object reference is used for all calls on this reference.
Demonstrate the usage of multiple POAs within one server process.
module POADemo { interface Greetings { string hello( in string strName); }; }; |
public class GreetingsImpl: POADemo.GreetingsPOA { public override string hello( string a_strmyName) { System.Console.WriteLine("Function 'OATest' Parameter '{0,20}'", a_strmyName); displayInfo(); return "Greetings to " + a_strmyName; } public void displayInfo() { Console.WriteLine( "My POA :{0}", _poa().the_name); Console.WriteLine( "The Default POA :{0}", _default_POA().the_name); byte[] oId = this._object_id(); Console.WriteLine( "Object ID :{0}", System.BitConverter.ToString(oId)); Ics.CORBA.Object oObj = _this_object(); oObj.printIOR(); } } |
m_oRootPOA = Ics.PortableServer.POAHelper.narrow( m_oOrb.resolve_initial_references( "RootPOA" )); m_oRootPOA.the_POAManager.activate(); |
Ics.CORBA.Policy[] oPol = new Ics.CORBA.Policy[1]; oPol[0] = m_oRootPOA.create_implicit_activation_policy( Ics.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION); Ics.PortableServer.POA oPOA_A = m_oRootPOA.create_POA( "A", null, null); Ics.PortableServer.POA oPOA_AA_1 = oPOA_A.create_POA( "AA_1", null, null); Ics.PortableServer.POA oPOA_AA_2 = oPOA_A.create_POA( "AA_2", null, null); Ics.PortableServer.POA oPOA_B = m_oRootPOA.create_POA( "B", null, null); Ics.PortableServer.POA oPOA_BB_1 = oPOA_B.create_POA( "BB_1", null, null); Ics.PortableServer.POA oPOA_BB_2 = oPOA_B.create_POA( "BB_2", null, oPol); GreetingsImpl oGreetingsImpl = new GreetingsImpl(); Ics.CORBA.Object oObjRef = oPOA_BB_2.servant_to_reference( oGreetingsImpl); |
Ics.CORBA._ORB.wrIORtoFile( "c:\\POADemo.ior", oObjRef ); |
Ics.CORBA.Object oGreetingsObj = m_oOrb.string_to_object( "file://c:\\POADemo.ior"); m_oIGreetings = POADemo.GreetingsHelper.narrow( oGreetingsObj); Console.WriteLine("Call hello '{0}' returned '{1}'", "Santa Claus", m_oIGreetings.hello("Santa Claus")); |
a.) Start the Server.
b.) Start the Client.