KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > jtests > conform > interceptor > iiop > IIOPDummyClientInterceptor


1 /**
2  * Copyright (C) 2002,2005 - INRIA (www.inria.fr)
3  *
4  * CAROL: Common Architecture for RMI ObjectWeb Layer
5  *
6  * This library is developed inside the ObjectWeb Consortium,
7  * http://www.objectweb.org
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22  * USA
23  *
24  * --------------------------------------------------------------------------
25  * $Id: IIOPDummyClientInterceptor.java,v 1.5 2005/02/14 09:41:56 benoitf Exp $
26  * --------------------------------------------------------------------------
27  */

28 package org.objectweb.carol.jtests.conform.interceptor.iiop;
29
30 import org.omg.CORBA.LocalObject JavaDoc;
31 import org.omg.IOP.ServiceContext JavaDoc;
32 import org.omg.PortableInterceptor.ClientRequestInfo JavaDoc;
33 import org.omg.PortableInterceptor.ClientRequestInterceptor JavaDoc;
34 import org.omg.PortableInterceptor.ForwardRequest JavaDoc;
35
36 import org.objectweb.carol.util.configuration.TraceCarol;
37
38 /**
39  * Class <code>IIOPDummyClientInterceptor</code> is a IIOP Dummy client
40  * interceptor for carol testing
41  * @author Guillaume Riviere (Guillaume.Riviere@inrialpes.fr)
42  */

43 public class IIOPDummyClientInterceptor extends LocalObject JavaDoc implements ClientRequestInterceptor JavaDoc {
44
45     /**
46      * Server dummy context id
47      */

48     //private static final int SERVER_CTX_ID = 50;
49

50     /**
51      * Client dummy context id
52      */

53     private static final int CLIENT_CTX_ID = 51;
54
55     /**
56      * interceptor name
57      */

58     private String JavaDoc interceptorName = null;
59
60     /**
61      * constructor
62      * @param name of the interceptor
63      */

64     public IIOPDummyClientInterceptor(String JavaDoc name) {
65         interceptorName = name;
66     }
67
68     /**
69      * get the name of this interceptor
70      * @return name of this interceptor
71      */

72     public String JavaDoc name() {
73         return interceptorName;
74     }
75
76     /**
77      * Destroy interceptor
78      */

79     public void destroy() {
80     }
81
82     /**
83      * send client context with the request. The sendingRequest method of the
84      * JPortableInterceptors is called prior to marshalling arguments and
85      * contexts
86      * @param jri the jrmp client info
87      * @exception ForwardRequest if an exception occur with the ObjectOutput
88      */

89     public void send_request(ClientRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
90         try {
91             byte[] data = java.net.InetAddress.getLocalHost().getHostName().getBytes();
92             TraceCarol.debugCarol("Add/Send Dummy Client Service Context");
93             jri.add_request_service_context(new ServiceContext JavaDoc(CLIENT_CTX_ID, data), true);
94         } catch (Exception JavaDoc e) {
95             TraceCarol.debugCarol("No service context");
96         }
97     }
98
99     /**
100      * Allows an Interceptor to query the information on a reply after it is
101      * returned from the server and before control is returned to the client.
102      * @param jri the jrmp client info
103      */

104     public void receive_reply(ClientRequestInfo JavaDoc jri) {
105         TraceCarol.debugCarol("Get/Receive Dummy Server Service Context:");
106         //System.out.println(new String
107
// (((ServiceContext)jri.get_reply_service_context(SERVER_CTX_ID)).context_data));
108

109     }
110
111     /**
112      * Allows an Interceptor to query information during a Time-Independent
113      * Invocation (TII) polling get reply sequence.
114      * @param jri Information about the current request being intercepted.
115      */

116     public void send_poll(ClientRequestInfo JavaDoc jri) {
117     }
118
119     /**
120      * Indicates to the interceptor that an exception occurred. Allows an
121      * Interceptor to query the exception's information before it is thrown to
122      * the client.
123      * @param jri Information about the current request being intercepted.
124      * @exception ForwardRequest If thrown, indicates to the ORB that a retry of
125      * the request should occur with the new object given in the
126      * exception.
127      */

128     public void receive_exception(ClientRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
129     }
130
131     /**
132      * Allows an Interceptor to query the information available when a request
133      * results in something other than a normal reply or an exception.
134      * @param jri Information about the current request being intercepted.
135      * @exception ForwardRequest If thrown, indicates to the ORB that a retry of
136      * the request should occur with the new object given in the
137      * exception.
138      */

139     public void receive_other(ClientRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
140     }
141 }
Popular Tags