KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > logdemo > LogDemo


1 // ====================================================================
2
//
3
// ECM: The Extensible Container Model
4
// Copyright (C) 2004 THALES
5
// Contact: openccm-ecm@objectweb.org
6
//
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Lesser General Public
9
// License as published by the Free Software Foundation; either
10
// version 2.1 of the License, or any later version.
11
//
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// Lesser General Public License for more details.
16
//
17
// You should have received a copy of the GNU Lesser General Public
18
// License along with this library; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
// USA
21
//
22
// Initial developer(s): Mathieu Vadet.
23
// Initial Funding: IST COACH European project (IST-2001-34445)
24
// http://www.ist-coach.org
25
//
26
// ====================================================================
27

28
29
30 package org.objectweb.ccm.logdemo;
31
32 import org.objectweb.corba.runtime.*;
33
34 /**
35  ** The application deployment.
36  **/

37 public class LogDemo
38 implements Runnable JavaDoc
39 {
40     // main
41
private ORBService _orb_service;
42
43     public
44     LogDemo(ORBService orbs)
45     {
46         // main
47
_orb_service = orbs;
48     }
49
50     //
51
// java.lang.Runnable
52
//
53

54     final public void
55     run()
56     {
57         try {
58             // obtain the INS scheme of the registration service
59
RegistrationService regs = org.objectweb.corba.runtime.Runtime.getRegistrationService();
60             INSRegistrationScheme scheme = (INSRegistrationScheme)regs.get_scheme(INSRegistrationScheme.SCHEME_ID);
61
62             // obtain homes
63
System.err.println("## Obtain homes");
64             ClientHome chome = ClientHomeHelper.narrow(scheme.lookup("ClientHome", _orb_service));
65             ServerHome shome = ServerHomeHelper.narrow(scheme.lookup("ServerHome", _orb_service));
66             AsyncServerHome ashome = AsyncServerHomeHelper.narrow(scheme.lookup("AsyncServerHome", _orb_service));
67
68             // create components
69
System.err.println("## Create components");
70             Client client1 = chome.create();
71             Client client2 = chome.create();
72             Server server = shome.create();
73             AsyncServer aserver = ashome.create();
74
75             // configure
76
System.err.println("## Configure components");
77             client1.name("Mathieu");
78             client2.name("Vincent");
79             server.name("Pascal");
80             aserver.name("Async Pascal");
81             // connect display facet/receptacle
82
System.err.println("## Connect client/server");
83             SynchronousDisplay dis = server.provide_display();
84             client1.connect_display(dis);
85             client2.connect_display(dis);
86             // connect message consumer/emitter
87
System.err.println("## Connect client/asyncserver");
88             AsyncMessageConsumer cons = aserver.get_consumer_async_display();
89             client1.connect_async_display(cons);
90             client2.connect_async_display(cons);
91
92             // complete configuration
93
System.err.println("## Complete configuration");
94             client1.configuration_complete();
95             client2.configuration_complete();
96             server.configuration_complete();
97             aserver.configuration_complete();
98         } catch (Exception JavaDoc ex) {
99             throw new Error JavaDoc(ex.getMessage());
100         }
101
102         System.out.println("Again ....");
103         System.exit(1);
104     }
105
106     static public Runnable JavaDoc
107     main(ORBService orbs)
108     {
109         return new LogDemo(orbs);
110     }
111 }
112
113
114
115
116
117
118
119
Popular Tags