ORBVersionServiceContext.java revision 608:7e06bf1dcb09
1121054Semax/*
2121054Semax * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
3189462Semax * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4189462Semax *
5189462Semax * This code is free software; you can redistribute it and/or modify it
6189462Semax * under the terms of the GNU General Public License version 2 only, as
7121054Semax * published by the Free Software Foundation.  Oracle designates this
8121054Semax * particular file as subject to the "Classpath" exception as provided
9121054Semax * by Oracle in the LICENSE file that accompanied this code.
10121054Semax *
11121054Semax * This code is distributed in the hope that it will be useful, but WITHOUT
12121054Semax * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13121054Semax * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14121054Semax * version 2 for more details (a copy is included in the LICENSE file that
15121054Semax * accompanied this code).
16121054Semax *
17121054Semax * You should have received a copy of the GNU General Public License version
18121054Semax * 2 along with this work; if not, write to the Free Software Foundation,
19121054Semax * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20121054Semax *
21121054Semax * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22121054Semax * or visit www.oracle.com if you need additional information or have any
23121054Semax * questions.
24121054Semax */
25121054Semax
26121054Semaxpackage com.sun.corba.se.spi.servicecontext;
27121054Semax
28121054Semaximport org.omg.CORBA.SystemException;
29121054Semaximport org.omg.CORBA_2_3.portable.InputStream ;
30121054Semaximport org.omg.CORBA_2_3.portable.OutputStream ;
31121054Semax
32121054Semaximport com.sun.corba.se.spi.orb.ORBVersion ;
33121054Semaximport com.sun.corba.se.spi.orb.ORBVersionFactory ;
34121054Semax
35121054Semaximport com.sun.corba.se.spi.ior.iiop.GIOPVersion;
36121054Semaximport com.sun.corba.se.spi.servicecontext.ServiceContext ;
37121054Semaximport com.sun.corba.se.impl.orbutil.ORBConstants ;
38121054Semax
39121054Semaxpublic class ORBVersionServiceContext extends ServiceContext {
40189462Semax
41121054Semax    public ORBVersionServiceContext( )
42191388Semax    {
43121054Semax        version = ORBVersionFactory.getORBVersion() ;
44189462Semax    }
45121054Semax
46189462Semax    public ORBVersionServiceContext( ORBVersion ver )
47121054Semax    {
48121054Semax        this.version = ver ;
49121054Semax    }
50191388Semax
51121054Semax    public ORBVersionServiceContext(InputStream is, GIOPVersion gv)
52121054Semax    {
53121054Semax        super(is, gv) ;
54121054Semax        // pay particular attention to where the version is being read from!
55143767Semax        // is contains an encapsulation, ServiceContext reads off the
56121054Semax        // encapsulation and leaves the pointer in the variable "in",
57121054Semax        // which points to the long value.
58121054Semax
59121054Semax        version = ORBVersionFactory.create( in ) ;
60121054Semax    }
61121054Semax
62213042Semax    // Required SERVICE_CONTEXT_ID and getId definitions
63213042Semax    public static final int SERVICE_CONTEXT_ID = ORBConstants.TAG_ORB_VERSION ;
64213042Semax    public int getId() { return SERVICE_CONTEXT_ID ; }
65213042Semax
66121054Semax    public void writeData( OutputStream os ) throws SystemException
67121054Semax    {
68121054Semax        version.write( os ) ;
69121054Semax    }
70121054Semax
71121054Semax    public ORBVersion getVersion()
72121054Semax    {
73121054Semax        return version ;
74121054Semax    }
75121054Semax
76121054Semax    // current ORB Version
77121054Semax    private ORBVersion version = ORBVersionFactory.getORBVersion() ;
78121054Semax
79121054Semax    public String toString()
80121054Semax    {
81121054Semax        return "ORBVersionServiceContext[ version=" + version + " ]" ;
82121054Semax    }
83121054Semax}
84121054Semax