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

📄 gnupoa.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* gnuAbstractPOA.java --   Copyright (C) 2005 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package gnu.CORBA.Poa;import java.util.ArrayList;import java.util.Arrays;import java.util.HashSet;import org.omg.CORBA.BAD_INV_ORDER;import org.omg.CORBA.BAD_PARAM;import org.omg.CORBA.CompletionStatus;import org.omg.CORBA.LocalObject;import org.omg.CORBA.NO_IMPLEMENT;import org.omg.CORBA.OBJ_ADAPTER;import org.omg.CORBA.ORB;import org.omg.CORBA.Object;import org.omg.CORBA.Policy;import org.omg.CORBA.SetOverrideType;import org.omg.CORBA.TRANSIENT;import org.omg.CORBA.portable.ObjectImpl;import org.omg.PortableInterceptor.NON_EXISTENT;import org.omg.PortableInterceptor.ObjectReferenceFactory;import org.omg.PortableInterceptor.ObjectReferenceTemplate;import org.omg.PortableInterceptor.ObjectReferenceTemplateHelper;import org.omg.PortableServer.AdapterActivator;import org.omg.PortableServer.ForwardRequest;import org.omg.PortableServer.IdAssignmentPolicy;import org.omg.PortableServer.IdAssignmentPolicyValue;import org.omg.PortableServer.IdUniquenessPolicy;import org.omg.PortableServer.IdUniquenessPolicyValue;import org.omg.PortableServer.ImplicitActivationPolicy;import org.omg.PortableServer.ImplicitActivationPolicyValue;import org.omg.PortableServer.LifespanPolicy;import org.omg.PortableServer.LifespanPolicyValue;import org.omg.PortableServer.POA;import org.omg.PortableServer.POAManager;import org.omg.PortableServer.RequestProcessingPolicy;import org.omg.PortableServer.RequestProcessingPolicyValue;import org.omg.PortableServer.SERVANT_RETENTION_POLICY_ID;import org.omg.PortableServer.Servant;import org.omg.PortableServer.ServantActivator;import org.omg.PortableServer.ServantLocator;import org.omg.PortableServer.ServantManager;import org.omg.PortableServer.ServantRetentionPolicy;import org.omg.PortableServer.ServantRetentionPolicyValue;import org.omg.PortableServer.ThreadPolicy;import org.omg.PortableServer.ThreadPolicyValue;import org.omg.PortableServer.POAManagerPackage.State;import org.omg.PortableServer.POAPackage.AdapterAlreadyExists;import org.omg.PortableServer.POAPackage.AdapterNonExistent;import org.omg.PortableServer.POAPackage.InvalidPolicy;import org.omg.PortableServer.POAPackage.NoServant;import org.omg.PortableServer.POAPackage.ObjectAlreadyActive;import org.omg.PortableServer.POAPackage.ObjectNotActive;import org.omg.PortableServer.POAPackage.ServantAlreadyActive;import org.omg.PortableServer.POAPackage.ServantNotActive;import org.omg.PortableServer.POAPackage.WrongAdapter;import org.omg.PortableServer.POAPackage.WrongPolicy;import gnu.CORBA.OrbFunctional;import gnu.CORBA.CDR.BufferredCdrInput;import gnu.CORBA.CDR.BufferedCdrOutput;/** * Our POA implementation. * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */public class gnuPOA  extends LocalObject  implements POA, ObjectReferenceFactory{  /**   * The object reference template, associated with this POA.   *    * @since 1.5   */  class RefTemplate implements ObjectReferenceTemplate  {    /**      * Use serialVersionUID for interoperability.      */    private static final long serialVersionUID = 1;        RefTemplate()    {      // The adapter name is computed once.      ArrayList names = new ArrayList();      names.add(the_name());      POA poa = the_parent();      while (poa != null)        {          names.add(poa.the_name());          poa = poa.the_parent();        }      // Fill in the string array in reverse (more natural) order,      // root POA first.      m_adapter_name = new String[names.size()];      for (int i = 0; i < m_adapter_name.length; i++)        m_adapter_name[i] = (String) names.get(m_adapter_name.length - i - 1);    }        /**     * The adapter name     */    final String[] m_adapter_name;        /**     * Get the name of this POA.     */    public String[] adapter_name()    {      return (String[]) m_adapter_name.clone();    }    /**     * Get the ORB id.     */    public String orb_id()    {      return m_orb.orb_id;    }    /**     * Get the server id.     */    public String server_id()    {      return OrbFunctional.server_id;    }    /**     * Create the object.     */    public Object make_object(String repositoryId, byte[] objectId)    {      return create_reference_with_id(objectId, repositoryId);    }    /**     * Get the array of truncatible repository ids.     */    public String[] _truncatable_ids()    {      return ref_template_ids;    }  }    /**    * Use serialVersionUID for interoperability.    */  private static final long serialVersionUID = 1;    /**   * The adapter reference template.   */  ObjectReferenceTemplate refTemplate;    /**   * The reference template repository ids. Defined outside the class as it   * cannot have static members.   */  final static String[] ref_template_ids =     new String[] { ObjectReferenceTemplateHelper.id() };    /**   * The active object map, mapping between object keys, objects and servants.   */  public final AOM aom = new AOM();  /**   * The children of this POA.   */  final ArrayList children = new ArrayList();  /**   * The name of this POA.   */  final String name;  /**   * The parent of this POA (null for the root POA).   */  final POA parent;  /**   * The ior key signature, indicating, that the ior key is encoded using   * internal agreements of this implementation (0x'free').   */  static final int SIGNATURE = 0x66726565;  /**   * The adapter activator for this POA, null if no activator is set.   */  AdapterActivator m_activator;  /**   * The POA manager for this POA.   */  POAManager m_manager;  /**   * The servant manager (servant activator) for this POA.   */  ServantActivator servant_activator;  /**   * The servant manager (servant locator) for this POA.   */  ServantLocator servant_locator;  /**   * The default servant, if on is in use.   */  Servant default_servant;  /**   * The cached poa id value, computed once.   */  private byte[] m_poa_id;  /**   * The all policy values that apply to this POA.   * The used policy values are singletons, unique between policies.   */  private final HashSet m_policies;  /**   * An array of the set policies.   */  Policy[] s_policies;  /**   * The ORB, where the POA is connected.   */  final ORB_1_4 m_orb;  /**   * When true, the POA is being destroyed or is destroyed.   */  boolean m_inDestruction;  /**   * True if the active object map is used by this POA.   * The value is moved into separate boolean value due   * necessity of the frequent checks.   */  public final boolean retain_servant;    /**   * The object reference factory, used to create the new object   * references.   */  ObjectReferenceFactory m_object_factory = this;  /**   * Create a new abstract POA.   *   * @param a_parent the parent of this POA.   * @param a_name a name for this POA.   * @param a_manager a manager for this POA. If null, a new   * {@link gnuPOAManager} will be instantiated.   * @param a_policies an array of policies that apply to this POA.   * @param an_orb an ORB for this POA.   */  public gnuPOA(gnuPOA a_parent, String a_name, POAManager a_manager,                Policy[] a_policies, ORB_1_4 an_orb               )         throws InvalidPolicy  {    // Add default policies.    Policy[] all_policies = StandardPolicies.withDefault(a_policies);    name = a_name;    parent = a_parent;    m_orb = an_orb;    if (a_manager != null)      m_manager = a_manager;    else      m_manager = new gnuPOAManager();    if (m_manager instanceof gnuPOAManager)      {        gnuPOAManager g = (gnuPOAManager) m_manager;        g.addPoa(this);      }    m_policies = new HashSet(all_policies.length);    s_policies = new Policy[ all_policies.length ];    for (int i = 0; i < s_policies.length; i++)      {        s_policies [ i ] = all_policies [ i ].copy();        m_policies.add(((AccessiblePolicy) s_policies [ i ]).getValue());      }    retain_servant = applies(ServantRetentionPolicyValue.RETAIN);    validatePolicies(a_policies);        refTemplate = new RefTemplate();  }  /**   * Wait while at least one of the threads in this POA is actively   * processing one of requests.   */  public void waitWhileRunning()  {    // First pause.    long time = 1;    // Maximal duration between checks.    long max = 500;    boolean runs;    do      {        runs = m_orb.currents.has(this);        if (runs)          {            // Avoid taking CPU resources            // from the thread that is running.            try              {                Thread.sleep(time);                time = time * 2;                if (time > max)                  time = max;              }            catch (InterruptedException ex)              {              }          }      }    while (runs);  }  /**   * Etherealize all objects, associated with this POA. Invoked from the   * {@link gnuPOAManager} only if it is known that the servant_activator   * holds non-null value.   */  protected void etherealizeAll()  {    if (servant_activator == null)      return;    ArrayList keys = new ArrayList();    keys.addAll(aom.keySet());    byte[] key;    AOM.Obj obj;    boolean last;    for (int i = 0; i < keys.size(); i++)      {        key = (byte[]) keys.get(i);        obj = aom.get(key);        if (obj.poa == this)          {            aom.remove(key);            if (!obj.isDeactiveted())              {                // Check if the servant still stays under the other key.                last = aom.findServant(obj.servant) == null;                servant_activator.etherealize(obj.key, this, obj.servant, true,                                              last                                             );              }          }      }  }  /**   * Create an instance of the POA with the given features.   * This method is not responsible for duplicate checking   * or adding the returned instance to any possible table.   *   * @param child_name the name of the poa being created.   * @param manager the poa manager (never null).   * @param policies the array of policies.   * @param an_orb the ORB for this POA.   *   * @return the created POA.   *   * @throws InvalidPolicy for conflicting or otherwise invalid policies.|   */  protected POA createPoaInstance(String child_name, POAManager a_manager,                                  Policy[] policies, ORB_1_4 an_orb                                 )                           throws InvalidPolicy  {    POAManager some_manager =      a_manager == null ? new gnuPOAManager() : a_manager;    if (some_manager instanceof gnuPOAManager)      {        ((gnuPOAManager) some_manager).addPoa(this);      }    return new gnuPOA(this, child_name, some_manager, policies, an_orb);  }  /**   * Check if the given policy value applies to this POA.   *   * @param policy_value a policy value to check. The policy values are   * singletons and unique between the different policies, so the policy

⌨️ 快捷键说明

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