1. /*
  2. * @(#)OldPOAObjectKeyTemplate.java 1.9 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.impl.ior;
  8. import org.omg.CORBA.INTERNAL ;
  9. import org.omg.CORBA.OctetSeqHolder ;
  10. import org.omg.CORBA_2_3.portable.InputStream ;
  11. import org.omg.CORBA_2_3.portable.OutputStream ;
  12. import com.sun.corba.se.spi.orb.ORB ;
  13. import com.sun.corba.se.spi.orb.ORBVersion ;
  14. import com.sun.corba.se.spi.orb.ORBVersionFactory ;
  15. import com.sun.corba.se.impl.ior.ObjectKeyFactoryImpl ;
  16. /**
  17. * @author Ken Cavanaugh
  18. */
  19. public final class OldPOAObjectKeyTemplate extends OldObjectKeyTemplateBase
  20. {
  21. /** This constructor reads the template ONLY from the stream
  22. */
  23. public OldPOAObjectKeyTemplate( ORB orb, int magic, int scid, InputStream is )
  24. {
  25. this( orb, magic, scid, is.read_long(), is.read_long(), is.read_long() ) ;
  26. }
  27. /** This constructor reads a complete ObjectKey (template and Id)
  28. * from the stream.
  29. */
  30. public OldPOAObjectKeyTemplate( ORB orb, int magic, int scid, InputStream is,
  31. OctetSeqHolder osh )
  32. {
  33. this( orb, magic, scid, is ) ;
  34. osh.value = readObjectKey( is ) ;
  35. }
  36. public OldPOAObjectKeyTemplate( ORB orb, int magic, int scid, int serverid,
  37. int orbid, int poaid)
  38. {
  39. super( orb, magic, scid, serverid,
  40. Integer.toString( orbid ),
  41. new ObjectAdapterIdNumber( poaid ) ) ;
  42. }
  43. public void writeTemplate(OutputStream os)
  44. {
  45. os.write_long( getMagic() ) ;
  46. os.write_long( getSubcontractId() ) ;
  47. os.write_long( getServerId() ) ;
  48. int orbid = Integer.parseInt( getORBId() ) ;
  49. os.write_long( orbid ) ;
  50. ObjectAdapterIdNumber oaid = (ObjectAdapterIdNumber)(getObjectAdapterId()) ;
  51. int poaid = oaid.getOldPOAId() ;
  52. os.write_long( poaid ) ;
  53. }
  54. public ORBVersion getORBVersion()
  55. {
  56. if (getMagic() == ObjectKeyFactoryImpl.JAVAMAGIC_OLD)
  57. return ORBVersionFactory.getOLD() ;
  58. else if (getMagic() == ObjectKeyFactoryImpl.JAVAMAGIC_NEW)
  59. return ORBVersionFactory.getNEW() ;
  60. else
  61. throw new INTERNAL() ;
  62. }
  63. }