/[classpath]/classpath/gnu/CORBA/Poa/gnuPOA.java
ViewVC logotype

Diff of /classpath/gnu/CORBA/Poa/gnuPOA.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.1 by gnu_andrew, Tue Aug 2 20:12:08 2005 UTC revision 1.1.2.2 by gnu_andrew, Wed Nov 2 00:43:26 2005 UTC
# Line 87  import org.omg.PortableServer.POAPackage Line 87  import org.omg.PortableServer.POAPackage
87  import org.omg.PortableServer.POAPackage.ServantNotActive;  import org.omg.PortableServer.POAPackage.ServantNotActive;
88  import org.omg.PortableServer.POAPackage.WrongAdapter;  import org.omg.PortableServer.POAPackage.WrongAdapter;
89  import org.omg.PortableServer.POAPackage.WrongPolicy;  import org.omg.PortableServer.POAPackage.WrongPolicy;
90  import gnu.CORBA.CDR.cdrBufInput;  import gnu.CORBA.CDR.BufferredCdrInput;
91  import gnu.CORBA.CDR.cdrBufOutput;  import gnu.CORBA.CDR.BufferedCdrOutput;
92    
93  /**  /**
94   * Our POA implementation.   * Our POA implementation.
# Line 102  public class gnuPOA Line 102  public class gnuPOA
102    /**    /**
103     * The active object map, mapping between object keys, objects and servants.     * The active object map, mapping between object keys, objects and servants.
104     */     */
105    public final activeObjectMap aom = new activeObjectMap();    public final AOM aom = new AOM();
106    
107    /**    /**
108     * The children of this POA.     * The children of this POA.
# Line 199  public class gnuPOA Line 199  public class gnuPOA
199           throws InvalidPolicy           throws InvalidPolicy
200    {    {
201      // Add default policies.      // Add default policies.
202      Policy[] all_policies = policySets.withDefault(a_policies);      Policy[] all_policies = StandardPolicies.withDefault(a_policies);
203    
204      name = a_name;      name = a_name;
205      parent = a_parent;      parent = a_parent;
# Line 222  public class gnuPOA Line 222  public class gnuPOA
222      for (int i = 0; i < s_policies.length; i++)      for (int i = 0; i < s_policies.length; i++)
223        {        {
224          s_policies [ i ] = all_policies [ i ].copy();          s_policies [ i ] = all_policies [ i ].copy();
225          m_policies.add(((vPolicy) s_policies [ i ]).getValue());          m_policies.add(((AccessiblePolicy) s_policies [ i ]).getValue());
226        }        }
227    
228      retain_servant = applies(ServantRetentionPolicyValue.RETAIN);      retain_servant = applies(ServantRetentionPolicyValue.RETAIN);
# Line 281  public class gnuPOA Line 281  public class gnuPOA
281      keys.addAll(aom.keySet());      keys.addAll(aom.keySet());
282    
283      byte[] key;      byte[] key;
284      activeObjectMap.Obj obj;      AOM.Obj obj;
285      boolean last;      boolean last;
286      for (int i = 0; i < keys.size(); i++)      for (int i = 0; i < keys.size(); i++)
287        {        {
# Line 445  public class gnuPOA Line 445  public class gnuPOA
445      required(ServantRetentionPolicyValue.RETAIN);      required(ServantRetentionPolicyValue.RETAIN);
446      required(IdAssignmentPolicyValue.SYSTEM_ID);      required(IdAssignmentPolicyValue.SYSTEM_ID);
447    
448      activeObjectMap.Obj exists = aom.findServant(a_servant);      AOM.Obj exists = aom.findServant(a_servant);
449    
450      if (exists != null)      if (exists != null)
451        {        {
# Line 464  public class gnuPOA Line 464  public class gnuPOA
464          // activations.          // activations.
465        }        }
466    
467      byte[] object_key = activeObjectMap.getFreeId();      byte[] object_key = AOM.getFreeId();
468      servantDelegate delegate = new servantDelegate(a_servant, this, object_key);      ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this, object_key);
469      connectDelegate(object_key, delegate);      connectDelegate(object_key, delegate);
470      return object_key;      return object_key;
471    }    }
# Line 514  public class gnuPOA Line 514  public class gnuPOA
514      // already active.      // already active.
515      if (applies(IdUniquenessPolicyValue.UNIQUE_ID))      if (applies(IdUniquenessPolicyValue.UNIQUE_ID))
516        {        {
517          activeObjectMap.Obj sx = aom.findServant(a_servant, false);          AOM.Obj sx = aom.findServant(a_servant, false);
518          if (sx != null)          if (sx != null)
519            throw new ServantAlreadyActive();            throw new ServantAlreadyActive();
520        }        }
521    
522      activeObjectMap.Obj exists = aom.get(an_Object_Id);      AOM.Obj exists = aom.get(an_Object_Id);
523      if (exists != null)      if (exists != null)
524        {        {
525          if (exists.servant == null)          if (exists.servant == null)
# Line 537  public class gnuPOA Line 537  public class gnuPOA
537        }        }
538      else      else
539        {        {
540          servantDelegate delegate =          ServantDelegateImpl delegate =
541            new servantDelegate(a_servant, this, an_Object_Id);            new ServantDelegateImpl(a_servant, this, an_Object_Id);
542          connectDelegate(an_Object_Id, delegate);          connectDelegate(an_Object_Id, delegate);
543        }        }
544    }    }
# Line 556  public class gnuPOA Line 556  public class gnuPOA
556     * (the required servant manager may be missing).     * (the required servant manager may be missing).
557     */     */
558    private void locateServant(byte[] an_Object_Id, Servant a_servant,    private void locateServant(byte[] an_Object_Id, Servant a_servant,
559                               activeObjectMap.Obj exists, boolean use_forwarding                               AOM.Obj exists, boolean use_forwarding
560                              )                              )
561                        throws InternalError                        throws InternalError
562    {    {
# Line 582  public class gnuPOA Line 582  public class gnuPOA
582          throw new OBJ_ADAPTER("no servant", 4, CompletionStatus.COMPLETED_NO);          throw new OBJ_ADAPTER("no servant", 4, CompletionStatus.COMPLETED_NO);
583        }        }
584    
585      servantDelegate delegate =      ServantDelegateImpl delegate =
586        new servantDelegate(exists.servant, this, an_Object_Id);        new ServantDelegateImpl(exists.servant, this, an_Object_Id);
587      exists.servant._set_delegate(delegate);      exists.servant._set_delegate(delegate);
588      object.setServant(exists.servant);      object.setServant(exists.servant);
589      connect_to_orb(an_Object_Id, delegate.object);      connect_to_orb(an_Object_Id, delegate.object);
# Line 605  public class gnuPOA Line 605  public class gnuPOA
605    {    {
606      required(ServantRetentionPolicyValue.RETAIN);      required(ServantRetentionPolicyValue.RETAIN);
607    
608      activeObjectMap.Obj exists = aom.get(the_Object_Id);      AOM.Obj exists = aom.get(the_Object_Id);
609    
610      if (exists == null || exists.isDeactiveted())      if (exists == null || exists.isDeactiveted())
611        throw new ObjectNotActive();        throw new ObjectNotActive();
# Line 615  public class gnuPOA Line 615  public class gnuPOA
615      // Check if this servant is serving something else.      // Check if this servant is serving something else.
616      aom.remove(the_Object_Id);      aom.remove(the_Object_Id);
617    
618      activeObjectMap.Obj other = aom.findServant(exists.servant, false);      AOM.Obj other = aom.findServant(exists.servant, false);
619    
620      boolean remaining = other != null;      boolean remaining = other != null;
621    
# Line 643  public class gnuPOA Line 643  public class gnuPOA
643                                          throws WrongPolicy                                          throws WrongPolicy
644    {    {
645      required(IdAssignmentPolicyValue.SYSTEM_ID);      required(IdAssignmentPolicyValue.SYSTEM_ID);
646      return create_reference_with_id(activeObjectMap.getFreeId(), a_repository_id);      return create_reference_with_id(AOM.getFreeId(), a_repository_id);
647    }    }
648    
649    /**    /**
# Line 672  public class gnuPOA Line 672  public class gnuPOA
672        ids = new String[] { a_repository_id };        ids = new String[] { a_repository_id };
673    
674      // Check maybe such object is already activated.      // Check maybe such object is already activated.
675      activeObjectMap.Obj e = aom.get(an_object_id);      AOM.Obj e = aom.get(an_object_id);
676    
677      Servant servant;      Servant servant;
678      if (e == null)      if (e == null)
# Line 847  public class gnuPOA Line 847  public class gnuPOA
847        return m_poa_id;        return m_poa_id;
848      else      else
849        {        {
850          cdrBufOutput buffer = new cdrBufOutput();          BufferedCdrOutput buffer = new BufferedCdrOutput();
851          POA p = this;          POA p = this;
852          while (p != null)          while (p != null)
853            {            {
# Line 874  public class gnuPOA Line 874  public class gnuPOA
874    {    {
875      required(ServantRetentionPolicyValue.RETAIN);      required(ServantRetentionPolicyValue.RETAIN);
876    
877      activeObjectMap.Obj ref = aom.get(the_Object_Id);      AOM.Obj ref = aom.get(the_Object_Id);
878      if (ref == null)      if (ref == null)
879        throw new ObjectNotActive();        throw new ObjectNotActive();
880      else      else
# Line 897  public class gnuPOA Line 897  public class gnuPOA
897    {    {
898      if (applies(ServantRetentionPolicyValue.RETAIN))      if (applies(ServantRetentionPolicyValue.RETAIN))
899        {        {
900          activeObjectMap.Obj ref = aom.get(the_Object_Id);          AOM.Obj ref = aom.get(the_Object_Id);
901          if (ref == null || ref.isDeactiveted())          if (ref == null || ref.isDeactiveted())
902            {            {
903              if (default_servant != null)              if (default_servant != null)
# Line 932  public class gnuPOA Line 932  public class gnuPOA
932    public byte[] reference_to_id(org.omg.CORBA.Object the_Object)    public byte[] reference_to_id(org.omg.CORBA.Object the_Object)
933                           throws WrongAdapter, WrongPolicy                           throws WrongAdapter, WrongPolicy
934    {    {
935      activeObjectMap.Obj ref = aom.findObject(the_Object);      AOM.Obj ref = aom.findObject(the_Object);
936      if (ref == null)      if (ref == null)
937        throw new WrongAdapter();        throw new WrongAdapter();
938      return ref.key;      return ref.key;
# Line 958  public class gnuPOA Line 958  public class gnuPOA
958    {    {
959      if (applies(ServantRetentionPolicyValue.RETAIN))      if (applies(ServantRetentionPolicyValue.RETAIN))
960        {        {
961          activeObjectMap.Obj ref = aom.findObject(the_Object);          AOM.Obj ref = aom.findObject(the_Object);
962          if (ref == null)          if (ref == null)
963            throw new WrongAdapter();            throw new WrongAdapter();
964          else if (ref.isDeactiveted() || ref.servant == null)          else if (ref.isDeactiveted() || ref.servant == null)
# Line 1017  public class gnuPOA Line 1017  public class gnuPOA
1017          )          )
1018         )         )
1019        {        {
1020          activeObjectMap.Obj ref = null;          AOM.Obj ref = null;
1021          if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))          if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
1022            ref = aom.findServant(the_Servant);            ref = aom.findServant(the_Servant);
1023          if (ref == null &&          if (ref == null &&
# Line 1071  public class gnuPOA Line 1071  public class gnuPOA
1071    {    {
1072      required(ServantRetentionPolicyValue.RETAIN);      required(ServantRetentionPolicyValue.RETAIN);
1073    
1074      activeObjectMap.Obj exists = null;      AOM.Obj exists = null;
1075    
1076      if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))      if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
1077        exists = aom.findServant(the_Servant);        exists = aom.findServant(the_Servant);
# Line 1098  public class gnuPOA Line 1098  public class gnuPOA
1098        {        {
1099          checkDiscarding();          checkDiscarding();
1100    
1101          byte[] object_key = activeObjectMap.getFreeId();          byte[] object_key = AOM.getFreeId();
1102    
1103          servantDelegate delegate =          ServantDelegateImpl delegate =
1104            new servantDelegate(the_Servant, this, object_key);            new ServantDelegateImpl(the_Servant, this, object_key);
1105          connectDelegate(object_key, delegate);          connectDelegate(object_key, delegate);
1106    
1107          return delegate.object;          return delegate.object;
# Line 1126  public class gnuPOA Line 1126  public class gnuPOA
1126     * under the forwarding exception (for remote client). Otherwise, the     * under the forwarding exception (for remote client). Otherwise, the
1127     * request is internally redirected (for local invocation).     * request is internally redirected (for local invocation).
1128     */     */
1129    private Servant incarnate(activeObjectMap.Obj x, byte[] object_key,    private Servant incarnate(AOM.Obj x, byte[] object_key,
1130                              Servant a_servant, boolean use_forwarding                              Servant a_servant, boolean use_forwarding
1131                             )                             )
1132    {    {
# Line 1328  public class gnuPOA Line 1328  public class gnuPOA
1328      keys.addAll(aom.keySet());      keys.addAll(aom.keySet());
1329    
1330      byte[] key;      byte[] key;
1331      activeObjectMap.Obj obj;      AOM.Obj obj;
1332      for (int i = 0; i < keys.size(); i++)      for (int i = 0; i < keys.size(); i++)
1333        {        {
1334          key = (byte[]) keys.get(i);          key = (byte[]) keys.get(i);
# Line 1433  public class gnuPOA Line 1433  public class gnuPOA
1433     * Connect the given delegate under the given key, also calling     * Connect the given delegate under the given key, also calling
1434     * incarnate.     * incarnate.
1435     */     */
1436    private void connectDelegate(byte[] object_key, servantDelegate delegate)    private void connectDelegate(byte[] object_key, ServantDelegateImpl delegate)
1437    {    {
1438      aom.add(delegate);      aom.add(delegate);
1439      connect_to_orb(object_key, delegate.object);      connect_to_orb(object_key, delegate.object);
# Line 1517  public class gnuPOA Line 1517  public class gnuPOA
1517    /**    /**
1518     * Recursively searches for the given object in the POA tree.     * Recursively searches for the given object in the POA tree.
1519     */     */
1520    public activeObjectMap.Obj findObject(org.omg.CORBA.Object object)    public AOM.Obj findObject(org.omg.CORBA.Object object)
1521    {    {
1522      activeObjectMap.Obj h = aom.findObject(object);      AOM.Obj h = aom.findObject(object);
1523      if (h != null)      if (h != null)
1524        return h;        return h;
1525      else      else
# Line 1533  public class gnuPOA Line 1533  public class gnuPOA
1533        }        }
1534      return h;      return h;
1535    }    }
1536      
1537    /**    /**
1538     * Recursively searches for the given key in the POA tree.     * Recursively searches for the given key in the POA tree.
1539     * @param ior_key the key, ecapsulating both object     * @param ior_key the key, ecapsulating both object
1540     * and poa ids.     * and poa ids.
1541     * @return     * @return
1542     */     */
1543    public activeObjectMap.Obj findKey(byte[] object_id, byte[] poa_id)    public AOM.Obj findKey(byte[] object_id, byte[] poa_id)
1544    {    {
1545      activeObjectMap.Obj h = null;      AOM.Obj h = null;
1546      if (Arrays.equals(poa_id, id()))      if (Arrays.equals(poa_id, id()))
1547        h = aom.get(object_id);        h = aom.get(object_id);
1548      if (h != null)      if (h != null)
# Line 1563  public class gnuPOA Line 1563  public class gnuPOA
1563     * Parses the given key, extracts poa and object id and searches     * Parses the given key, extracts poa and object id and searches
1564     * for such reference.     * for such reference.
1565     */     */
1566    public activeObjectMap.Obj findIorKey(byte[] ior_key)    public AOM.Obj findIorKey(byte[] ior_key)
1567    {    {
1568      cdrBufInput in = new cdrBufInput(ior_key);      BufferredCdrInput in = new BufferredCdrInput(ior_key);
1569      int signature = in.read_long();      int signature = in.read_long();
1570      if (signature != SIGNATURE)      if (signature != SIGNATURE)
1571        return null;        return null;
# Line 1582  public class gnuPOA Line 1582  public class gnuPOA
1582     */     */
1583    public byte[] toIORKey(byte[] object_id)    public byte[] toIORKey(byte[] object_id)
1584    {    {
1585      cdrBufOutput buffer = new cdrBufOutput();      BufferedCdrOutput buffer = new BufferedCdrOutput();
1586      buffer.write_long(SIGNATURE);      buffer.write_long(SIGNATURE);
1587      buffer.write_sequence(object_id);      buffer.write_sequence(object_id);
1588      buffer.write_sequence(id());      buffer.write_sequence(id());
# Line 1600  public class gnuPOA Line 1600  public class gnuPOA
1600     */     */
1601    public byte[] idFormIor(byte[] ior_key)    public byte[] idFormIor(byte[] ior_key)
1602    {    {
1603      cdrBufInput in = new cdrBufInput(ior_key);      BufferredCdrInput in = new BufferredCdrInput(ior_key);
1604      int signature = in.read_long();      int signature = in.read_long();
1605      if (signature != SIGNATURE)      if (signature != SIGNATURE)
1606        return null;        return null;
# Line 1612  public class gnuPOA Line 1612  public class gnuPOA
1612      else      else
1613        return null;        return null;
1614    }    }
 }  
1615      
1616      /**
1617       * Recursively searches for the given servant in the POA tree.
1618       */
1619      public AOM.Obj findServant(Servant servant)
1620      {
1621        AOM.Obj h = aom.findServant(servant);
1622        if (h != null)
1623          return h;
1624        else
1625          {
1626            for (int i = 0; i < children.size(); i++)
1627              {
1628                h = ((gnuPOA) children.get(i)).findServant(servant);
1629                if (h != null)
1630                  return h;
1631              }
1632          }
1633        return h;
1634      }  
1635    }

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26