KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > transaction > TransactionInitializer


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1999-2004 Gerald Brose
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */

21 package org.jacorb.transaction;
22
23 import org.omg.PortableInterceptor.*;
24 import org.jacorb.orb.*;
25 import org.omg.IOP.*;
26 /**
27  * This class registers the ClientContextTransferInterceptor
28  * and the ServerContextTransferInterceptor with the ORB.
29  *
30  * @author Vladimir Mencl
31  * @version $Id: TransactionInitializer.java,v 1.5 2004/05/06 12:40:01 nicolas Exp $
32  */

33
34 public class TransactionInitializer
35     extends org.omg.CORBA.LocalObject JavaDoc
36     implements ORBInitializer
37 {
38     public static int slot_id;
39
40     public TransactionInitializer()
41     {
42     }
43     
44     // implementation of org.omg.PortableInterceptor.ORBInitializerOperations interface
45
/**
46      * This method allocates a slot at the PICurrent, creates a codec and sets
47      * up the TransactionCurrent and the interceptor.
48      */

49     public void post_init(ORBInitInfo info)
50     {
51         try
52         {
53             ORB orb = ((org.jacorb.orb.portableInterceptor.ORBInitInfoImpl)info).getORB();
54             slot_id = info.allocate_slot_id();
55             
56             Encoding encoding = new Encoding(ENCODING_CDR_ENCAPS.value,
57                                              (byte) 1, (byte) 0);
58             Codec codec = info.codec_factory().create_codec(encoding);
59             
60             TransactionCurrentImpl ts_current = new TransactionCurrentImpl(orb, slot_id);
61             info.register_initial_reference("TransactionCurrent", ts_current);
62             
63             info.add_client_request_interceptor(
64                    new ClientContextTransferInterceptor(slot_id, codec));
65             
66             info.add_server_request_interceptor(
67                          new ServerContextTransferInterceptor(codec,
68                                                               slot_id,
69                                                               ts_current,
70                                                               orb));
71
72         }
73         catch (Exception JavaDoc e)
74         {
75             // org.jacorb.util.Debug.output(2, e);
76
}
77     }
78
79     public void pre_init(ORBInitInfo info) {
80     }
81     
82 } // TransactionInitializer
83

84
Popular Tags