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.omg.IOP.Codec;
25: import org.omg.IOP.ServiceContext;
26: import org.omg.IOP.TransactionService;
27: import org.apache.avalon.framework.logger.Logger;
28:
29: /**
30: * This interceptor adds a service context with
31: * the transactions propagation context to the
32: * outgoing message.
33: *
34: * @author Nicolas Noffke
35: * @version $Id: ClientContextTransferInterceptor.java,v 1.11 2005/11/20 16:48:25 andre.spiegel Exp $
36: */
37:
38: public class ClientContextTransferInterceptor extends
39: org.omg.CORBA.LocalObject implements ClientRequestInterceptor {
40:
41: private int slot_id = -1;
42: private Codec codec = null;
43: private Logger logger = null;
44:
45: public ClientContextTransferInterceptor(Logger logger, int slot_id,
46: Codec codec) {
47: this .logger = logger;
48: this .slot_id = slot_id;
49: this .codec = codec;
50: }
51:
52: // implementation of org.omg.PortableInterceptor.InterceptorOperations interface
53:
54: public String name() {
55: return "ClientContextTransferInterceptor";
56: }
57:
58: public void destroy() {
59: }
60:
61: /**
62: * Add the propagation context to the outgoing message
63: */
64:
65: public void send_request(ClientRequestInfo ri)
66: throws ForwardRequest {
67: try {
68: org.omg.CORBA.Any any = ri.get_slot(slot_id);
69:
70: if (!(any.type().kind().value() == org.omg.CORBA.TCKind._tk_null)) {
71: ServiceContext ctx = new ServiceContext(
72: TransactionService.value, codec.encode(any));
73: if (logger.isDebugEnabled())
74: logger.debug("adding Transaction Service Context"
75: + " to outgoing request");
76: ri.add_request_service_context(ctx, false);
77: }
78: } catch (Exception e) {
79:
80: }
81: }
82:
83: public void send_poll(ClientRequestInfo ri) {
84: }
85:
86: public void receive_reply(ClientRequestInfo ri) {
87: }
88:
89: public void receive_exception(ClientRequestInfo ri)
90: throws ForwardRequest {
91: }
92:
93: public void receive_other(ClientRequestInfo ri)
94: throws ForwardRequest {
95: }
96: } // ClientContextTransferInterceptor
|