1 /*
   2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package org.omg.CORBA;
  27 import org.omg.CORBA.portable.*;
  28 
  29 
  30 /**
  31  * <P>Used as a base class for implementation of a local IDL interface in the
  32  * Java language mapping.  It is a class which implements all the operations
  33  * in the <tt>org.omg.CORBA.Object</tt> interface.
  34  * <P>Local interfaces are implemented by using CORBA::LocalObject
  35  *  to provide implementations of <code>Object</code> pseudo
  36  *  operations and any other ORB-specific support mechanisms that are
  37  *  appropriate for such objects.  Object implementation techniques are
  38  *  inherently language-mapping specific.  Therefore, the
  39  *  <code>LocalObject</code> type is not defined in IDL, but is specified
  40  *  in each language mapping.
  41  *  <P>Methods that do not apply to local objects throw
  42  *  an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with the message,
  43  *  "This is a locally contrained object."  Attempting to use a
  44  *  <TT>LocalObject</TT> to create a DII request results in NO_IMPLEMENT
  45  *  system exception.  Attempting to marshal or stringify a
  46  *  <TT>LocalObject</TT> results in a MARSHAL system exception.  Narrowing
  47  *  and widening references to <TT>LocalObjects</TT> must work as for regular
  48  *  object references.
  49  *  <P><code>LocalObject</code> is to be used as the base class of locally
  50  *  constrained objects, such as those in the PortableServer module.
  51  *  The specification here is based on the CORBA Components
  52  *  Volume I - orbos/99-07-01<P>
  53  * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
  54      *      comments for unimplemented features</a>
  55  */
  56 
  57 public class LocalObject implements org.omg.CORBA.Object
  58 {
  59     private static String reason = "This is a locally constrained object.";
  60 
  61     /**
  62      * Constructs a default <code>LocalObject</code> instance.
  63      */
  64     public LocalObject() {}
  65 
  66     /**
  67      * <P>Determines whether the two object references are equivalent,
  68      * so far as the ORB can easily determine. Two object references are equivalent
  69      * if they are identical. Two distinct object references which in fact refer to
  70      * the same object are also equivalent. However, ORBs are not required
  71      * to attempt determination of whether two distinct object references
  72      * refer to the same object, since such determination could be impractically
  73      * expensive.
  74      * <P>Default implementation of the org.omg.CORBA.Object method.
  75      *
  76      * @param that the object reference with which to check for equivalence
  77      * @return <code>true</code> if this object reference is known to be
  78      *         equivalent to the given object reference.
  79      *         Note that <code>false</code> indicates only that the two
  80      *         object references are distinct, not necessarily that
  81      *         they reference distinct objects.
  82      */
  83     public boolean _is_equivalent(org.omg.CORBA.Object that) {
  84         return equals(that) ;
  85     }
  86 
  87     /**
  88      * Always returns <code>false</code>.
  89      * This method is the default implementation of the
  90      * <code>org.omg.CORBA.Object</code> method.
  91      *
  92      * @return <code>false</code>
  93      */
  94     public boolean _non_existent() {
  95         return false;
  96     }
  97 
  98     /**
  99      * Returns a hash value that is consistent for the
 100      * lifetime of the object, using the given number as the maximum.
 101      * This method is the default implementation of the
 102      * <code>org.omg.CORBA.Object</code> method.
 103      *
 104      * @param maximum an <code>int</code> identifying maximum value of
 105      *                the hashcode
 106      * @return this instance's hashcode
 107      */
 108     public int _hash(int maximum) {
 109         return hashCode() ;
 110     }
 111 
 112     /**
 113      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 114      * the message "This is a locally constrained object."  This method
 115      * does not apply to local objects and is therefore not implemented.
 116      * This method is the default implementation of the
 117      * <code>org.omg.CORBA.Object</code> method.
 118      *
 119      * @param repository_id a <code>String</code>
 120      * @return NO_IMPLEMENT because this is a locally constrained object
 121      *      and this method does not apply to local objects
 122      * @exception NO_IMPLEMENT because this is a locally constrained object
 123      *      and this method does not apply to local objects
 124      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 125      *      comments for unimplemented features</a>
 126      */
 127     public boolean _is_a(String repository_id) {
 128         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 129     }
 130 
 131     /**
 132      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 133      * the message "This is a locally constrained object."
 134      * This method is the default implementation of the
 135      * <code>org.omg.CORBA.Object</code> method.
 136      *
 137      * @return a duplicate of this <code>LocalObject</code> instance.
 138      * @exception NO_IMPLEMENT
 139      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 140      *      comments for unimplemented features</a>
 141      */
 142     public org.omg.CORBA.Object _duplicate() {
 143         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 144     }
 145 
 146     /**
 147      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 148      * the message "This is a locally constrained object."
 149      * This method is the default implementation of the
 150      * <code>org.omg.CORBA.Object</code> method.
 151      *
 152      * @exception NO_IMPLEMENT
 153      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 154      *      comments for unimplemented features</a>
 155      */
 156     public void _release() {
 157         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 158     }
 159 
 160     /**
 161      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 162      * the message "This is a locally constrained object."
 163      * This method is the default implementation of the
 164      * <code>org.omg.CORBA.Object</code> method.
 165      *
 166      * @param operation a <code>String</code> giving the name of an operation
 167      *        to be performed by the request that is returned
 168      * @return a <code>Request</code> object with the given operation
 169      * @exception NO_IMPLEMENT
 170      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 171      *      comments for unimplemented features</a>
 172      */
 173     public Request _request(String operation) {
 174         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 175     }
 176 
 177     /**
 178      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 179      * the message "This is a locally constrained object."
 180      * This method is the default implementation of the
 181      * <code>org.omg.CORBA.Object</code> method.
 182      *
 183      * @param ctx          a <code>Context</code> object containing
 184      *                     a list of properties
 185      * @param operation    the <code>String</code> representing the name of the
 186      *                     method to be invoked
 187      * @param arg_list     an <code>NVList</code> containing the actual arguments
 188      *                     to the method being invoked
 189      * @param result       a <code>NamedValue</code> object to serve as a
 190      *                     container for the method's return value
 191      * @return a new <code>Request</code> object initialized with the given
 192      * arguments
 193      * @exception NO_IMPLEMENT
 194      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 195      *      comments for unimplemented features</a>
 196      */
 197     public Request _create_request(Context ctx,
 198                                    String operation,
 199                                    NVList arg_list,
 200                                    NamedValue result) {
 201         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 202     }
 203 
 204     /**
 205      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 206      * the message "This is a locally constrained object."
 207      * This method is the default implementation of the
 208      * <code>org.omg.CORBA.Object</code> method.
 209      *
 210      * @param ctx          a <code>Context</code> object containing
 211      *                     a list of properties
 212      * @param operation    the name of the method to be invoked
 213      * @param arg_list     an <code>NVList</code> containing the actual arguments
 214      *                     to the method being invoked
 215      * @param result       a <code>NamedValue</code> object to serve as a
 216      *                     container for the method's return value
 217      * @param exceptions   an <code>ExceptionList</code> object containing a
 218      *                     list of possible exceptions the method can throw
 219      * @param contexts     a <code>ContextList</code> object containing a list of
 220      *                     context strings that need to be resolved and sent
 221      *                     with the
 222      *                     <code>Request</code> instance
 223      * @return the new <code>Request</code> object initialized with the given
 224      * arguments
 225      * @exception NO_IMPLEMENT
 226      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 227      *      comments for unimplemented features</a>
 228      */
 229     public Request _create_request(Context ctx,
 230                                    String operation,
 231                                    NVList arg_list,
 232                                    NamedValue result,
 233                                    ExceptionList exceptions,
 234                                    ContextList contexts) {
 235         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 236     }
 237 
 238     /**
 239      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 240      * the message "This is a locally constrained object." This method
 241      * does not apply to local objects and is therefore not implemented.
 242      * This method is the default implementation of the
 243      * <code>org.omg.CORBA.Object</code> method.
 244      *
 245      * @return NO_IMPLEMENT because this is a locally constrained object
 246      *      and this method does not apply to local objects
 247      * @exception NO_IMPLEMENT because this is a locally constrained object
 248      *      and this method does not apply to local objects
 249      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 250      *      comments for unimplemented features</a>
 251      */
 252     public org.omg.CORBA.Object _get_interface()
 253     {
 254         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 255     }
 256 
 257     /**
 258      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 259      * the message "This is a locally constrained object."
 260      * This method is the default implementation of the
 261      * <code>org.omg.CORBA.Object</code> method.
 262      *
 263      * @exception NO_IMPLEMENT
 264      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 265      *      comments for unimplemented features</a>
 266      */
 267     public org.omg.CORBA.Object _get_interface_def()
 268     {
 269         // First try to call the delegate implementation class's
 270         // "Object get_interface_def(..)" method (will work for JDK1.2
 271         // ORBs).
 272         // Else call the delegate implementation class's
 273         // "InterfaceDef get_interface(..)" method using reflection
 274         // (will work for pre-JDK1.2 ORBs).
 275 
 276         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 277     }
 278 
 279     /**
 280      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 281      * the message "This is a locally constrained object."
 282      * This method is the default implementation of the
 283      * <code>org.omg.CORBA.Object</code> method.
 284      * @return the ORB instance that created the Delegate contained in this
 285      * <code>ObjectImpl</code>
 286      * @exception NO_IMPLEMENT
 287      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 288      *      comments for unimplemented features</a>
 289      */
 290     public org.omg.CORBA.ORB _orb() {
 291         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 292     }
 293 
 294     /**
 295      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 296      * the message "This is a locally constrained object." This method
 297      * does not apply to local objects and is therefore not implemented.
 298      * This method is the default implementation of the
 299      * <code>org.omg.CORBA.Object</code> method.
 300      *
 301      * @param policy_type  an <code>int</code>
 302      * @return NO_IMPLEMENT because this is a locally constrained object
 303      *      and this method does not apply to local objects
 304      * @exception NO_IMPLEMENT because this is a locally constrained object
 305      *      and this method does not apply to local objects
 306      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 307      *      comments for unimplemented features</a>
 308      */
 309     public org.omg.CORBA.Policy _get_policy(int policy_type) {
 310         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 311     }
 312 
 313 
 314     /**
 315      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 316      * the message "This is a locally constrained object." This method
 317      * does not apply to local objects and is therefore not implemented.
 318      * This method is the default implementation of the
 319      * <code>org.omg.CORBA.Object</code> method.
 320      *
 321      * @exception NO_IMPLEMENT
 322      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 323      *      comments for unimplemented features</a>
 324      */
 325     public org.omg.CORBA.DomainManager[] _get_domain_managers() {
 326         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 327     }
 328 
 329     /**
 330      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 331      * the message "This is a locally constrained object." This method
 332      * does not apply to local objects and is therefore not implemented.
 333      * This method is the default implementation of the
 334      * <code>org.omg.CORBA.Object</code> method.
 335      *
 336      * @param policies an array
 337      * @param set_add a flag
 338      * @return NO_IMPLEMENT because this is a locally constrained object
 339      *      and this method does not apply to local objects
 340      * @exception NO_IMPLEMENT because this is a locally constrained object
 341      *      and this method does not apply to local objects
 342      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 343      *      comments for unimplemented features</a>
 344      */
 345     public org.omg.CORBA.Object
 346         _set_policy_override(org.omg.CORBA.Policy[] policies,
 347                              org.omg.CORBA.SetOverrideType set_add) {
 348         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 349     }
 350 
 351 
 352     /**
 353      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 354      * the message "This is a locally constrained object."
 355      * This method is the default implementation of the
 356      * <code>org.omg.CORBA.Object</code> method.<P>
 357      * Returns <code>true</code> for this <code>LocalObject</code> instance.
 358      *
 359      * @return <code>true</code> always
 360      * @exception NO_IMPLEMENT
 361      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 362      *      comments for unimplemented features</a>
 363      */
 364     public boolean _is_local() {
 365         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 366     }
 367 
 368     /**
 369      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 370      * the message "This is a locally constrained object."
 371      * This method is the default implementation of the
 372      * <code>org.omg.CORBA.Object</code> method.
 373      *
 374      * @param operation a <code>String</code> indicating which operation
 375      *                  to preinvoke
 376      * @param expectedType the class of the type of operation mentioned above
 377      * @return NO_IMPLEMENT because this is a locally constrained object
 378      *      and this method does not apply to local objects
 379      * @exception NO_IMPLEMENT because this is a locally constrained object
 380      *      and this method does not apply to local object
 381      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 382      *      comments for unimplemented features</a>
 383      */
 384     public ServantObject _servant_preinvoke(String operation,
 385                                             Class expectedType) {
 386         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 387     }
 388 
 389     /**
 390      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 391      * the message "This is a locally constrained object."
 392      * This method is the default implementation of the
 393      * <code>org.omg.CORBA.Object</code> method.
 394      *
 395      * @param servant the servant object on which to post-invoke
 396      * @exception NO_IMPLEMENT
 397      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 398      *      comments for unimplemented features</a>
 399      */
 400     public void _servant_postinvoke(ServantObject servant) {
 401         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 402     }
 403 
 404     /*
 405      * The following methods were added by orbos/98-04-03: Java to IDL
 406      * Mapping. These are used by RMI over IIOP.
 407      */
 408 
 409     /**
 410      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 411      * the message "This is a locally constrained object."
 412      * This method is the default implementation of the
 413      * <code>org.omg.CORBA.Object</code> method.
 414      * <P>Called by a stub to obtain an OutputStream for
 415      * marshaling arguments. The stub must supply the operation name,
 416      * and indicate if a response is expected (i.e is this a oneway call).
 417      *
 418      * @param operation the name of the operation being requested
 419      * @param responseExpected <code>true</code> if a response is expected,
 420      *                         <code>false</code> if it is a one-way call
 421      * @return NO_IMPLEMENT because this is a locally constrained object
 422      *      and this method does not apply to local objects
 423      * @exception NO_IMPLEMENT because this is a locally constrained object
 424      *      and this method does not apply to local objects
 425      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 426      *      comments for unimplemented features</a>
 427      */
 428     public OutputStream _request(String operation,
 429                                  boolean responseExpected) {
 430         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 431     }
 432 
 433     /**
 434      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 435      * the message "This is a locally constrained object."
 436      * This method is the default implementation of the
 437      * <code>org.omg.CORBA.Object</code> method.
 438      * <P>Called to invoke an operation. The stub provides an
 439      * <code>OutputStream</code> that was previously returned by a
 440      * <code>_request()</code>
 441      * call. <code>_invoke</code> returns an <code>InputStream</code> which
 442      * contains the
 443      * marshaled reply. If an exception occurs, <code>_invoke</code> may throw an
 444      * <code>ApplicationException</code> object which contains an
 445      * <code>InputStream</code> from
 446      * which the user exception state may be unmarshaled.
 447      *
 448      * @param output the <code>OutputStream</code> to invoke
 449      * @return NO_IMPLEMENT because this is a locally constrained object
 450      *      and this method does not apply to local objects
 451      * @throws ApplicationException If an exception occurs,
 452      * <code>_invoke</code> may throw an
 453      * <code>ApplicationException</code> object which contains
 454      * an <code>InputStream</code> from
 455      * which the user exception state may be unmarshaled.
 456      * @throws RemarshalException If an exception occurs,
 457      * <code>_invoke</code> may throw an
 458      * <code>ApplicationException</code> object which contains
 459      * an <code>InputStream</code> from
 460      * which the user exception state may be unmarshaled.
 461      * @exception NO_IMPLEMENT because this is a locally constrained object
 462      *      and this method does not apply to local objects
 463      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 464      *      comments for unimplemented features</a>
 465      */
 466     public InputStream _invoke(OutputStream output)
 467         throws ApplicationException, RemarshalException
 468     {
 469         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 470     }
 471 
 472     /**
 473      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 474      * the message "This is a locally constrained object."
 475      * This method is the default implementation of the
 476      * <code>org.omg.CORBA.Object</code> method.
 477      * <P>May optionally be called by a stub to release a
 478      * reply stream back to the ORB when the unmarshaling has
 479      * completed. The stub passes the <code>InputStream</code> returned by
 480      * <code>_invoke()</code> or
 481      * <code>ApplicationException.getInputStream()</code>.
 482      * A null
 483      * value may also be passed to <code>_releaseReply</code>, in which case the
 484      * method is a no-op.
 485      *
 486      * @param input the reply stream back to the ORB or null
 487      * @exception NO_IMPLEMENT
 488      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 489      *      comments for unimplemented features</a>
 490      */
 491     public void _releaseReply(InputStream input) {
 492         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 493     }
 494 
 495     /**
 496      * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
 497      * the message "This is a locally constrained object." This method
 498      * does not apply to local objects and is therefore not implemented.
 499      * This method is the default implementation of the
 500      * <code>org.omg.CORBA.Object</code> method.
 501      *
 502      * @return NO_IMPLEMENT because this is a locally constrained object
 503      *      and this method does not apply to local objects
 504      * @exception NO_IMPLEMENT because this is a locally constrained object
 505      *      and this method does not apply to local objects
 506      * @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
 507      *      comments for unimplemented features</a>
 508      */
 509 
 510     public boolean validate_connection() {
 511         throw new org.omg.CORBA.NO_IMPLEMENT(reason);
 512     }
 513 }