01: /*
02: * JacORB - a free Java ORB
03: *
04: * Copyright (C) 1999-2004 Gerald Brose
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Library General Public
08: * License as published by the Free Software Foundation; either
09: * 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: import org.apache.avalon.framework.logger.Logger;
27:
28: /**
29: * This class registers the ClientContextTransferInterceptor
30: * and the ServerContextTransferInterceptor with the ORB.
31: *
32: * @author Vladimir Mencl
33: * @version $Id: TransactionInitializer.java,v 1.6 2005/11/20 16:49:19 andre.spiegel Exp $
34: */
35:
36: public class TransactionInitializer extends org.omg.CORBA.LocalObject
37: implements ORBInitializer {
38: public static int slot_id;
39:
40: public TransactionInitializer() {
41: }
42:
43: // implementation of org.omg.PortableInterceptor.ORBInitializerOperations interface
44: /**
45: * This method allocates a slot at the PICurrent, creates a codec and sets
46: * up the TransactionCurrent and the interceptor.
47: */
48: public void post_init(ORBInitInfo info) {
49: try {
50: ORB orb = ((org.jacorb.orb.portableInterceptor.ORBInitInfoImpl) info)
51: .getORB();
52: Logger logger = ((org.jacorb.orb.ORB) orb)
53: .getConfiguration().getNamedLogger(
54: "jacorb.tx_service");
55: slot_id = info.allocate_slot_id();
56:
57: Encoding encoding = new Encoding(ENCODING_CDR_ENCAPS.value,
58: (byte) 1, (byte) 0);
59: Codec codec = info.codec_factory().create_codec(encoding);
60:
61: TransactionCurrentImpl ts_current = new TransactionCurrentImpl(
62: orb, slot_id);
63: info.register_initial_reference("TransactionCurrent",
64: ts_current);
65:
66: info
67: .add_client_request_interceptor(new ClientContextTransferInterceptor(
68: logger, slot_id, codec));
69:
70: info
71: .add_server_request_interceptor(new ServerContextTransferInterceptor(
72: codec, slot_id, ts_current, orb));
73:
74: } catch (Exception e) {
75: // org.jacorb.util.Debug.output(2, e);
76: }
77: }
78:
79: public void pre_init(ORBInitInfo info) {
80: }
81:
82: } // TransactionInitializer
|