1. /*
  2. * @(#)ORBVersionServiceContext.java 1.10 04/06/21
  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.spi.servicecontext;
  8. import org.omg.CORBA.SystemException;
  9. import org.omg.CORBA_2_3.portable.InputStream ;
  10. import org.omg.CORBA_2_3.portable.OutputStream ;
  11. import com.sun.corba.se.spi.orb.ORBVersion ;
  12. import com.sun.corba.se.spi.orb.ORBVersionFactory ;
  13. import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
  14. import com.sun.corba.se.spi.servicecontext.ServiceContext ;
  15. import com.sun.corba.se.impl.orbutil.ORBConstants ;
  16. public class ORBVersionServiceContext extends ServiceContext {
  17. public ORBVersionServiceContext( )
  18. {
  19. version = ORBVersionFactory.getORBVersion() ;
  20. }
  21. public ORBVersionServiceContext( ORBVersion ver )
  22. {
  23. this.version = ver ;
  24. }
  25. public ORBVersionServiceContext(InputStream is, GIOPVersion gv)
  26. {
  27. super(is, gv) ;
  28. // pay particular attention to where the version is being read from!
  29. // is contains an encapsulation, ServiceContext reads off the
  30. // encapsulation and leaves the pointer in the variable "in",
  31. // which points to the long value.
  32. version = ORBVersionFactory.create( in ) ;
  33. }
  34. // Required SERVICE_CONTEXT_ID and getId definitions
  35. public static final int SERVICE_CONTEXT_ID = ORBConstants.TAG_ORB_VERSION ;
  36. public int getId() { return SERVICE_CONTEXT_ID ; }
  37. public void writeData( OutputStream os ) throws SystemException
  38. {
  39. version.write( os ) ;
  40. }
  41. public ORBVersion getVersion()
  42. {
  43. return version ;
  44. }
  45. // current ORB Version
  46. private ORBVersion version = ORBVersionFactory.getORBVersion() ;
  47. public String toString()
  48. {
  49. return "ORBVersionServiceContext[ version=" + version + " ]" ;
  50. }
  51. }