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

📄 gnupoa.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
  }  /** {@inheritDoc} */  public IdUniquenessPolicy create_id_uniqueness_policy(IdUniquenessPolicyValue a_value)  {    return new gnuIdUniquenessPolicy(a_value);  }  /** {@inheritDoc} */  public ImplicitActivationPolicy create_implicit_activation_policy(ImplicitActivationPolicyValue a_value)  {    return new gnuImplicitActivationPolicy(a_value);  }  /** {@inheritDoc} */  public LifespanPolicy create_lifespan_policy(LifespanPolicyValue a_value)  {    return new gnuLifespanPolicy(a_value);  }  /** {@inheritDoc} */  public RequestProcessingPolicy create_request_processing_policy(RequestProcessingPolicyValue a_value)  {    return new gnuRequestProcessingPolicy(a_value);  }  /** {@inheritDoc} */  public ServantRetentionPolicy create_servant_retention_policy(ServantRetentionPolicyValue a_value)  {    return new gnuServantRetentionPolicy(a_value);  }  /** {@inheritDoc} */  public ThreadPolicy create_thread_policy(ThreadPolicyValue a_value)  {    return new gnuThreadPolicy(a_value);  }  /**   * <p>   * Destroy this POA and all descendant POAs. The destroyed POAs can be later   * re-created via {@link AdapterActivator} or by invoking {@link #create_POA}.   * This differs from {@link PoaManagerOperations#deactivate} that does not   * allow recreation of the deactivated POAs. After deactivation, recreation is   * only possible if the POAs were later destroyed.   * </p>   * <p>   * The remote invocation on the target, belonging to the POA that is currently   * destroyed return the remote exception ({@link TRANSIENT}, minor code 4).   * </p>   *    * @param etherealize_objects if true, and POA has RETAIN policy, and the   * servant manager is available, the servant manager method   * {@link ServantActivatorOperations#etherealize} is called for each <i>active</i>   * object in the Active Object Map. This method should not try to access POA   * being destroyed. If <code>destroy</code> is called multiple times before   * the destruction completes, the etherialization should be invoked only once.   *    * @param wait_for_completion if true, the method waits till the POA being   * destroyed completes all current requests and etherialization. If false, the   * method returns immediately.   */  public void destroy(boolean etherealize_objects, boolean wait_for_completion)  {    // Notify the IOR interceptors about that the POA is destroyed.    if (m_orb.iIor != null)      m_orb.iIor.adapter_state_changed(        new ObjectReferenceTemplate[] { getReferenceTemplate() },        NON_EXISTENT.value);    if (wait_for_completion)      waitWhileRunning();    // Nofify the IOR interceptors that the POA is destroyed.    if (m_manager instanceof gnuPOAManager)      {        ((gnuPOAManager) m_manager).poaDestroyed(this);      }    // Put the brake instead of manager, preventing the subsequent    // requests.    gnuPOAManager g = new gnuPOAManager();    g.state = State.INACTIVE;    m_manager = g;    // Disconnect from parent.    if (parent instanceof gnuPOA)      {        ((gnuPOA) parent).children.remove(this);      }    unregisterFromManager();    // Disconnect from the ORB all objects, registered with this POA.    ArrayList keys = new ArrayList();    keys.addAll(aom.keySet());    byte[] key;    AOM.Obj obj;    for (int i = 0; i < keys.size(); i++)      {        key = (byte[]) keys.get(i);        obj = aom.get(key);        if (obj.poa == this)          m_orb.disconnect(obj.object);      }    m_orb.identityDestroyed(this);    if (etherealize_objects && servant_activator != null && !m_inDestruction)      {        etherealizeAll();      }    m_inDestruction = true;    POA[] ch = the_children();    for (int i = 0; i < ch.length; i++)      {        ch[i].destroy(etherealize_objects, wait_for_completion);      }  }  /**   * Destroy this POA if it has not been destroyed, destroys it.   */  protected void finalize()                   throws java.lang.Throwable  {    if (!m_inDestruction)      destroy(false, false);  }  /**   * Remove self from the manager list.   */  private void unregisterFromManager()  {    if (m_manager instanceof gnuPOAManager)      {        gnuPOAManager p = (gnuPOAManager) m_manager;        p.removePOA(this);      }  }  /**   * Get the policy of the given type, associated with this POA.   *   * @param a_policy_type a type of the requested policy.   * @return a policy of the given type, applyting to this POA.   *   * @throws org.omg.CORBA.BAD_PARAM if the policy of this type has not   * been specified for this POA.   */  public Policy _get_policy(int a_policy_type)                     throws org.omg.CORBA.BAD_PARAM  {    for (int i = 0; i < s_policies.length; i++)      {        if (s_policies [ i ].policy_type() == a_policy_type)          return s_policies [ i ].copy();      }    throw new BAD_PARAM("No policy type " + a_policy_type);  }  /**   * Get the copy of the policy array.   */  public Policy[] getPolicyArray()  {    Policy[] r = new Policy[ s_policies.length ];    for (int i = 0; i < s_policies.length; i++)      {        r [ i ] = s_policies [ i ].copy();      }    return r;  }  /**   * The POAs cannot be created by this method.   *   * @specnote this is also not possible in Suns jdk at least till 1.4.   *   * @throws NO_IMPLEMENT always.   */  public org.omg.CORBA.Object _set_policy_override(Policy[] policies,                                                   SetOverrideType how                                                  )  {    throw new NO_IMPLEMENT("Use createPOA instead.");  }  /**   * Get the ORB, where this POA is connected.   */  public ORB orb()  {    return m_orb;  }  /**   * Connect the given delegate under the given key, also calling incarnate.   */  private void create_and_connect(byte[] object_key, String repository_id,    ServantDelegateImpl delegate)  {    aom.add(delegate);    connect_to_orb(object_key, getReferenceFactory().make_object(repository_id,      object_key));    if (servant_activator != null)      incarnate(null, object_key, delegate.servant, false);  }  /**   * Check if the POA is not in a discarding mode. The activation   * operations are forbidded in discarding mode.   *   * @throws TRANSIENT if the POA is in discarding mode.   */  private void checkDiscarding()                        throws TRANSIENT  {    if (m_manager.get_state() == State.DISCARDING)      throw new TRANSIENT("Discarding mode", 1, CompletionStatus.COMPLETED_MAYBE);  }  /**   * Connect the given delegate object to orb.   */  protected void connect_to_orb(byte[] an_Object_Id, org.omg.CORBA.Object object)  {    if (applies(ThreadPolicyValue.SINGLE_THREAD_MODEL))      m_orb.connect_1_thread(object, toIORKey(an_Object_Id), this);    else      m_orb.connect(object, toIORKey(an_Object_Id));  }  /**   * Returns the representation of this POA tree.   */  public String toString()  {    StringBuffer b = new StringBuffer(name);    if (children.size() != 0)      {        b.append(" (");        for (int i = 0; i < children.size(); i++)          {            b.append(children.get(i));            if (i < children.size() - 2)              b.append(", ");          }        b.append(")");      }    return b.toString();  }  /**   * Check if the policy set is valid.   */  protected boolean validatePolicies(Policy[] a)                              throws InvalidPolicy  {    if (applies(ServantRetentionPolicyValue.NON_RETAIN))      {        if (!applies(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT) &&            !applies(RequestProcessingPolicyValue.USE_SERVANT_MANAGER)           )          {            short p = 0;            for (short i = 0; i < a.length; i++)              {                if (a [ i ].policy_type() == SERVANT_RETENTION_POLICY_ID.value)                  p = i;              }            throw new InvalidPolicy("NON_RETAIN requires either " +                                    "USE_DEFAULT_SERVANT or USE_SERVANT_MANAGER",                                    p                                   );          }      }    return true;  }  /**   * Recursively searches for the given object in the POA tree.   */  public AOM.Obj findObject(org.omg.CORBA.Object object)  {    AOM.Obj h = aom.findObject(object);    if (h != null)      return h;    else      {        for (int i = 0; i < children.size(); i++)          {            h = ((gnuPOA) children.get(i)).findObject(object);            if (h != null)              return h;          }      }    return h;  }    /**   * Recursively searches for the given key in the POA tree.   * @param ior_key the key, ecapsulating both object   * and poa ids.   * @return   */  public AOM.Obj findKey(byte[] object_id, byte[] poa_id)  {    AOM.Obj h = null;    if (Arrays.equals(poa_id, id()))      h = aom.get(object_id);    if (h != null)      return h;    else      {        for (int i = 0; i < children.size(); i++)          {            h = ((gnuPOA) children.get(i)).findKey(object_id, poa_id);            if (h != null)              return h;          }      }    return h;  }  /**   * Parses the given key, extracts poa and object id and searches   * for such reference.   */  public AOM.Obj findIorKey(byte[] ior_key)  {    BufferredCdrInput in = new BufferredCdrInput(ior_key);    int signature = in.read_long();    if (signature != SIGNATURE)      return null;    byte[] id = in.read_sequence();    byte[] poa = in.read_sequence();    return findKey(id, poa);  }  /**   * Converts the object Id into the IOR key. IOR key must be   * unique in the scope of the ORB, and Ids only in the scope of POA.   * Hence the IOR key includes the POA identifiers.   */  public byte[] toIORKey(byte[] object_id)  {    BufferedCdrOutput buffer = new BufferedCdrOutput();    buffer.write_long(SIGNATURE);    buffer.write_sequence(object_id);    buffer.write_sequence(id());    return buffer.buffer.toByteArray();  }  /**   * Extracts the object id from the ior key.   *   * @param ior_key   *   * @return the encapsulated object ior key or null if   * this ior key either refers a different POA or encoding signature   * mismatch.   */  public byte[] idFormIor(byte[] ior_key)  {    BufferredCdrInput in = new BufferredCdrInput(ior_key);    int signature = in.read_long();    if (signature != SIGNATURE)      return null;    byte[] object_id = in.read_sequence();    byte[] poa_id = in.read_sequence();    if (Arrays.equals(poa_id, id()))      return object_id;    else      return null;  }    /**   * Recursively searches for the given servant in the POA tree.   */  public AOM.Obj findServant(Servant servant)  {    AOM.Obj h = aom.findServant(servant);    if (h != null)      return h;    else      {        for (int i = 0; i < children.size(); i++)          {            h = ((gnuPOA) children.get(i)).findServant(servant);            if (h != null)              return h;          }      }    return h;  }    /**   * Get the object reference template of this POA.   * Instantiate a singleton instance, if required.   */  public ObjectReferenceTemplate getReferenceTemplate()  {    if (refTemplate == null)      refTemplate = new RefTemplate();        return refTemplate;  }    public ObjectReferenceFactory getReferenceFactory()  {    return m_object_factory;  }    public void setReferenceFactory(ObjectReferenceFactory factory)  {    m_object_factory = factory;  }  /**   * Create the object (needed by the factory interface).   */  public Object make_object(String a_repository_id, byte[] an_object_id)  {    AOM.Obj existing = aom.get(an_object_id);    // The object may already exist. In this case, it is just returned.    if (existing != null && existing.object != null)      return existing.object;    else      {        return new gnuServantObject(new String[] { a_repository_id },          an_object_id, this, m_orb);      }  }  /**   * Required by object reference factory ops.   */  public String[] _truncatable_ids()  {    return ref_template_ids;  }}

⌨️ 快捷键说明

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