Source for org.omg.PortableServer.POAOperations

   1: /* POAOperations.java --
   2:    Copyright (C) 2005 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: 
  39: package org.omg.PortableServer;
  40: 
  41: import org.omg.CORBA.Policy;
  42: import org.omg.PortableServer.POAPackage.AdapterAlreadyExists;
  43: import org.omg.PortableServer.POAPackage.AdapterNonExistent;
  44: import org.omg.PortableServer.POAPackage.InvalidPolicy;
  45: import org.omg.PortableServer.POAPackage.NoServant;
  46: import org.omg.PortableServer.POAPackage.ObjectAlreadyActive;
  47: import org.omg.PortableServer.POAPackage.ObjectNotActive;
  48: import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
  49: import org.omg.PortableServer.POAPackage.ServantNotActive;
  50: import org.omg.PortableServer.POAPackage.WrongAdapter;
  51: import org.omg.PortableServer.POAPackage.WrongPolicy;
  52: 
  53: /**
  54:  * Defines the operations, applicable to the POA.
  55:  *
  56:  * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
  57:  */
  58: public interface POAOperations
  59: {
  60:   /**
  61:    * Creates a new POA as a child of the target POA.
  62:    *
  63:    * @param child_name the name of the child POA being created.
  64:    * @param manager the manager that will control the new POA. If this parameter
  65:    * is null, a new POA manager is created and associated with the new POA.
  66:    *
  67:    * @param policies the policies, applicable for the parent POA. Policies
  68:    * are <i>not</i> inherited from the parent POA. If some policy type
  69:    * is missing in the array (or the zero size array is passed), the missing
  70:    * policies obtain the default values from the table, specified
  71:    * in the {@link POA} documentation header.
  72:    *
  73:    * @return an newly created POA. The POA will be intially in the holding
  74:    * state and must be activated to start processing requests.
  75:    *
  76:    * @throws AdapterAlreadyExists if the child with the given child_name
  77:    * already exists for the current POA.
  78:    * @throws InvalidPolicy if the policies conflict with each other or are
  79:    * otherwise inappropriate.
  80:    *
  81:    * @see POA for the list of required policies.
  82:    * @see #the_children()
  83:    */
  84:   POA create_POA(String child_name, POAManager manager, Policy[] policies)
  85:           throws AdapterAlreadyExists, InvalidPolicy;
  86: 
  87:   /**
  88:   * Find and optionally activate the child POA with the given name.
  89:   *
  90:   * @param poa_name the name of the POA to find.
  91:   * @param activate_it if the child with the specified name is not found
  92:   * or inactive and this parameter is true, the target POA activator is
  93:   * invoked to activate that child. If this succeeds, that child POA
  94:   * is returned.
  95:   *
  96:   * @throws AdapterNonExistent if no active child with the given name
  97:   * is found and one of the following is true:
  98:   * a) the target POA has no associated
  99:   * {@link AdapterActivator}. b) that activator fails to activate the
 100:   * child POA. c) <code>activate_id</code> = false.
 101:   */
 102:   POA find_POA(String poa_name, boolean activate_it)
 103:         throws AdapterNonExistent;
 104: 
 105:   /**
 106:    * Generate the Object Id for the given servant and add the servant to
 107:    * the Active Object Map using this Id a a key. If the servant
 108:    * activator is set, its incarnate method will be called. In this case,
 109:    * the passed servant in this method can be null; in this case, the servant,
 110:    * returned by {@link ServantLocatorOperations#incarnate} will
 111:    * be used.
 112:    *
 113:    * @param a_servant a servant that would serve the object with the
 114:    * returned Object Id.
 115:    *
 116:    * @return the generated objert Id for the given servant.
 117:    *
 118:    * @throws ServantAlreadyActive if this servant is already in the
 119:    * Active Object Map and the UNIQUE_ID policy applies.
 120:    *
 121:    * @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN
 122:    * do not apply to this POA.
 123:    */
 124:   byte[] activate_object(Servant a_servant)
 125:                   throws ServantAlreadyActive, WrongPolicy;
 126: 
 127:   /**
 128:    * Add the given servant to the Active Object Map as a servant for the
 129:    * object with the provided Object Id. If the servant activator is
 130:    * set, its incarnate method will be called. In this case,
 131:    * the passed servant in this method can be null; in this case, the servant,
 132:    * returned by {@link ServantLocatorOperations#incarnate} will
 133:    * be used.
 134:    *
 135:    * @param an_Object_Id an object id for the given object.
 136:    * @param a_servant a servant that will serve the object with the given
 137:    * Object Id.
 138:    *
 139:    * @throws ObjectAlreadyActive if the given object id is already in the
 140:    * Active Object Map.
 141:    * @throws WrongPolicy if the required RETAIN policy does not apply to
 142:    * this POA.
 143:    * @throws BAD_PARAM if the passed object id is invalid due any reason.
 144:    */
 145:   void activate_object_with_id(byte[] an_Object_Id, Servant a_servant)
 146:                         throws ServantAlreadyActive, ObjectAlreadyActive,
 147:                                WrongPolicy;
 148: 
 149:   /**
 150:    * <p>Deactivate object with the given id. Client, trying to call
 151:    * method on the deactivated object will either receive the remote
 152:    * exception ({@link org.omg.CORBA.OBJECT_NOT_EXIST}, minor 0x535503ec),
 153:    * incomplete) or the object will be reactivated and serve the request.
 154:    * The object can be reactivated only if the implicit activation
 155:    * policy applies and the servant activator is set.</p><p>
 156:    * The deactivated object will continue to process requests that arrived
 157:    * before decativation.
 158:    * If this POA has the associated servant manager, a
 159:    * {@link ServantActivatorOperations#etherealize} is <i>immediately</i>
 160:    * invoked on the passed id. The deactivated object can be reactivated
 161:    * by {@link #activate_object_with_id}.</p>
 162:    * <p>The deactivation will not release thread, port or memory resources,
 163:    * taken by that object. This is due requirement to make the
 164:    * object reactivation possible at any time. To release the resources,
 165:    * you must destroy the POA.
 166:    * </p>
 167:    *
 168:    * @throws WrongPolicy if the required RETAIN policy does not apply to
 169:    * this POA.
 170:    */
 171:   void deactivate_object(byte[] the_Object_Id)
 172:                   throws ObjectNotActive, WrongPolicy;
 173: 
 174:   /**
 175:   * Create the object reference, encapsulating the given repository Id and
 176:   * the Object Id, generated by this POA. The returned object will not be
 177:   * activated by default and may be activated on the first invocation by
 178:   * the servant manager (if it is set and if policies are applicable).
 179:   * The returned object can also be narrowed by helper and used locally.
 180:   * In this case, the servant will be activated on the first local call of
 181:   * any method. The methods on returned object can also be invoked by
 182:   * name, using {@link org.omg.CORBA.Request}.
 183:   *
 184:   * @param a_repository_id the repository id for the given object. When
 185:   * narrowing the returned object with some helper, it will be checked for
 186:   * equality with value, returned by the the helper id().
 187:   *
 188:   * @throws WrongPolicy if the required SYSTEM_ID policy does not apply to
 189:   * this POA.
 190:   */
 191:   org.omg.CORBA.Object create_reference(String a_repository_id)
 192:                                  throws WrongPolicy;
 193: 
 194:   /**
 195:   * <p> Create the object reference, encapsulating the given repository Id and
 196:   * the given Object Id. The returned object will not be
 197:   * activated by default and may be activated on the first invocation by
 198:   * the servant manager (if it is set and if policies are applicable).
 199:   * </p><p>
 200:   * The returned object can also be narrowed by helper and used locally.
 201:   * In this case, the servant will be activated on the first local call of
 202:   * any method. The methods on returned object can also be invoked by
 203:   * name, using {@link org.omg.CORBA.Request}.
 204:   * </p>
 205:   *
 206:   * @param an_object_id the object id for the object being created.
 207:   * If the POA uses the SYSTEM_ID policy, the portable application
 208:   * must only supply ids, generated by that POA.
 209:   *
 210:   * @param a_repository_id the repository id for the given object. When
 211:   * narrowing the returned object with some helper, it will be checked for
 212:   * equality with value, returned by the the helper id().
 213:   */
 214:   org.omg.CORBA.Object create_reference_with_id(byte[] an_object_id,
 215:                                                 String a_repository_id
 216:                                                );
 217: 
 218:   /**
 219:    * Returns a default servant for this POA.
 220:    *
 221:    * @return a servant that will be used for requests for
 222:    * which no servant is found in the Active Object Map.
 223:    *
 224:    * @throws NoServant if there is no default servant associated with this POA.
 225:    * @throws WrongPolicy if the USE_DEFAULT_SERVANT policy is not active.
 226:    */
 227:   Servant get_servant()
 228:                throws NoServant, WrongPolicy;
 229: 
 230:   /**
 231:    * Sets the default servant for this POA.
 232:    *
 233:    * @param a_servant a servant that will be used for requests for
 234:    * which no servant is found in the Active Object Map.
 235:    *
 236:    * @throws WrongPolicy if the USE_DEFAULT_SERVANT policy is not active.
 237:    */
 238:   void set_servant(Servant a_servant)
 239:             throws WrongPolicy;
 240: 
 241:   /**
 242:    * Set a servant manager for this POA.
 243:    *
 244:    * @param a servant manager being set. If the RETAIN policy applies, the
 245:    * manager must implement a {@link ServantActivator}. If the NON_RETAIN
 246:    * policy applies, the manager must implement a {@link ServantLocator}.
 247:    *
 248:    * @throws WrongPolicy if the required USE_SERVANT_MANAGER policy does not
 249:    * apply to this POA.
 250:    *
 251:    * @throws OBJ_ADAPTER minor code 4 if the passed manager does not
 252:    * implement the required interface ({@link ServantActivator},
 253:    * {@link ServantLocator}).
 254:    *
 255:    * @throws BAD_INV_ORDER minor code 6 if the method is called more than once
 256:    * on the same POA. The manager can be set only once.
 257:    */
 258:   void set_servant_manager(ServantManager a_manager)
 259:                     throws WrongPolicy;
 260: 
 261:   /**
 262:    * Get the servant manager, associated with this POA.
 263:    *
 264:    * @return the associated servant manager or null if it has
 265:    * been previously set.
 266:    *
 267:    * @throws WrongPolicy if the required USE_SERVANT_MANAGER policy does not
 268:    * apply to this POA.
 269:    */
 270:   ServantManager get_servant_manager()
 271:                               throws WrongPolicy;
 272: 
 273:   /**
 274:    * Get the unique Id of the POA in the process in which it is created.
 275:    * This Id is needed by portable interceptors. The id is unique
 276:    * for the life span of the POA in the process. For persistent
 277:    * POAs, if a POA is created in the same path with the same name as
 278:    * another POA, these POAs are identical have the same id. All transient
 279:    * POAs are assumed unique.
 280:    */
 281:   byte[] id();
 282: 
 283:   /**
 284:    * Returns the reference to the active object with the given Id.
 285:    *
 286:    * @param the_Object_Id the object id.
 287:    *
 288:    * @throws ObjectNotActive if there is no active object with such Id.
 289:    * @throws WrongPolicy if the required RETAIN policy does not apply to
 290:    * this POA.
 291:    */
 292:   org.omg.CORBA.Object id_to_reference(byte[] the_Object_Id)
 293:                                 throws ObjectNotActive, WrongPolicy;
 294: 
 295:   /**
 296:    * Returns the servant that serves the active object with the given Id.
 297:    *
 298:    * @param the_Object_Id the object id.
 299:    *
 300:    * @throws ObjectNotActive if there is no active object with such Id.
 301:    * @throws WrongPolicy. This method requires either RETAIN or
 302:    * USE_DEFAULT_SERVANT policies and reaises the WrongPolicy if none of them
 303:    * apply to this POA.
 304:    */
 305:   Servant id_to_servant(byte[] the_Object_Id)
 306:                  throws ObjectNotActive, WrongPolicy;
 307: 
 308:   /**
 309:    * Returns the Object Id, encapsulated in the given object reference.
 310:    *
 311:    * @param the_Object the object that has been previously created with this
 312:    * POA. It need not be active.
 313:    *
 314:    * @throws WrongAdapter if the passed object has not been previously created
 315:    * with this POA.
 316:    * @throws WrongPolicy never (declared for the future extensions only).
 317:    */
 318:   byte[] reference_to_id(org.omg.CORBA.Object the_Object)
 319:                   throws WrongAdapter, WrongPolicy;
 320: 
 321:   /**
 322:    * Returns the servant that is serving this object.
 323:    *
 324:    * @return if the RETAIN policy applies and the object is in the Active
 325:    * Object Map, the method returns the servant, associated with this object.
 326:    * Otherwise, if the USE_DEFAULT_SERVANT policy applies, the method returns
 327:    * the default servant (if one was set).
 328:    *
 329:    * @throws ObjectNotActive if none of the conditions above are satisfied.
 330:    * @throws WrongAdapter if the object reference was not created with this POA.
 331:    * @throws WrongPolicy. This method requires either RETAIN or
 332:    * USE_DEFAULT_SERVANT policies and reaises the WrongPolicy if none of them
 333:    * apply to this POA.
 334:    */
 335:   Servant reference_to_servant(org.omg.CORBA.Object the_Object)
 336:                         throws ObjectNotActive, WrongPolicy, WrongAdapter;
 337: 
 338:   /**
 339:   * Returns the id of the object, served by the given servant. The id is found
 340:   * in one of the following ways.
 341:   * <ul>
 342:   * <li>If the POA has both the RETAIN and the UNIQUE_ID policy and
 343:   * the specified servant is active, the method return the Object Id associated
 344:   * with that servant.
 345:   * </li><li>
 346:   * If the POA has both the RETAIN and the IMPLICIT_ACTIVATION policy and
 347:   * either the POA has the MULTIPLE_ID policy or the specified servant is
 348:   * inactive, the method activates the servant using a POA-generated Object Id
 349:   * and the Interface Id associated with the servant, and returns that
 350:   * Object Id.
 351:   * </li>
 352:   * <li>If the POA has the USE_DEFAULT_SERVANT policy, the servant specified
 353:   * is the default servant, and the method is being invoked in the context o
 354:   * f executing a request on the default servant, the method returns the
 355:   * ObjectId associated with the current invocation.
 356:   * </li>
 357:   * </ul>
 358:   * @throws ServantNotActive in all cases, not listed in the list above.
 359:   * @throws WrongPolicy The method requres USE_DEFAULT_SERVANT policy or
 360:   * a combination of the RETAIN policy and either the UNIQUE_ID or
 361:   * IMPLICIT_ACTIVATION policies and throws the WrongPolicy if these conditions
 362:   * are not satisfied.
 363:   */
 364:   byte[] servant_to_id(Servant the_Servant)
 365:                 throws ServantNotActive, WrongPolicy;
 366: 
 367:   /**
 368:    * <p>Converts the given servant to the object reference.
 369:    * The servant will serve all methods, invoked on the returned object.
 370:    * The returned object reference can be passed to the remote client,
 371:    * enabling remote invocations.
 372:    * </p><p>
 373:    * If the specified servant already serves some active object, that
 374:    * object is returned. Otherwise,
 375:    * if the POA has the IMPLICIT_ACTIVATION policy the method activates
 376:    * the servant, creating an new object with the POA-generated Object Id.
 377:    * In this case, if the servant activator is set, the
 378:    * {@link ServantActivatorOperations#incarnate} method will be called.
 379:    * </p>
 380:    *
 381:    * @throws ServantNotActive if the servant is inactive and no
 382:    * IMPLICIT_ACTIVATION policy applies.
 383:    * @throws WrongPolicy This method needs the RETAIN policy and either the
 384:    * UNIQUE_ID or IMPLICIT_ACTIVATION policies.
 385:    *
 386:    * @return the object, exposing the given servant in the context of this POA.
 387:    */
 388:   org.omg.CORBA.Object servant_to_reference(Servant the_Servant)
 389:                                      throws ServantNotActive, WrongPolicy;
 390: 
 391:   /**
 392:    * Return the POA manager, associated with this POA.
 393:    *
 394:    * @return the associated POA manager (always available).
 395:    */
 396:   POAManager the_POAManager();
 397: 
 398:   /**
 399:    * Returns the adapter activator, associated with this POA.
 400:    * The newly created POA has no activator (null would be
 401:    * returned). The ORB root POA also initially has no activator.
 402:    *
 403:    * @return tha adapter activator or null if this POA has no
 404:    * associated adapter activator.
 405:    */
 406:   AdapterActivator the_activator();
 407: 
 408:   /**
 409:   * Set the adapter activator for this POA.
 410:   *
 411:   * @param the activator being set.
 412:   */
 413:   void the_activator(AdapterActivator activator);
 414: 
 415:   /**
 416:   * The children of this POA.
 417:   *
 418:   * @return the array of all childs for this POA.
 419:   */
 420:   POA[] the_children();
 421: 
 422:   /**
 423:    * Return the name of this POA.
 424:    *
 425:    * @return the name of POA, relative to its parent.
 426:    */
 427:   String the_name();
 428: 
 429:   /**
 430:    * Return the parent of this POA.
 431:    *
 432:    * @return the parent POA or <code>null</code> if this is a root POA.
 433:    */
 434:   POA the_parent();
 435: 
 436:   /**
 437:    * <p> Destroy this POA and all descendant POAs. The destroyed POAs can be
 438:    * later re-created via {@link AdapterActivator} or by invoking
 439:    * {@link #create_POA}.
 440:    * This differs from {@link PoaManagerOperations#deactivate} that does
 441:    * not allow recreation of the deactivated POAs. After deactivation,
 442:    * recreation is only possible if the POAs were later destroyed.
 443:    * </p><p>
 444:    * The remote invocation on the target, belonging to the POA that is
 445:    * currently destroyed return the remote exception ({@link TRANSIENT},
 446:    * minor code 4).
 447:    * </p>
 448:    * @param etherealize_objects if true, and POA has RETAIN policy, and the
 449:    * servant manager is available, the servant manager method
 450:    * {@link ServantActivatorOperations#etherealize} is called for each
 451:    *  <i>active</i> object in the Active Object Map. This method should not
 452:    * try to access POA being destroyed. If <code>destroy</code> is called
 453:    * multiple times before the destruction completes,
 454:    * the etherialization should be invoked only once.
 455:    *
 456:    * @param wait_for_completion if true, the method waits till the POA being
 457:    * destroyed completes all current requests and etherialization. If false,
 458:    * the method returns immediately.
 459:    */
 460:   void destroy(boolean etherealize_objects, boolean wait_for_completion);
 461: 
 462:   /**
 463:    * Create the IdUniquenessPolicy policy.
 464:    *
 465:    * @param value states which one Id uniqueness policy will apply.
 466:    *
 467:    * @return the created policy.
 468:    */
 469:   IdUniquenessPolicy create_id_uniqueness_policy(IdUniquenessPolicyValue a_value);
 470: 
 471:   /**
 472:    * Create the ImplicitActivationPolicy policy.
 473:    *
 474:    * @param value states which one activation policy will apply.
 475:    *
 476:    * @return the created policy.
 477:    */
 478:   ImplicitActivationPolicy create_implicit_activation_policy(ImplicitActivationPolicyValue a_value);
 479: 
 480:   /**
 481:    * Create the LifespanPolicy policy.
 482:    *
 483:    * @param value states which one object lifespan policy will apply.
 484:    *
 485:    * @return the created policy.
 486:    */
 487:   LifespanPolicy create_lifespan_policy(LifespanPolicyValue a_value);
 488: 
 489:   /**
 490:    * Create the RequestProcessingPolicy policy.
 491:    *
 492:    * @param value states which one request processing policy will apply.
 493:    *
 494:    * @return the created policy.
 495:    */
 496:   RequestProcessingPolicy create_request_processing_policy(RequestProcessingPolicyValue a_value);
 497: 
 498:   /**
 499:    * Create the ServantRetentionPolicy policy.
 500:    *
 501:    * @param value states which one servant retention policy will apply.
 502:    *
 503:    * @return the created policy.
 504:    */
 505:   ServantRetentionPolicy create_servant_retention_policy(ServantRetentionPolicyValue a_value);
 506: 
 507:   /**
 508:    * Create the ThreadPolicy policy.
 509:    *
 510:    * @param value states which one thread policy will apply.
 511:    *
 512:    * @return the created policy.
 513:    */
 514:   ThreadPolicy create_thread_policy(ThreadPolicyValue a_value);
 515: 
 516:   /**
 517:   * Create the ID assignment policy with the given value.
 518:   *
 519:   * @param value states which one ID assignment policy will apply.
 520:   *
 521:   * @return the created policy.
 522:   */
 523:   IdAssignmentPolicy create_id_assignment_policy(IdAssignmentPolicyValue value);
 524: