1 package org.jacorb.test.orb.connection; 2 3 import java.util.Properties ; 4 5 import org.jacorb.test.*; 6 import org.omg.CORBA.*; 7 import org.omg.GIOP.*; 8 import org.omg.BiDirPolicy.*; 9 import org.omg.PortableServer.*; 10 11 15 public class BiDirServerImpl extends BiDirServerPOA 16 { 17 private ClientCallback callback = null; 18 19 public void register_callback(ClientCallback cc) 20 { 21 this.callback = cc; 22 } 23 24 public void callback_hello(String message) 25 { 26 final String msg = message; 27 new Thread (new Runnable () 28 { 29 public void run() 30 { 31 try 32 { 33 Thread.sleep (200); 34 } 35 catch (InterruptedException ex) 36 { 37 } 39 callback.hello (msg); 40 } 41 }).start(); 42 } 43 44 public int get_open_client_transports() 45 { 46 return org.jacorb.orb.iiop.ClientIIOPConnection.openTransports; 47 } 48 49 public static void main (String [] args) 50 { 51 try 52 { 53 org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null); 54 55 Any any = orb.create_any(); 56 BidirectionalPolicyValueHelper.insert(any, BOTH.value); 57 58 POA root_poa = (POA) orb.resolve_initial_references("RootPOA"); 59 60 Policy[] policies = new Policy[4]; 61 policies[0] = 62 root_poa.create_lifespan_policy(LifespanPolicyValue.TRANSIENT); 63 64 policies[1] = 65 root_poa.create_id_assignment_policy( 66 IdAssignmentPolicyValue.SYSTEM_ID); 67 68 policies[2] = 69 root_poa.create_implicit_activation_policy( 70 ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION); 71 72 policies[3] = 73 orb.create_policy(BIDIRECTIONAL_POLICY_TYPE.value, any); 74 75 POA bidir_poa = 76 root_poa.create_POA( 77 "BiDirPOA", 78 root_poa.the_POAManager(), 79 policies); 80 bidir_poa.the_POAManager().activate(); 81 82 org.omg.CORBA.Object o = 83 bidir_poa.servant_to_reference(new BiDirServerImpl()); 84 85 System.out.println ("SERVER IOR: " + orb.object_to_string(o)); 86 System.out.flush(); 87 88 orb.run(); 89 } 90 catch (Exception e) 91 { 92 System.out.println ("ERROR: " + e); 93 } 94 95 } 96 97 } 98 | Popular Tags |