KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > rmi > multi > CmiPRODelegate


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: CmiPRODelegate.java,v 1.3 2005/03/11 13:59:24 benoitf Exp $
26  * --------------------------------------------------------------------------
27  */

28 package org.objectweb.carol.rmi.multi;
29
30 import java.rmi.NoSuchObjectException JavaDoc;
31 import java.rmi.Remote JavaDoc;
32 import java.rmi.RemoteException JavaDoc;
33
34 import javax.rmi.CORBA.PortableRemoteObjectDelegate JavaDoc;
35
36 import org.objectweb.carol.cmi.LowerOrb;
37
38 /**
39  * Class <code>CmiPRODelegate</code> for the mapping between cmi
40  * UnicastRemoteObject and PortableRemoteObject
41  * @author Simon Nieuviarts
42  */

43 public class CmiPRODelegate implements PortableRemoteObjectDelegate JavaDoc {
44
45     /**
46      * ORB to export clustered objects.
47      */

48     private PortableRemoteObjectDelegate JavaDoc rmi;
49
50     /**
51      * Get the lower ORB delegate to export objects.
52      */

53     public CmiPRODelegate() {
54         rmi = LowerOrb.getPRODelegate();
55     }
56
57     /**
58      * Export a Remote Object
59      * @param obj Remote object to export
60      * @exception RemoteException exporting remote object problem
61      */

62     public void exportObject(Remote JavaDoc obj) throws RemoteException JavaDoc {
63         rmi.exportObject(obj);
64     }
65
66     /**
67      * Method for unexport object
68      * @param obj Remote obj object to unexport
69      * @exception NoSuchObjectException if the object is not currently exported
70      */

71     public void unexportObject(Remote JavaDoc obj) throws NoSuchObjectException JavaDoc {
72         rmi.unexportObject(obj);
73     }
74
75     /**
76      * Connection method
77      * @param target a remote object;
78      * @param source another remote object;
79      * @exception RemoteException if the connection fail
80      */

81     public void connect(Remote JavaDoc target, Remote JavaDoc source) throws RemoteException JavaDoc {
82         rmi.connect(target, source);
83     }
84
85     /**
86      * Narrow method
87      * @param obj Remote obj the object to narrow
88      * @param newClass Class newClass the expected type of the result
89      * @return an object of type newClass
90      * @exception ClassCastException if the obj class is not compatible with a
91      * newClass cast
92      */

93     public Object JavaDoc narrow(Object JavaDoc obj, Class JavaDoc newClass) throws ClassCastException JavaDoc {
94         return rmi.narrow(obj, newClass);
95     }
96
97     /**
98      * To stub method
99      * @return the stub object
100      * @param obj Remote object to unexport
101      * @exception NoSuchObjectException if the object is not currently exported
102      */

103     public Remote JavaDoc toStub(Remote JavaDoc obj) throws NoSuchObjectException JavaDoc {
104         return rmi.toStub(obj);
105     }
106 }
Popular Tags