KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > spi > orb > ORBVersionFactory


1 /*
2  * @(#)ORBVersionFactory.java 1.13 04/03/01
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.spi.orb ;
9
10 import com.sun.corba.se.spi.orb.ORBVersion ;
11 import com.sun.corba.se.impl.orb.ORBVersionImpl ;
12 import org.omg.CORBA.portable.InputStream JavaDoc ;
13 import org.omg.CORBA.INTERNAL JavaDoc ;
14
15 public class ORBVersionFactory {
16     private ORBVersionFactory() {} ;
17
18     public static ORBVersion getFOREIGN()
19     {
20     return ORBVersionImpl.FOREIGN ;
21     }
22
23     public static ORBVersion getOLD()
24     {
25     return ORBVersionImpl.OLD ;
26     }
27
28     public static ORBVersion getNEW()
29     {
30     return ORBVersionImpl.NEW ;
31     }
32
33     public static ORBVersion getJDK1_3_1_01()
34     {
35     return ORBVersionImpl.JDK1_3_1_01 ;
36     }
37
38     public static ORBVersion getNEWER()
39     {
40     return ORBVersionImpl.NEWER ;
41     }
42
43     public static ORBVersion getPEORB()
44     {
45     return ORBVersionImpl.PEORB ;
46     }
47
48     /** Return the current version of this ORB
49      */

50     public static ORBVersion getORBVersion()
51     {
52     return ORBVersionImpl.PEORB ;
53     }
54
55     public static ORBVersion create( InputStream JavaDoc is )
56     {
57     byte value = is.read_octet() ;
58     return byteToVersion( value ) ;
59     }
60
61     private static ORBVersion byteToVersion( byte value )
62     {
63     /* Throwing an exception here would cause this version to be
64     * incompatible with future versions of the ORB, to the point
65     * that this version could
66     * not even unmarshal objrefs from a newer version that uses
67     * extended versioning. Therefore, we will simply treat all
68     * unknown versions as the latest version.
69     if (value < 0)
70         throw new INTERNAL() ;
71     */

72
73     /**
74      * Update: If we treat all unknown versions as the latest version
75      * then when we send an IOR with a PEORB version to an ORB that
76      * doesn't know the PEORB version it will treat it as whatever
77      * its idea of the latest version is. Then, if that IOR is
78      * sent back to the server and compared with the original
79      * the equality check will fail because the versions will be
80      * different.
81      *
82      * Instead, just capture the version bytes.
83      */

84
85     switch (value) {
86         case ORBVersion.FOREIGN : return ORBVersionImpl.FOREIGN ;
87         case ORBVersion.OLD : return ORBVersionImpl.OLD ;
88         case ORBVersion.NEW : return ORBVersionImpl.NEW ;
89             case ORBVersion.JDK1_3_1_01: return ORBVersionImpl.JDK1_3_1_01 ;
90         case ORBVersion.NEWER : return ORBVersionImpl.NEWER ;
91         case ORBVersion.PEORB : return ORBVersionImpl.PEORB ;
92         default : return new ORBVersionImpl(value);
93     }
94     }
95 }
96
Popular Tags