1 package demo.bidir; 2 3 import org.omg.CosNaming.*; 4 import org.omg.PortableServer.*; 5 import org.omg.BiDirPolicy.*; 6 import org.omg.CORBA.*; 7 8 import java.util.Properties ; 9 18 19 public class Client 20 extends ClientCallbackPOA 21 { 22 public Client () 23 { 24 } 25 26 public void hello( String message ) 27 { 28 System.out.println( "Client callback object received hello message >" + 29 message + 30 '<'); 31 } 32 33 public static void main( String [] args ) 34 throws Exception 35 { 36 Properties props = new Properties (); 37 props.put( "org.omg.PortableInterceptor.ORBInitializerClass.bidir_init", 38 "org.jacorb.orb.giop.BiDirConnectionInitializer" ); 39 40 org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init( args, props ); 41 42 NamingContextExt nc = 43 NamingContextExtHelper.narrow( 44 orb.resolve_initial_references( "NameService" )); 45 46 org.omg.CORBA.Object o = 47 nc.resolve( nc.to_name( "bidir.example" )); 48 49 Server server = ServerHelper.narrow( o ); 50 51 Any any = orb.create_any(); 52 BidirectionalPolicyValueHelper.insert( any, BOTH.value ); 53 54 POA root_poa = (POA) orb.resolve_initial_references( "RootPOA" ); 55 56 Policy[] policies = new Policy[4]; 57 policies[0] = 58 root_poa.create_lifespan_policy(LifespanPolicyValue.TRANSIENT); 59 60 policies[1] = 61 root_poa.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID); 62 63 policies[2] = 64 root_poa.create_implicit_activation_policy( ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION ); 65 66 policies[3] = orb.create_policy( BIDIRECTIONAL_POLICY_TYPE.value, 67 any ); 68 69 POA bidir_poa = root_poa.create_POA( "BiDirPOA", 70 root_poa.the_POAManager(), 71 policies ); 72 bidir_poa.the_POAManager().activate(); 73 74 ClientCallback ccb = ClientCallbackHelper.narrow( bidir_poa.servant_to_reference( new Client() )); 75 76 server.register_callback( ccb ); 77 78 server.callback_hello( "A test string" ); 79 } 80 } | Popular Tags |