KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > rmi > jrmp > server > JRemoteCall


1 /**
2  * Copyright (C) 2002,2004 - 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: JRemoteCall.java,v 1.7 2004/09/01 11:02:41 benoitf Exp $
26  * --------------------------------------------------------------------------
27  */

28 package org.objectweb.carol.rmi.jrmp.server;
29
30 //java import
31
import java.io.ObjectInput JavaDoc;
32 import java.rmi.RemoteException JavaDoc;
33 import java.rmi.UnmarshalException JavaDoc;
34 import java.rmi.server.ObjID JavaDoc;
35
36 import org.objectweb.carol.rmi.jrmp.interceptor.JClientInterceptorHelper;
37 import org.objectweb.carol.rmi.jrmp.interceptor.JClientRequestInterceptor;
38
39 import sun.rmi.transport.Connection;
40 import sun.rmi.transport.StreamRemoteCall;
41
42 /**
43  * Class <code>JRemoteCall</code> is the CAROL JRMP Remote call with context
44  * propagation
45  * @author Guillaume Riviere (Guillaume.Riviere@inrialpes.fr)
46  * @version 1.0, 15/07/2002
47  */

48 public class JRemoteCall extends StreamRemoteCall {
49
50     /**
51      * Client Interceptor for context propagation
52      */

53     protected JClientRequestInterceptor[] cis = null;
54
55     /**
56      * Constructor for client side call
57      * @param c The connection
58      * @param id the object id
59      * @param hash the hash code
60      * @param cis the client interceptors array
61      */

62     public JRemoteCall(Connection c, ObjID JavaDoc id, int op, long hash, JClientRequestInterceptor[] cis)
63             throws RemoteException JavaDoc {
64         super(c, id, op, hash);
65         this.cis = cis;
66     }
67
68     /**
69      * override executeCall to receive and reassociate contexts that were sent
70      * back from the server in the case of exeptional return
71      * @deprecated
72      */

73     public void executeCall() throws Exception JavaDoc {
74         try {
75             super.executeCall();
76         } catch (Exception JavaDoc e) {
77             // if it is our dummy exception read the real one
78
if (e.getMessage().equals("dummy")) {
79                 ObjectInput JavaDoc in = getInputStream();
80                 JClientInterceptorHelper.receive_exception(in, cis);
81                 Object JavaDoc ex;
82                 try {
83                     ex = in.readObject();
84                 } catch (Exception JavaDoc exc) {
85                     throw new UnmarshalException JavaDoc("Error unmarshaling return", exc);
86                 }
87                 if (ex instanceof Exception JavaDoc) {
88                     // this throw an exception
89
exceptionReceivedFromServer((Exception JavaDoc) ex);
90                 } else {
91                     throw new UnmarshalException JavaDoc("Return type not Exception");
92                 }
93             } else {
94                 // There is no other receive context propagation
95
// The other case is generaly a network problem, so there is
96
// no context propagation inside from the server
97
throw e;
98             }
99         }
100         ObjectInput JavaDoc in = getInputStream();
101         JClientInterceptorHelper.receive_reply(in, cis);
102     }
103 }
Popular Tags