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