KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > cmi > UnicastRemoteObject


1 /*
2  * Copyright (C) 2002-2003, Simon Nieuviarts
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA
18  */

19 package org.objectweb.carol.cmi;
20
21 import java.rmi.NoSuchObjectException JavaDoc;
22 import java.rmi.Remote JavaDoc;
23 import java.rmi.RemoteException JavaDoc;
24
25 /**
26  * To export objects in the cluster.
27  */

28 public class UnicastRemoteObject implements Remote JavaDoc {
29     protected UnicastRemoteObject() throws RemoteException JavaDoc {
30         exportObject((Remote JavaDoc)this);
31     }
32
33     public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
34         throw new CloneNotSupportedException JavaDoc("Not implemented");
35     }
36
37     /*
38         private static ClusterSkel putObject(Remote obj) throws RemoteException {
39             WeakRef wr = new WeakRef(obj, rQueue);
40             boolean start = false;
41             ClusterSkel cs;
42             synchronized (exports) {
43                 cs = (ClusterSkel)exports.get(wr);
44                 if (cs == null) {
45                     cs = new ClusterSkel(obj);
46                     exports.put(wr, cs);
47                     if (rQueueFlush == null) {
48                         rQueueFlush = new RefQueueFlush();
49                         start = true;
50                     }
51                 }
52             }
53             if (start) rQueueFlush.start();
54             return cs;
55         }
56     */

57
58     public static void exportObject(Remote JavaDoc obj)
59         throws RemoteException JavaDoc {
60         /*
61                 if (obj instanceof UnicastRemoteObject) {
62                     ClusterSkel cs = putObject(obj);
63                 LowerOrb.exportObject(cs, port);
64                 return cs; // XXX Should return the stub
65             } else
66                 throw new RemoteException("no support for servers which do not extend " + UnicastRemoteObject.class.getClass().getName());
67         */

68         // DistributedExports.exportObject(obj);
69
LowerOrb.exportObject(obj);
70     }
71
72     public static void unexportObject(Remote JavaDoc obj)
73         throws NoSuchObjectException JavaDoc {
74         /*
75             ClusterSkel cs = (ClusterSkel)exports.get(obj);
76             if (cs == null)
77                 throw new NoSuchObjectException("Object not exported");
78             return LowerOrb.unexportObject(cs, force);
79         */

80         // DistributedExports.unexportObject(obj);
81
LowerOrb.unexportObject(obj);
82     }
83 }
84
Popular Tags