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