FileDocCategorySizeDatePackage
ServiceContext.javaAPI DocJava SE 5 API3836Fri Aug 26 14:54:40 BST 2005com.sun.corba.se.spi.servicecontext

ServiceContext

public abstract class ServiceContext extends Object
Base class for all ServiceContext classes. There is a derived ServiceContext class for each service context that the ORB supports. Each subclass encapsulates the representation of the service context and provides any needed methods for manipulating the service context. Each subclass must provide the following members:

    a public static final int SERVICE_CONTEXT_ID that gives the OMG (or other) defined id for the service context. This is needed for the registration mechanism defined in ServiceContexts. OMG defined service context ids are taken from section 13.6.7 of ptc/98-12-04.
  • a public constructor that takes an InputStream as its argument.
  • Appropriate definitions of getId() and writeData(). getId() must return SERVICE_CONTEXT_ID.

The subclass can be constructed either directly from the service context representation, or by reading the representation from an input stream. These cases are needed when the service context is created and written to the request or reply, and when the service context is read from the received request or reply.

Fields Summary
protected InputStream
in
in is the stream containing the service context representation. It is constructed by the stream constructor, and available for use in the subclass stream constructor.
Constructors Summary
protected ServiceContext()
Simple default constructor used when subclass is constructed from its representation.

 
protected ServiceContext(InputStream s, GIOPVersion gv)
Stream constructor used when subclass is constructed from an InputStream. This constructor must be called by super( stream ) in the subclass. After this constructor completes, the service context representation can be read from in. Note that the service context id has been consumed from the input stream before this object is constructed.

        in = s;
    
Methods Summary
private voiddprint(java.lang.String msg)

	ORBUtility.dprint( this, msg ) ;
    
public abstract intgetId()
Returns Service context id. Must be overloaded in subclass.

public java.lang.StringtoString()


       
    
	return "ServiceContext[ id=" + getId() + " ]" ;
    
public voidwrite(org.omg.CORBA_2_3.portable.OutputStream s, com.sun.corba.se.spi.ior.iiop.GIOPVersion gv)
Write the service context to an output stream. This method must be used for writing the service context to a request or reply header.

        EncapsOutputStream os = new EncapsOutputStream( (ORB)(s.orb()), gv ) ;
        os.putEndian() ;
        writeData( os ) ;
        byte[] data = os.toByteArray() ;

        s.write_long(getId());
        s.write_long(data.length);
        s.write_octet_array(data, 0, data.length);
    
protected abstract voidwriteData(org.omg.CORBA_2_3.portable.OutputStream os)
Writes the data used to represent the subclasses service context into an encapsulation stream. Must be overloaded in subclass.