< prev index next >

src/java.corba/share/classes/javax/rmi/CORBA/Util.java

Print this page




  91 
  92         if (utilDelegate != null) {
  93             utilDelegate.writeAny(out, obj);
  94         }
  95     }
  96 
  97     /**
  98      * Reads a java.lang.Object as a CORBA any.
  99      * @param in the stream from which to read the any.
 100      * @return the object read from the stream.
 101      */
 102     public static Object readAny(InputStream in) {
 103 
 104         if (utilDelegate != null) {
 105             return utilDelegate.readAny(in);
 106         }
 107         return null;
 108     }
 109 
 110     /**
 111      * Writes a java.lang.Object as a CORBA Object. If <code>obj</code> is
 112      * an exported RMI-IIOP server object, the tie is found
 113      * and wired to <code>obj</code>, then written to
 114 <code>out.write_Object(org.omg.CORBA.Object)</code>.
 115      * If <code>obj</code> is a CORBA Object, it is written to
 116      * <code>out.write_Object(org.omg.CORBA.Object)</code>.
 117      * @param out the stream in which to write the object.
 118      * @param obj the object to write.
 119      */
 120     public static void writeRemoteObject(OutputStream out,
 121                                          java.lang.Object obj) {
 122 
 123         if (utilDelegate != null) {
 124             utilDelegate.writeRemoteObject(out, obj);
 125         }
 126 
 127     }
 128 
 129     /**
 130      * Writes a java.lang.Object as either a value or a CORBA Object.
 131      * If <code>obj</code> is a value object or a stub object, it is written to
 132      * <code>out.write_abstract_interface(java.lang.Object)</code>. If <code>obj</code>
 133 is
 134 an exported
 135      * RMI-IIOP server object, the tie is found and wired to <code>obj</code>,
 136      * then written to <code>out.write_abstract_interface(java.lang.Object)</code>.
 137      * @param out the stream in which to write the object.
 138      * @param obj the object to write.
 139      */
 140     public static void writeAbstractObject(OutputStream out,
 141                                            java.lang.Object obj) {
 142 
 143         if (utilDelegate != null) {
 144             utilDelegate.writeAbstractObject(out, obj);
 145         }
 146     }
 147 
 148     /**
 149      * Registers a target for a tie. Adds the tie to an internal table and calls
 150      * {@link Tie#setTarget} on the tie object.
 151      * @param tie the tie to register.
 152      * @param target the target for the tie.
 153      */
 154     public static void registerTarget(javax.rmi.CORBA.Tie tie,
 155                                       java.rmi.Remote target) {
 156 
 157         if (utilDelegate != null) {
 158             utilDelegate.registerTarget(tie, target);
 159         }
 160 
 161     }
 162 
 163     /**
 164      * Removes the associated tie from an internal table and calls {@link
 165 Tie#deactivate}
 166      * to deactivate the object.
 167      * @param target the object to unexport.
 168      */
 169     public static void unexportObject(java.rmi.Remote target)
 170         throws java.rmi.NoSuchObjectException
 171     {
 172 
 173         if (utilDelegate != null) {
 174             utilDelegate.unexportObject(target);
 175         }
 176 
 177     }
 178 
 179     /**
 180      * Returns the tie (if any) for a given target object.
 181      * @return the tie or null if no tie is registered for the given target.
 182      */
 183     public static Tie getTie (Remote target) {
 184 
 185         if (utilDelegate != null) {


 202         return null;
 203     }
 204 
 205     /**
 206      * Returns the codebase, if any, for the given class.
 207      * @param clz the class to get a codebase for.
 208      * @return a space-separated list of URLs, or null.
 209      */
 210     public static String getCodebase(java.lang.Class clz) {
 211         if (utilDelegate != null) {
 212             return utilDelegate.getCodebase(clz);
 213         }
 214         return null;
 215     }
 216 
 217     /**
 218      * Returns a class instance for the specified class.
 219      * <P>The spec for this method is the "Java to IDL language
 220      * mapping", ptc/00-01-06.
 221      * <P>In Java SE Platform, this method works as follows:
 222      * <UL><LI>Find the first non-null <tt>ClassLoader</tt> on the
 223      * call stack and attempt to load the class using this
 224      * <tt>ClassLoader</tt>.
 225      * <LI>If the first step fails, and if <tt>remoteCodebase</tt>
 226      * is non-null and
 227      * <tt>useCodebaseOnly</tt> is false, then call
 228      * <tt>java.rmi.server.RMIClassLoader.loadClass(remoteCodebase, className)</tt>.
 229      * <LI>If <tt>remoteCodebase</tt> is null or <tt>useCodebaseOnly</tt>
 230      * is true, then call <tt>java.rmi.server.RMIClassLoader.loadClass(className)</tt>.
 231      * <LI>If a class was not successfully loaded by step 1, 2, or 3,
 232      * and <tt>loader</tt> is non-null, then call <tt>loader.loadClass(className)</tt>.
 233      * <LI>If a class was successfully loaded by step 1, 2, 3, or 4, then
 234      *  return the loaded class, else throw <tt>ClassNotFoundException</tt>.
 235      * </UL>
 236      *
 237      * @param className the name of the class.
 238      * @param remoteCodebase a space-separated list of URLs at which
 239      * the class might be found. May be null.
 240      * @param loader a <tt>ClassLoader</tt> that may be used to
 241      * load the class if all other methods fail.
 242      * @return the <code>Class</code> object representing the loaded class.
 243      * @exception ClassNotFoundException if class cannot be loaded.
 244      */
 245     public static Class loadClass(String className,
 246                                   String remoteCodebase,
 247                                   ClassLoader loader)
 248         throws ClassNotFoundException {
 249         if (utilDelegate != null) {
 250             return utilDelegate.loadClass(className,remoteCodebase,loader);
 251         }
 252         return null ;
 253     }
 254 
 255 
 256     /**
 257      * The <tt>isLocal</tt> method has the same semantics as the
 258      * <tt>ObjectImpl._is_local</tt>
 259      * method, except that it can throw a <tt>RemoteException</tt>.
 260      *
 261      * The <tt>_is_local()</tt> method is provided so that stubs may determine if a
 262      * particular object is implemented by a local servant and hence local
 263      * invocation APIs may be used.
 264      *
 265      * @param stub the stub to test.
 266      *
 267      * @return The <tt>_is_local()</tt> method returns true if
 268      * the servant incarnating the object is located in the same process as
 269      * the stub and they both share the same ORB instance.  The <tt>_is_local()</tt>
 270      * method returns false otherwise. The default behavior of <tt>_is_local()</tt> is
 271      * to return false.
 272      *
 273      * @throws RemoteException The Java to IDL specification does not
 274      * specify the conditions that cause a <tt>RemoteException</tt> to be thrown.
 275      */
 276     public static boolean isLocal(Stub stub) throws RemoteException {
 277 
 278         if (utilDelegate != null) {
 279             return utilDelegate.isLocal(stub);
 280         }
 281 
 282         return false;
 283     }
 284 
 285     /**
 286      * Wraps an exception thrown by an implementation
 287      * method.  It returns the corresponding client-side exception.
 288      * @param orig the exception to wrap.
 289      * @return the wrapped exception.
 290      */
 291     public static RemoteException wrapException(Throwable orig) {
 292 
 293         if (utilDelegate != null) {
 294             return utilDelegate.wrapException(orig);




  91 
  92         if (utilDelegate != null) {
  93             utilDelegate.writeAny(out, obj);
  94         }
  95     }
  96 
  97     /**
  98      * Reads a java.lang.Object as a CORBA any.
  99      * @param in the stream from which to read the any.
 100      * @return the object read from the stream.
 101      */
 102     public static Object readAny(InputStream in) {
 103 
 104         if (utilDelegate != null) {
 105             return utilDelegate.readAny(in);
 106         }
 107         return null;
 108     }
 109 
 110     /**
 111      * Writes a java.lang.Object as a CORBA Object. If {@code obj} is
 112      * an exported RMI-IIOP server object, the tie is found
 113      * and wired to {@code obj}, then written to
 114      * {@code out.write_Object(org.omg.CORBA.Object)}.
 115      * If {@code obj} is a CORBA Object, it is written to
 116      * {@code out.write_Object(org.omg.CORBA.Object)}.
 117      * @param out the stream in which to write the object.
 118      * @param obj the object to write.
 119      */
 120     public static void writeRemoteObject(OutputStream out,
 121                                          java.lang.Object obj) {
 122 
 123         if (utilDelegate != null) {
 124             utilDelegate.writeRemoteObject(out, obj);
 125         }
 126 
 127     }
 128 
 129     /**
 130      * Writes a java.lang.Object as either a value or a CORBA Object.
 131      * If {@code obj} is a value object or a stub object, it is written to
 132      * {@code out.write_abstract_interface(java.lang.Object)}.
 133      * If {@code obj} is an exported
 134      * RMI-IIOP server object, the tie is found and wired to {@code obj},
 135      * then written to {@code out.write_abstract_interface(java.lang.Object)}.

 136      * @param out the stream in which to write the object.
 137      * @param obj the object to write.
 138      */
 139     public static void writeAbstractObject(OutputStream out,
 140                                            java.lang.Object obj) {
 141 
 142         if (utilDelegate != null) {
 143             utilDelegate.writeAbstractObject(out, obj);
 144         }
 145     }
 146 
 147     /**
 148      * Registers a target for a tie. Adds the tie to an internal table and calls
 149      * {@link Tie#setTarget} on the tie object.
 150      * @param tie the tie to register.
 151      * @param target the target for the tie.
 152      */
 153     public static void registerTarget(javax.rmi.CORBA.Tie tie,
 154                                       java.rmi.Remote target) {
 155 
 156         if (utilDelegate != null) {
 157             utilDelegate.registerTarget(tie, target);
 158         }
 159 
 160     }
 161 
 162     /**
 163      * Removes the associated tie from an internal table
 164      * and calls {@link Tie#deactivate}
 165      * to deactivate the object.
 166      * @param target the object to unexport.
 167      */
 168     public static void unexportObject(java.rmi.Remote target)
 169         throws java.rmi.NoSuchObjectException
 170     {
 171 
 172         if (utilDelegate != null) {
 173             utilDelegate.unexportObject(target);
 174         }
 175 
 176     }
 177 
 178     /**
 179      * Returns the tie (if any) for a given target object.
 180      * @return the tie or null if no tie is registered for the given target.
 181      */
 182     public static Tie getTie (Remote target) {
 183 
 184         if (utilDelegate != null) {


 201         return null;
 202     }
 203 
 204     /**
 205      * Returns the codebase, if any, for the given class.
 206      * @param clz the class to get a codebase for.
 207      * @return a space-separated list of URLs, or null.
 208      */
 209     public static String getCodebase(java.lang.Class clz) {
 210         if (utilDelegate != null) {
 211             return utilDelegate.getCodebase(clz);
 212         }
 213         return null;
 214     }
 215 
 216     /**
 217      * Returns a class instance for the specified class.
 218      * <P>The spec for this method is the "Java to IDL language
 219      * mapping", ptc/00-01-06.
 220      * <P>In Java SE Platform, this method works as follows:
 221      * <UL><LI>Find the first non-null {@code ClassLoader} on the
 222      * call stack and attempt to load the class using this
 223      * {@code ClassLoader}.
 224      * <LI>If the first step fails, and if {@code remoteCodebase}
 225      * is non-null and
 226      * {@code useCodebaseOnly} is false, then call
 227      * {@code java.rmi.server.RMIClassLoader.loadClass(remoteCodebase, className)}.
 228      * <LI>If {@code remoteCodebase} is null or {@code useCodebaseOnly}
 229      * is true, then call {@code java.rmi.server.RMIClassLoader.loadClass(className)}.
 230      * <LI>If a class was not successfully loaded by step 1, 2, or 3,
 231      * and {@code loader} is non-null, then call {@code loader.loadClass(className)}.
 232      * <LI>If a class was successfully loaded by step 1, 2, 3, or 4, then
 233      *  return the loaded class, else throw {@code ClassNotFoundException}.
 234      * </UL>
 235      *
 236      * @param className the name of the class.
 237      * @param remoteCodebase a space-separated list of URLs at which
 238      * the class might be found. May be null.
 239      * @param loader a {@code ClassLoader} that may be used to
 240      * load the class if all other methods fail.
 241      * @return the {@code Class} object representing the loaded class.
 242      * @exception ClassNotFoundException if class cannot be loaded.
 243      */
 244     public static Class loadClass(String className,
 245                                   String remoteCodebase,
 246                                   ClassLoader loader)
 247         throws ClassNotFoundException {
 248         if (utilDelegate != null) {
 249             return utilDelegate.loadClass(className,remoteCodebase,loader);
 250         }
 251         return null ;
 252     }
 253 
 254 
 255     /**
 256      * The {@code isLocal} method has the same semantics as the
 257      * {@code ObjectImpl._is_local}
 258      * method, except that it can throw a {@code RemoteException}.
 259      *
 260      * The {@code _is_local()} method is provided so that stubs may determine if a
 261      * particular object is implemented by a local servant and hence local
 262      * invocation APIs may be used.
 263      *
 264      * @param stub the stub to test.
 265      *
 266      * @return The {@code _is_local()} method returns true if
 267      * the servant incarnating the object is located in the same process as
 268      * the stub and they both share the same ORB instance.  The {@code _is_local()}
 269      * method returns false otherwise. The default behavior of {@code _is_local()} is
 270      * to return false.
 271      *
 272      * @throws RemoteException The Java to IDL specification does not
 273      * specify the conditions that cause a {@code RemoteException} to be thrown.
 274      */
 275     public static boolean isLocal(Stub stub) throws RemoteException {
 276 
 277         if (utilDelegate != null) {
 278             return utilDelegate.isLocal(stub);
 279         }
 280 
 281         return false;
 282     }
 283 
 284     /**
 285      * Wraps an exception thrown by an implementation
 286      * method.  It returns the corresponding client-side exception.
 287      * @param orig the exception to wrap.
 288      * @return the wrapped exception.
 289      */
 290     public static RemoteException wrapException(Throwable orig) {
 291 
 292         if (utilDelegate != null) {
 293             return utilDelegate.wrapException(orig);


< prev index next >