01: package demo.bidir;
02:
03: import org.omg.CosNaming.*;
04: import org.omg.PortableServer.*;
05: import org.omg.BiDirPolicy.*;
06: import org.omg.CORBA.*;
07:
08: import java.util.Properties;
09:
10: /**
11: * Client.java
12: *
13: *
14: * Created: Mon Sep 3 19:28:34 2001
15: *
16: * @author Nicolas Noffke
17: * @version $Id: Client.java,v 1.2 2003/12/01 12:36:00 simon.mcqueen Exp $
18: */
19:
20: public class Client extends ClientCallbackPOA {
21: public Client() {
22: }
23:
24: public void hello(String message) {
25: System.out
26: .println("Client callback object received hello message >"
27: + message + '<');
28: }
29:
30: public static void main(String[] args) throws Exception {
31: Properties props = new Properties();
32: props
33: .put(
34: "org.omg.PortableInterceptor.ORBInitializerClass.bidir_init",
35: "org.jacorb.orb.giop.BiDirConnectionInitializer");
36:
37: org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, props);
38:
39: NamingContextExt nc = NamingContextExtHelper.narrow(orb
40: .resolve_initial_references("NameService"));
41:
42: org.omg.CORBA.Object o = nc
43: .resolve(nc.to_name("bidir.example"));
44:
45: Server server = ServerHelper.narrow(o);
46:
47: Any any = orb.create_any();
48: BidirectionalPolicyValueHelper.insert(any, BOTH.value);
49:
50: POA root_poa = (POA) orb.resolve_initial_references("RootPOA");
51:
52: Policy[] policies = new Policy[4];
53: policies[0] = root_poa
54: .create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
55:
56: policies[1] = root_poa
57: .create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
58:
59: policies[2] = root_poa
60: .create_implicit_activation_policy(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
61:
62: policies[3] = orb.create_policy(
63: BIDIRECTIONAL_POLICY_TYPE.value, any);
64:
65: POA bidir_poa = root_poa.create_POA("BiDirPOA", root_poa
66: .the_POAManager(), policies);
67: bidir_poa.the_POAManager().activate();
68:
69: ClientCallback ccb = ClientCallbackHelper.narrow(bidir_poa
70: .servant_to_reference(new Client()));
71:
72: server.register_callback(ccb);
73:
74: server.callback_hello("A test string");
75: }
76: }// Client
|