1. /*
  2. * @(#)POAObjectKeyTemplate.java 1.21 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. // @(#)POAObjectKeyTemplate.java 1.21 03/01/23
  8. package com.sun.corba.se.internal.ior;
  9. import com.sun.corba.se.ActivationIDL.POANameHelper ;
  10. import com.sun.corba.se.internal.iiop.CDRInputStream ;
  11. import com.sun.corba.se.internal.core.ORBVersion ;
  12. import com.sun.corba.se.internal.core.ORBVersionFactory ;
  13. import com.sun.corba.se.internal.ior.ObjectId ;
  14. import com.sun.corba.se.internal.ior.ObjectKeyFactory ;
  15. import com.sun.corba.se.internal.ior.POAId ;
  16. import org.omg.CORBA_2_3.portable.OutputStream ;
  17. import org.omg.CORBA.ORB ;
  18. import org.omg.CORBA.OctetSeqHolder ;
  19. import java.util.Iterator ;
  20. /**
  21. * @author
  22. */
  23. public final class POAObjectKeyTemplate extends NewObjectKeyTemplateBase
  24. {
  25. private String orbid ;
  26. private POAId poaid ;
  27. private byte[] adapterId ;
  28. public boolean equals( Object obj )
  29. {
  30. if (!super.equals( obj ))
  31. return false ;
  32. if (!(obj instanceof POAObjectKeyTemplate))
  33. return false ;
  34. POAObjectKeyTemplate other = (POAObjectKeyTemplate)obj ;
  35. return (orbid.equals( other.orbid )) && (poaid.equals( other.poaid )) ;
  36. }
  37. public byte[] getAdapterId( ORB orb )
  38. {
  39. return (byte[])(adapterId.clone()) ;
  40. }
  41. private byte[] computeAdapterId()
  42. {
  43. // write out serverid, orbid, poaid
  44. ByteBuffer buff = new ByteBuffer() ;
  45. buff.append( getServerId() ) ;
  46. buff.append( orbid ) ;
  47. buff.append( poaid.getNumLevels() ) ;
  48. Iterator iter = poaid.iterator() ;
  49. while (iter.hasNext()) {
  50. String comp = (String)(iter.next()) ;
  51. buff.append( comp ) ;
  52. }
  53. buff.trimToSize() ;
  54. return buff.toArray() ;
  55. }
  56. public POAObjectKeyTemplate( int magic, int scid, CDRInputStream is,
  57. OctetSeqHolder osh )
  58. {
  59. // Read server id from input stream for superclass constructor
  60. super( magic, scid, is.read_long() ) ;
  61. orbid = is.read_string() ;
  62. String[] temp = POANameHelper.read( is ) ;
  63. poaid = new POAIdArray( temp ) ;
  64. osh.value = readObjectKey( is ) ;
  65. setVersion( is ) ;
  66. adapterId = computeAdapterId() ;
  67. }
  68. /**
  69. * @param scid
  70. * @param serverid
  71. * @param orbid
  72. * @param poaid
  73. * @return
  74. * @exception
  75. * @author
  76. * @roseuid 3915F507004D
  77. */
  78. public POAObjectKeyTemplate( int scid, int serverid, String orbid,
  79. POAId poaid)
  80. {
  81. super( ObjectKeyTemplate.JAVAMAGIC_NEWER, scid, serverid ) ;
  82. this.orbid = orbid ;
  83. this.poaid = poaid ;
  84. setORBVersion( ORBVersionFactory.getORBVersion() ) ;
  85. adapterId = computeAdapterId() ;
  86. }
  87. /**
  88. * @param objectId
  89. * @param os
  90. * @return void
  91. * @exception
  92. * @author
  93. * @roseuid 3915FFEA00EB
  94. */
  95. public void write(OutputStream os)
  96. {
  97. os.write_long( getMagic() ) ;
  98. os.write_long( getSubcontractId() ) ;
  99. os.write_long( getServerId() ) ;
  100. os.write_string( orbid ) ;
  101. poaid.write( os ) ;
  102. }
  103. public String getORBId()
  104. {
  105. return orbid ;
  106. }
  107. public POAId getPOAId()
  108. {
  109. return poaid ;
  110. }
  111. }