⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gnupoa.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
   * type is not passed.   *   * @return true if the policy value applies, false otherwise.   */  public final boolean applies(java.lang.Object policy_value)  {    return m_policies.contains(policy_value);  }  /**   * Check for the presence of the required policy.   *   * @param policy_value a policy value to check.   *   * @throws WrongPolicy if the required policy value is not applicable.   */  public final void required(java.lang.Object policy_value)                      throws WrongPolicy  {    if (!applies(policy_value))      throw new WrongPolicy(policy_value + " policy required.");  }  /**   * Check for the absence of the given policy.   *   * @param policy_value a policy value to check.   *   * @throws WrongPolicy if the passed policy value is applicable.   */  public final void excluding(java.lang.Object policy_value)                       throws WrongPolicy  {    if (applies(policy_value))      throw new WrongPolicy(policy_value + " policy applies.");  }  /**  * Find and optionally activate the child POA with the given name.  *  * @param poa_name the name of the POA to find.  * @param activate_it if the child with the specified name is not found  * or inactive and this parameter is true, the target POA activator is  * invoked to activate that child. If this succeeds, that child POA  * is returned.  *  * @throws AdapterNonExistent if no active child with the given name  * is found and one of the following is true:  * a) the target POA has no associated  * {@link AdapterActivator}. b) that activator fails to activate the  * child POA. c) <code>activate_id</code> = false.  */  public POA find_POA(String poa_name, boolean activate_it)               throws AdapterNonExistent  {    POA child;    for (int i = 0; i < children.size(); i++)      {        child = (POA) children.get(i);        if (child.the_name().equals(poa_name))          return child;      }    if (activate_it && m_activator != null)      {        boolean activated = m_activator.unknown_adapter(this, poa_name);        if (!activated)          throw new AdapterNonExistent(poa_name + " activation failed.");        // Tha activator should add the child to the childrent table.        for (int i = 0; i < children.size(); i++)          {            child = (POA) children.get(i);            if (child.the_name().equals(poa_name))              return child;          }        throw new AdapterNonExistent(poa_name + " not created. ");      }    else      throw new AdapterNonExistent(poa_name);  }  /**   * Generate the Object Id for the given servant and add the servant to the   * Active Object Map using this Id a a key. If the servant activator is set,   * its incarnate method will be called.   *    * @param a_servant a servant that would serve the object with the returned   * Object Id. If null is passed, under apporoprate policies the servant   * activator is invoked.   *    * @return the generated objert Id for the given servant.   *    * @throws ServantAlreadyActive if this servant is already in the Active   * Object Map and the UNIQUE_ID policy applies.   *    * @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN do not   * apply to this POA.   */  public byte[] activate_object(Servant a_servant)    throws ServantAlreadyActive, WrongPolicy  {    checkDiscarding();    required(ServantRetentionPolicyValue.RETAIN);    required(IdAssignmentPolicyValue.SYSTEM_ID);    AOM.Obj exists = aom.findServant(a_servant);    if (exists != null)      {        if (exists.isDeactiveted())          {            // If exists but deactivated, activate and return            // the existing key.            exists.setDeactivated(false);            incarnate(exists, exists.key, a_servant, false);            return exists.key;          }        else if (applies(IdUniquenessPolicyValue.UNIQUE_ID))          throw new ServantAlreadyActive();        // It multiple ids are allowed, exit block allowing repetetive        // activations.      }    byte[] object_key = AOM.getFreeId();    ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this,      object_key);    create_and_connect(object_key,      a_servant._all_interfaces(this, object_key)[0], delegate);    return object_key;  }  /**   * Add the given servant to the Active Object Map as a servant for the object   * with the provided Object Id. If the servant activator is set, its incarnate   * method will be called.   *    * @param an_Object_Id an object id for the given object.   * @param a_servant a servant that will serve the object with the given Object   * Id. If null is passed, under apporoprate policies the servant activator is   * invoked.   *    * @throws ObjectAlreadyActive if the given object id is already in the Active   * Object Map.   * @throws ServantAlreadyActive if the UNIQUE_ID policy applies and this   * servant is already in use.   * @throws WrongPolicy if the required RETAIN policy does not apply to this   * POA.   * @throws BAD_PARAM if the passed object id is invalid due any reason.   */  public void activate_object_with_id(byte[] an_Object_Id, Servant a_servant)                               throws ServantAlreadyActive, ObjectAlreadyActive,                                      WrongPolicy  {    activate_object_with_id(an_Object_Id, a_servant, false);  }  /**   * Same as activate_object_with_id, but permits gnuForwardRequest forwarding   * exception. This is used when the activation is called from the remote   * invocation context and we have possibility to return the forwarding   * message.   */  public void activate_object_with_id(byte[] an_Object_Id, Servant a_servant,    boolean use_forwarding)    throws ServantAlreadyActive, ObjectAlreadyActive, WrongPolicy  {    checkDiscarding();    required(ServantRetentionPolicyValue.RETAIN);    // If the UNIQUE_ID applies, the servant being passed must not be    // already active.    if (applies(IdUniquenessPolicyValue.UNIQUE_ID))      {        AOM.Obj sx = aom.findServant(a_servant, false);        if (sx != null)          throw new ServantAlreadyActive();      }    AOM.Obj exists = aom.get(an_Object_Id);    if (exists != null)      {        if (exists.servant == null)          {            locateServant(an_Object_Id, a_servant, exists, use_forwarding);            exists.setDeactivated(false);          }        else if (exists.isDeactiveted())          {            exists.setDeactivated(false);            incarnate(exists, an_Object_Id, a_servant, use_forwarding);          }        else          throw new ObjectAlreadyActive();      }    else      {        ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this,          an_Object_Id);        create_and_connect(an_Object_Id, a_servant._all_interfaces(this,          an_Object_Id)[0], delegate);      }  }  /**   * Locate the servant for this object Id and connect it to ORB.   *    * @param an_Object_Id the object id.   * @param a_servant the servant (may be null).   * @param exists an existing active object map entry.   * @param use_forwarding allow to throw the gnuForwardRequest if the activator   * throws ForwardRequest.   *    * @throws OBJ_ADAPTER minor 4 if the servant cannot be located (the required   * servant manager may be missing).   */  private void locateServant(byte[] an_Object_Id, Servant a_servant,                             AOM.Obj exists, boolean use_forwarding                            )                      throws InternalError  {    // An object was created with create_reference.    gnuServantObject object = (gnuServantObject) exists.object;    if (servant_activator != null)      {        exists.setServant(incarnate(exists, an_Object_Id, a_servant,                                    use_forwarding                                   )                         );      }    else if (default_servant != null)      {        exists.setServant(default_servant);      }    if (exists.servant == null)      {        exists.setServant(a_servant);      }    if (exists.servant == null)      {        throw new OBJ_ADAPTER("no servant", 4, CompletionStatus.COMPLETED_NO);      }    ServantDelegateImpl delegate =      new ServantDelegateImpl(exists.servant, this, an_Object_Id);    exists.servant._set_delegate(delegate);    object.setServant(exists.servant);    connect_to_orb(an_Object_Id, delegate.object);  }  /**   * Deactivate object with the given id.   *   * The deactivated object will continue to process requests that arrived   * before decativation. If this POA has the associated   * servant manager, a {@link ServantActivatorOperations#etherealize} is   * immediately invoked on the passed id.   *   * @throws WrongPolicy if the required RETAIN policy does not apply to   * this POA.   */  public void deactivate_object(byte[] the_Object_Id)                         throws ObjectNotActive, WrongPolicy  {    required(ServantRetentionPolicyValue.RETAIN);    AOM.Obj exists = aom.get(the_Object_Id);    if (exists == null || exists.isDeactiveted())      throw new ObjectNotActive();    exists.setDeactivated(true);    // Check if this servant is serving something else.    aom.remove(the_Object_Id);    AOM.Obj other = aom.findServant(exists.servant, false);    boolean remaining = other != null;    aom.put(exists);    if (servant_activator != null)      servant_activator.etherealize(the_Object_Id, this, exists.servant, false,                                    remaining                                   );  }  /**  * Create the object reference, encapsulating the given repository Id and  * the Object Id, generated by this POA. The returned object will not be  * activated by default and may be activated on the first invocation by  * the servant manager (if it is set and if policies are applicable).  *  * @param a_repository_id the repository id for the given object, can  * be null if to be requested from the servant later.  *  * @throws WrongPolicy if the required SYSTEM_ID policy does not apply to  * this POA.  */  public org.omg.CORBA.Object create_reference(String a_repository_id)                                        throws WrongPolicy  {    required(IdAssignmentPolicyValue.SYSTEM_ID);    return create_reference_with_id(AOM.getFreeId(), a_repository_id);  }  /**   * <p>   * Create the object reference, encapsulating the given repository Id and   * the given Object Id. The returned object will <i>not</i> be   * activated by default and may be activated on the first invocation by   * the servant manager (if the IMPLICIT_ACTIVATION policy applies).   *   * @param an_object_id the object id for the object being created. If this   * POA uses the SYSTEM_ID policy, the portable application should only   * pass the ids, generated by this POA.   *   * @param a_repository_id the repository id for the object being created,   * can be null if this information should be later requested from the   * servant.   */  public org.omg.CORBA.Object create_reference_with_id(byte[] an_object_id,    String a_repository_id   )  {    String[] ids;    if (a_repository_id == null)      ids = null;    else      ids = new String[] { a_repository_id };    // Check maybe such object is already activated.    AOM.Obj e = aom.get(an_object_id);    Servant servant;    if (e == null)      {        servant = null;      }    else      {        servant = e.servant;        e.setDeactivated(false);      }    gnuServantObject object =      new gnuServantObject(ids, an_object_id, this, m_orb);    object._set_delegate(new LocalDelegate(object, this, an_object_id));    aom.add(object.Id, object, servant, this);    connect_to_orb(an_object_id, object);    return object;  }  /**   * Creates a new POA as a child of the target POA.   *   * @param child_name the name of the child POA being created.   * @param manager the manager that will control the new POA. If this parameter   * is null, a new POA manager is created and associated with the new POA.   *   * @param policies the policies, applicable for the parent POA. Policies   * are <i>not</i> inherited from the parent POA.   *   * @return an newly created POA. The POA will be intially in the holding   * state and must be activated to start processing requests.   *   * @throws AdapterAlreadyExists if the child with the given child_name   * already exists for the current POA.   * @throws InvalidPolicy if the policies conflict with each other or are   * otherwise inappropriate.   *   * @see #the_children()   */  public POA create_POA(String child_name, POAManager manager, Policy[] policies)                 throws AdapterAlreadyExists, InvalidPolicy  {    POA child;    for (int i = 0; i < children.size(); i++)      {        child = (POA) children.get(i);        if (child.the_name().equals(child_name))          throw new AdapterAlreadyExists(name + "/" + child_name);      }    POA poa = createPoaInstance(child_name, manager, policies, m_orb);    children.add(poa);    return poa;  }  /**   * Returns a default servant for this POA.   *   * @return a servant that will be used for requests for   * which no servant is found in the Active Object Map.   *   * @throws NoServant if there is no default servant associated with this POA.   * @throws WrongPolicy if the USE_DEFAULT_SERVANT policy is not active.   */  public Servant get_servant()                      throws NoServant, WrongPolicy  {    required(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);    if (default_servant == null)      throw new NoServant();    return default_servant;  }  /**   * Sets the default servant for this POA.   *   * @param a_servant a servant that will be used for requests for   * which no servant is found in the Active Object Map.   *   * @throws WrongPolicy if the USE_DEFAULT_SERVANT policy is not active.   */  public void set_servant(Servant a_servant)                   throws WrongPolicy  {    required(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);    default_servant = a_servant;  }  /**   * Set a servant manager for this POA.   *   * @param a servant manager being set. If the RETAIN policy applies, the   * manager must implement a {@link ServantActivator}. If the NON_RETAIN   * policy applies, the manager must implement a {@link ServantLocator}.   *   * @throws WrongPolicy if the required USE_SERVANT_MANAGER policy does not   * apply to this POA.   *   * @throws OBJ_ADAPTER minor code 4 if the passed manager does not   * implement the required interface ({@link ServantActivator},   * {@link ServantLocator}). The POA, that has the RETAIN policy uses   * servant managers that are ServantActivators. When the POA has the   * NON_RETAIN policy it uses servant managers that are ServantLoacators.   *   * @throws BAD_INV_ORDER minor code 6 if the method is called more than once   * on the same POA. The manager can be set only once.   */  public void set_servant_manager(ServantManager a_manager)                           throws WrongPolicy  {    required(RequestProcessingPolicyValue.USE_SERVANT_MANAGER);    if (servant_activator != null || servant_locator != null)      throw new BAD_INV_ORDER("Setting manager twice for " + name, 6,                              CompletionStatus.COMPLETED_NO                             );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -