KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > protocol > giopmsgheaders > LocateReplyMessage_1_0


1 /*
2  * @(#)LocateReplyMessage_1_0.java 1.13 03/12/19
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.impl.protocol.giopmsgheaders;
9
10 import org.omg.CORBA.INTERNAL JavaDoc;
11 import org.omg.CORBA.CompletionStatus JavaDoc;
12 import org.omg.CORBA.SystemException JavaDoc;
13
14 import com.sun.corba.se.spi.ior.IOR;
15 import com.sun.corba.se.spi.ior.IORFactories;
16
17 import com.sun.corba.se.spi.orb.ORB;
18
19 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
20
21 import com.sun.corba.se.impl.encoding.CDRInputStream;
22
23 import com.sun.corba.se.spi.logging.CORBALogDomains ;
24 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
25
26 /**
27  * This implements the GIOP 1.0 LocateReply header.
28  *
29  * @author Ram Jeyaraman 05/14/2000
30  * @version 1.0
31  */

32
33 public final class LocateReplyMessage_1_0 extends Message_1_0
34         implements LocateReplyMessage {
35
36     // Instance variables
37

38     private ORB orb = null;
39     private int request_id = (int) 0;
40     private int locate_status = (int) 0;
41     private IOR ior = null;
42
43     // Constructors
44

45     LocateReplyMessage_1_0(ORB orb) {
46         this.orb = orb;
47     }
48
49     LocateReplyMessage_1_0(ORB orb, int _request_id,
50             int _locate_status, IOR _ior) {
51         super(Message.GIOPBigMagic, false, Message.GIOPLocateReply, 0);
52         this.orb = orb;
53         request_id = _request_id;
54         locate_status = _locate_status;
55         ior = _ior;
56     }
57
58     // Accessor methods
59

60     public int getRequestId() {
61         return this.request_id;
62     }
63
64     public int getReplyStatus() {
65         return this.locate_status;
66     }
67
68     public short getAddrDisposition() {
69         return KeyAddr.value;
70     }
71         
72     public SystemException JavaDoc getSystemException(String JavaDoc message) {
73         return null; // 1.0 LocateReply body does not contain SystemException
74
}
75
76     public IOR getIOR() {
77         return this.ior;
78     }
79
80     // IO methods
81

82     public void read(org.omg.CORBA.portable.InputStream JavaDoc istream) {
83         super.read(istream);
84         this.request_id = istream.read_ulong();
85         this.locate_status = istream.read_long();
86         isValidReplyStatus(this.locate_status); // raises exception on error
87

88         // The code below reads the reply body if status is OBJECT_FORWARD
89
if (this.locate_status == OBJECT_FORWARD) {
90             CDRInputStream cdr = (CDRInputStream) istream;
91         this.ior = IORFactories.makeIOR( cdr ) ;
92         }
93     }
94
95     // Note, this writes only the header information.
96
// IOR may be written afterwards into the reply mesg body.
97
public void write(org.omg.CORBA.portable.OutputStream JavaDoc ostream) {
98         super.write(ostream);
99         ostream.write_ulong(this.request_id);
100         ostream.write_long(this.locate_status);
101     }
102
103     // Static methods
104

105     public static void isValidReplyStatus(int replyStatus) {
106         switch (replyStatus) {
107         case UNKNOWN_OBJECT :
108         case OBJECT_HERE :
109         case OBJECT_FORWARD :
110             break;
111         default :
112         ORBUtilSystemException localWrapper = ORBUtilSystemException.get(
113         CORBALogDomains.RPC_PROTOCOL ) ;
114         throw localWrapper.illegalReplyStatus( CompletionStatus.COMPLETED_MAYBE);
115         }
116     }
117
118     public void callback(MessageHandler handler)
119         throws java.io.IOException JavaDoc
120     {
121         handler.handleInput(this);
122     }
123 } // class LocateReplyMessage_1_0
124
Popular Tags