KickJava   Java API By Example, From Geeks To Geeks.

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


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
24 import org.omg.PortableInterceptor.*;
25 import org.omg.IOP.Codec JavaDoc;
26 import org.omg.IOP.ServiceContext JavaDoc;
27 import org.omg.IOP.TransactionService JavaDoc;
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.10 2004/05/06 12:40:01 nicolas Exp $
36  */

37
38 public class ClientContextTransferInterceptor
39     extends org.omg.CORBA.LocalObject JavaDoc
40     implements ClientRequestInterceptor
41 {
42
43     private int slot_id = -1;
44     private Codec JavaDoc codec = null;
45
46     public ClientContextTransferInterceptor(int slot_id, Codec JavaDoc codec)
47     {
48         this.slot_id = slot_id;
49         this.codec = codec;
50     }
51
52     // implementation of org.omg.PortableInterceptor.InterceptorOperations interface
53

54     public String JavaDoc name()
55     {
56         return "ClientContextTransferInterceptor";
57     }
58
59     public void destroy()
60     {
61     }
62
63     /**
64      * Add the propagation context to the outgoing message
65      */

66
67     public void send_request( ClientRequestInfo ri )
68         throws ForwardRequest
69     {
70         try
71         {
72             org.omg.CORBA.Any JavaDoc any = ri.get_slot(slot_id);
73       
74             if (! (any.type().kind().value() == org.omg.CORBA.TCKind._tk_null))
75             {
76                 ServiceContext JavaDoc ctx = new ServiceContext JavaDoc(TransactionService.value,
77                                                         codec.encode(any));
78
79                 ri.add_request_service_context(ctx, false);
80             }
81         }
82         catch (Exception JavaDoc e)
83         {
84
85         }
86     }
87
88     public void send_poll(ClientRequestInfo ri){
89     }
90
91     public void receive_reply(ClientRequestInfo ri){
92     }
93
94     public void receive_exception(ClientRequestInfo ri)
95         throws ForwardRequest{
96     }
97
98     public void receive_other(ClientRequestInfo ri)
99         throws ForwardRequest{
100     }
101 } // ClientContextTransferInterceptor
102

103
104
105
106
107
108
Popular Tags