CountPOAServer

CountPOAServer - Activate the POA manager...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// CountPOAServer.java: The Count Server main program / import org.omg.PortableServer.*; import org.omg.CosNaming.*; i class CountPOAServer { static public void main(String[] args) { try { // Initialize the ORB org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null); // get a reference to the root POA POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); // Create policies for our persistent POA org.omg.CORBA.Policy[] policies = { rootPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT) }; // Create myPOA with the right policies POA myPOA = rootPOA.create_POA( "count_poa", rootPOA.the_POAManager(), policies ); // Create the servant CountPOAServant countServant = new CountPOAServant(); // Decide on the ID for the servant byte[] countId = "Count".getBytes(); // Activate the servant with the ID on myPOA myPOA.activate_object_with_id(countId, countServant);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // Activate the POA manager rootPOA.the_POAManager().activate(); // get a reference to the Naming Service root context org.omg.CORBA.Object nameServiceObj = orb.resolve_initial_references("NameService"); if (nameServiceObj == null) { System.out.println("nameServiceObj = null"); return; } NamingContextExt nameService = NamingContextExtHelper.narrow(nameServiceObj); if (nameService == null) { System.out.println("nameService = null"); return; } // bind the Count object in the Naming service NameComponent countName = {new NameComponent("countName", "")}; nameService.rebind(countName, myPOA.servant_to_reference(countServant)); System.out.println(myPOA.servant_to_reference(countServant) + " is ready."); // Wait for incoming requests orb.run(); } catch(Exception e) { System.err.println(e); } } }...
View Full Document

This note was uploaded on 09/17/2009 for the course CMPE 273 taught by Professor Shim during the Fall '09 term at San Jose State.

Page1 / 2

CountPOAServer - Activate the POA manager...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online