KickJava   Java API By Example, From Geeks To Geeks.

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


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: IIOPDummyServerInterceptor.java,v 1.4 2005/02/08 10:03:48 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.ForwardRequest JavaDoc;
33 import org.omg.PortableInterceptor.ServerRequestInfo JavaDoc;
34 import org.omg.PortableInterceptor.ServerRequestInterceptor JavaDoc;
35
36 /**
37  * Class <code>IIOPDummyServerInterceptor</code> is a IIOP Dummy server
38  * interceptor for carol testing
39  * @author Guillaume Riviere (Guillaume.Riviere@inrialpes.fr)
40  */

41 public class IIOPDummyServerInterceptor extends LocalObject JavaDoc implements ServerRequestInterceptor JavaDoc {
42
43     /**
44      * Server dummy context id
45      */

46     private static int SERVER_CTX_ID = 50;
47
48     /**
49      * Client dummy context id
50      */

51     private static int CLIENT_CTX_ID = 51;
52
53     /**
54      * interceptor name
55      */

56     private String JavaDoc interceptorName = null;
57
58     /**
59      * constructor
60      * @param String name
61      */

62     public IIOPDummyServerInterceptor(String JavaDoc name) {
63         interceptorName = name;
64     }
65
66     /**
67      * Receive request context
68      * @param JServerRequestInfo the jrmp server request information
69      * @exception ForwardRequest if an exception occur with the ObjectOutput
70      */

71     public void receive_request_service_contexts(ServerRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
72         try {
73             //System.out.println("IIOPDummyServerInterceptor Get/Receive Dummy
74
// Client Service Context:");
75
//System.out.println(new
76
// String(((ServiceContext)jri.get_request_service_context(CLIENT_CTX_ID)).context_data));
77
} catch (Exception JavaDoc e) {
78             // no service context : do nothing
79
}
80     }
81
82     /**
83      * Receive request
84      * @param JServerRequestInfo the jrmp server request information
85      * @exception ForwardRequest if an exception occur with the ObjectOutput
86      */

87     public void receive_request(ServerRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
88     }
89
90     /**
91      * send reply with context
92      * @param JServerRequestInfo the jrmp server request information
93      */

94     public void send_reply(ServerRequestInfo JavaDoc jri) {
95         try {
96             byte[] data = java.net.InetAddress.getLocalHost().getHostName().getBytes();
97             //System.out.println("IIOPDummyServerInterceptor Add/Send Dummy
98
// Server Service Context");
99
jri.add_reply_service_context(new ServiceContext JavaDoc(SERVER_CTX_ID, data), true);
100         } catch (Exception JavaDoc e) {
101         }
102     }
103
104     /**
105      * get the name of this interceptor
106      * @return name
107      */

108     public String JavaDoc name() {
109         return interceptorName;
110     }
111
112     public void send_exception(ServerRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
113     }
114
115     public void send_other(ServerRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
116     }
117
118     public void destroy() {
119     }
120 }
Popular Tags