OSDN Git Service

Merged gcj-eclipse branch to trunk.
[pf3gnuchains/gcc-fork.git] / libjava / classpath / tools / gnu / classpath / tools / rmiregistry / RegistryImpl_Stub.java
1 /* RegistryImpl_Stub.java -- Registry stub.
2    Copyright (c) 2006 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10  
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library.  Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module.  An independent module is a module which is not derived from
33 or based on this library.  If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so.  If you do not wish to do so, delete this
36 exception statement from your version. */
37
38 package gnu.classpath.tools.rmiregistry;
39
40 import java.rmi.AccessException;
41 import java.rmi.AlreadyBoundException;
42 import java.rmi.NotBoundException;
43 import java.rmi.Remote;
44 import java.rmi.RemoteException;
45 import java.rmi.registry.Registry;
46
47 import java.lang.reflect.Method;
48 import java.rmi.server.RemoteRef;
49 import java.rmi.server.RemoteStub;
50 import java.rmi.UnexpectedException;
51
52 /**
53  * This class delegates its method calls to the remote RMI object, referenced
54  * by {@link RemoteRef}. 
55  *
56  * It is normally generated with rmic.
57  */
58 public final class RegistryImpl_Stub 
59     extends RemoteStub
60     implements Registry
61 {
62     /**
63      * Use serialVersionUID for interoperability 
64      */
65     private static final long serialVersionUID = 3;
66     
67     /**
68      * The explaining message for {@ling UnexpectedException}.
69      */
70     private static final String exception_message = 
71       "undeclared checked exception";
72
73      /* All remote methods, invoked by this stub: */
74     private static final Method met_list;
75     private static final Method met_rebind;
76     private static final Method met_unbind;
77     private static final Method met_lookup;
78     private static final Method met_bind;
79     private static final Object[] NO_ARGS = new Object[0];
80     static
81       {
82         final Class[]  NO_ARGSc = new Class[0];      
83         try 
84           {
85              met_list =
86                Registry.class.getMethod("list", NO_ARGSc);
87              met_rebind =
88                Registry.class.getMethod("rebind", new Class[]
89                  {
90                    String.class, Remote.class
91                  });
92              met_unbind =
93                Registry.class.getMethod("unbind", new Class[]
94                  {
95                    String.class
96                  });
97              met_lookup =
98                Registry.class.getMethod("lookup", new Class[]
99                  {
100                    String.class
101                  });
102              met_bind =
103                Registry.class.getMethod("bind", new Class[]
104                  {
105                    String.class, Remote.class
106                  });
107
108           }
109         catch (NoSuchMethodException nex)
110           {
111              NoSuchMethodError err = new NoSuchMethodError(
112                "RegistryImpl_Stub class initialization failed");
113              err.initCause(nex);
114              throw err;
115           }  
116       }
117     
118     /**
119      * Create the instance for _RegistryImpl_Stub that forwards method calls to the
120      * remote object.
121      *
122      * @para the reference to the remote object.
123      */
124     public RegistryImpl_Stub(RemoteRef reference) 
125     {
126        super(reference);
127     }    
128     
129     /* Methods */    
130   /** @inheritDoc */
131   public String [] list() 
132     throws RemoteException, AccessException
133   {
134     try
135       {
136         Object result =  ref.invoke(this, met_list,
137                    NO_ARGS,
138                    2571371476350237748L);
139         return (String []) result;           
140       }
141     catch (RuntimeException e)
142       {
143         throw e;
144       }
145     catch (RemoteException e)
146       {
147         throw e;
148       }
149     catch (Exception e)
150       {
151         UnexpectedException uex = new UnexpectedException(exception_message);
152         uex.detail = e;
153         throw uex;
154       }
155   }
156    
157   /** @inheritDoc */
158   public void rebind(String p0, Remote p1) 
159     throws RemoteException, AccessException
160   {
161     try
162       {
163         ref.invoke(this, met_rebind,
164           new Object[] {p0, p1},
165           -8381844669958460146L);
166       }
167     catch (RuntimeException e)
168       {
169         throw e;
170       }
171     catch (RemoteException e)
172       {
173         throw e;
174       }
175     catch (Exception e)
176       {
177         UnexpectedException uex = new UnexpectedException(exception_message);
178         uex.detail = e;
179         throw uex;
180       }
181   }
182    
183   /** @inheritDoc */
184   public void unbind(String p0) 
185     throws RemoteException, NotBoundException, AccessException
186   {
187     try
188       {
189         ref.invoke(this, met_unbind,
190           new Object[] {p0},
191           7305022919901907578L);
192       }
193     catch (RuntimeException e)
194       {
195         throw e;
196       }
197     catch (RemoteException e)
198       {
199         throw e;
200       }
201     catch (Exception e)
202       {
203         UnexpectedException uex = new UnexpectedException(exception_message);
204         uex.detail = e;
205         throw uex;
206       }
207   }
208    
209   /** @inheritDoc */
210   public Remote lookup(String p0) 
211     throws RemoteException, NotBoundException, AccessException
212   {
213     try
214       {
215         Object result =  ref.invoke(this, met_lookup,
216                    new Object[] {p0},
217                    -7538657168040752697L);
218         return (Remote) result;           
219       }
220     catch (RuntimeException e)
221       {
222         throw e;
223       }
224     catch (RemoteException e)
225       {
226         throw e;
227       }
228     catch (Exception e)
229       {
230         UnexpectedException uex = new UnexpectedException(exception_message);
231         uex.detail = e;
232         throw uex;
233       }
234   }
235    
236   /** @inheritDoc */
237   public void bind(String p0, Remote p1) 
238     throws RemoteException, AlreadyBoundException, AccessException
239   {
240     try
241       {
242         ref.invoke(this, met_bind,
243           new Object[] {p0, p1},
244           7583982177005850366L);
245       }
246     catch (RuntimeException e)
247       {
248         throw e;
249       }
250     catch (RemoteException e)
251       {
252         throw e;
253       }
254     catch (Exception e)
255       {
256         UnexpectedException uex = new UnexpectedException(exception_message);
257         uex.detail = e;
258         throw uex;
259       }
260   }
261    
262     
263 }