1. /*
  2. * @(#)WireObjectKeyTemplate.java 1.17 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. //Source file: J:/ws/serveractivation/src/share/classes/com.sun.corba.se.internal.ior/WireObjectKey.java
  8. package com.sun.corba.se.internal.ior;
  9. import com.sun.corba.se.internal.core.ORBVersion ;
  10. import com.sun.corba.se.internal.core.ORBVersionImpl ;
  11. import com.sun.corba.se.internal.orbutil.SubcontractList ;
  12. import com.sun.corba.se.internal.orbutil.MinorCodes ;
  13. import com.sun.corba.se.internal.ior.ObjectKeyTemplate ;
  14. import com.sun.corba.se.internal.ior.ObjectId ;
  15. import com.sun.corba.se.internal.iiop.CDRInputStream ;
  16. import org.omg.CORBA_2_3.portable.OutputStream ;
  17. import org.omg.CORBA_2_3.portable.InputStream ;
  18. import org.omg.CORBA.CompletionStatus ;
  19. import org.omg.CORBA.BAD_OPERATION ;
  20. import org.omg.CORBA.ORB ;
  21. import org.omg.CORBA.OctetSeqHolder ;
  22. /**
  23. * @author
  24. */
  25. public class WireObjectKeyTemplate implements ObjectKeyTemplate
  26. {
  27. public boolean equals( Object obj )
  28. {
  29. if (obj == null)
  30. return false ;
  31. return obj instanceof WireObjectKeyTemplate ;
  32. }
  33. private byte[] getId( InputStream is )
  34. {
  35. CDRInputStream cis = (CDRInputStream)is ;
  36. int len = cis.getBufferLength() ;
  37. byte[] result = new byte[ len ] ;
  38. cis.read_octet_array( result, 0, len ) ;
  39. return result ;
  40. }
  41. public WireObjectKeyTemplate( InputStream is, OctetSeqHolder osh )
  42. {
  43. osh.value = getId( is ) ;
  44. }
  45. public void write( ObjectId id, OutputStream os )
  46. {
  47. byte[] key = id.getId() ;
  48. os.write_octet_array( key, 0, key.length ) ;
  49. }
  50. public int getSubcontractId()
  51. {
  52. return SubcontractList.defaultSubcontract ;
  53. }
  54. /** While it might make sense to throw an exception here, this causes
  55. * problems since we need to check whether unusual object references
  56. * are local or not. It seems that the easiest way to handle this is
  57. * to return an invalid server id.
  58. */
  59. public int getServerId()
  60. {
  61. return -1 ;
  62. // throw new BAD_OPERATION( MinorCodes.SERVER_ID_NOT_AVAILABLE,
  63. // CompletionStatus.COMPLETED_NO ) ;
  64. }
  65. /** Adapter ID is not available, since our
  66. * ORB did not implement the object carrying this key.
  67. */
  68. public byte[] getAdapterId( ORB orb )
  69. {
  70. throw new BAD_OPERATION( MinorCodes.ADAPTER_ID_NOT_AVAILABLE,
  71. CompletionStatus.COMPLETED_NO ) ;
  72. }
  73. public ORBVersion getORBVersion()
  74. {
  75. return ORBVersionImpl.FOREIGN ;
  76. }
  77. }