KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > ior > iiop > JavaSerializationComponent


1 /**
2  * @(#)JavaSerializationComponent.java 1.2 04/06/07
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.impl.ior.iiop;
8
9 import org.omg.CORBA_2_3.portable.OutputStream JavaDoc;
10
11 import com.sun.corba.se.impl.orbutil.ORBConstants;
12 import com.sun.corba.se.impl.orbutil.ORBUtility;
13 import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
14
15 import com.sun.corba.se.spi.orb.ORB;
16 import com.sun.corba.se.spi.ior.TaggedComponentBase;
17
18 /**
19  * Tagged component that contains a value that indicates the Java
20  * serialization version supported by the ORB.
21  *
22  * ORB Java serialization uses IIOP as the transport protocol, but uses
23  * Java serialization mechanism and its accompanying encodings, instead
24  * of IIOP CDR serialization mechanism. Java serialization is generally
25  * observed to be faster than CDR.
26  */

27 public class JavaSerializationComponent extends TaggedComponentBase {
28
29     private byte version;
30
31     private static JavaSerializationComponent singleton;
32
33     public static JavaSerializationComponent singleton() {
34     if (singleton == null) {
35         synchronized (JavaSerializationComponent.class) {
36         singleton =
37             new JavaSerializationComponent(Message.JAVA_ENC_VERSION);
38         }
39     }
40     return singleton;
41     }
42
43     public JavaSerializationComponent(byte version) {
44         this.version = version;
45     }
46
47     public byte javaSerializationVersion() {
48     return this.version;
49     }
50
51     public void writeContents(OutputStream JavaDoc os) {
52         os.write_octet(version);
53     }
54     
55     public int getId() {
56     return ORBConstants.TAG_JAVA_SERIALIZATION_ID;
57     }
58
59     public boolean equals(Object JavaDoc obj) {
60     if (!(obj instanceof JavaSerializationComponent)) {
61         return false;
62     }
63     JavaSerializationComponent other = (JavaSerializationComponent) obj;
64     return this.version == other.version;
65     }
66
67     public int hashCode() {
68     return this.version;
69     }
70 }
71
Popular Tags