KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > coach > tracing > service > pi > TracingServiceORBInitializer


1 /***************************************************************************/
2 /* COACH: Component Based Open Source Architecture for */
3 /* Distributed Telecom Applications */
4 /* See: http://www.objectweb.org/ */
5 /* */
6 /* Copyright (C) 2003 Lucent Technologies Nederland BV */
7 /* Bell Labs Advanced Technologies - EMEA */
8 /* */
9 /* Initial developer(s): Harold Batteram */
10 /* */
11 /* This library is free software; you can redistribute it and/or */
12 /* modify it under the terms of the GNU Lesser General Public */
13 /* License as published by the Free Software Foundation; either */
14 /* version 2.1 of the License, or (at your option) any later version. */
15 /* */
16 /* This library is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
19 /* Lesser General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public */
22 /* License along with this library; if not, write to the Free Software */
23 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
24 /***************************************************************************/
25 package org.coach.tracing.service.pi;
26
27 import org.omg.IOP.Codec JavaDoc;
28 import org.omg.IOP.CodecFactory JavaDoc;
29 import org.omg.IOP.CodecFactoryHelper JavaDoc;
30 import org.omg.IOP.Encoding JavaDoc;
31 import org.omg.PortableInterceptor.*;
32 import org.omg.CORBA.LocalObject JavaDoc;
33 import org.coach.tracing.api.pi.*;
34
35 public class TracingServiceORBInitializer extends LocalObject JavaDoc implements ORBInitializer
36 {
37     private TracingServiceImpl aServiceImpl;
38     private TracingServiceInterceptor aServiceInterceptor;
39
40     public void pre_init(ORBInitInfo info)
41     {
42         try
43         {
44 // System.err.println("TracingServiceORBInitializer pre_init()");
45

46             int id = info.allocate_slot_id();
47
48             aServiceInterceptor = new TracingServiceInterceptor(id);
49
50             info.add_client_request_interceptor(aServiceInterceptor);
51             info.add_server_request_interceptor(aServiceInterceptor);
52
53             // Create and register a reference to the service to be
54
// used by client code.
55
aServiceImpl = new TracingServiceImpl(id);
56             info.register_initial_reference("TracingService", aServiceImpl);
57         }
58         catch (Throwable JavaDoc t)
59         {
60             t.printStackTrace();
61         }
62     }
63
64     public void post_init(ORBInitInfo info)
65     {
66         try
67         {
68 // System.err.println("TracingServiceORBInitializer post_init()");
69
Current piCurrent = CurrentHelper.narrow(info.resolve_initial_references("PICurrent"));
70             CodecFactory JavaDoc codecFactory = CodecFactoryHelper.narrow(info.resolve_initial_references("CodecFactory"));
71     // Encoding encoding = new Encoding((short)0, (byte)1, (byte)2);
72
Encoding JavaDoc encoding = new Encoding JavaDoc((short)0, (byte)1, (byte)0);
73             Codec JavaDoc codec = codecFactory.create_codec(encoding);
74             aServiceInterceptor.init(piCurrent, codec);
75             aServiceImpl.setPICurrent(piCurrent);
76         }
77         catch (Throwable JavaDoc t)
78         {
79             t.printStackTrace();
80         }
81     }
82 }
83
Popular Tags