KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)LocateReplyMessage_1_1.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 import com.sun.corba.se.impl.encoding.CDRInputStream;
21
22 import com.sun.corba.se.spi.logging.CORBALogDomains ;
23 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
24
25 /**
26  * This implements the GIOP 1.1 LocateReply header.
27  *
28  * @author Ram Jeyaraman 05/14/2000
29  * @version 1.0
30  */

31
32 public final class LocateReplyMessage_1_1 extends Message_1_1
33         implements LocateReplyMessage {
34
35     // Instance variables
36

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

44     LocateReplyMessage_1_1(ORB orb) {
45         this.orb = orb;
46     }
47
48     LocateReplyMessage_1_1(ORB orb, int _request_id,
49             int _reply_status, IOR _ior) {
50         super(Message.GIOPBigMagic, GIOPVersion.V1_1, FLAG_NO_FRAG_BIG_ENDIAN,
51             Message.GIOPLocateReply, 0);
52         this.orb = orb;
53         request_id = _request_id;
54         reply_status = _reply_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.reply_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.reply_status = istream.read_long();
86         isValidReplyStatus(this.reply_status); // raises exception on error
87

88         // The code below reads the reply body if status is OBJECT_FORWARD
89
if (this.reply_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. SystemException or
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.reply_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_1
124
Popular Tags