LocateReplyMessage_1_0.java revision 608:7e06bf1dcb09
1236592Sobrien/* 2236592Sobrien * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. 3287598Sbdrewery * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4236592Sobrien * 5236592Sobrien * This code is free software; you can redistribute it and/or modify it 6236592Sobrien * under the terms of the GNU General Public License version 2 only, as 7236592Sobrien * published by the Free Software Foundation. Oracle designates this 8236592Sobrien * particular file as subject to the "Classpath" exception as provided 9236592Sobrien * by Oracle in the LICENSE file that accompanied this code. 10236592Sobrien * 11236592Sobrien * This code is distributed in the hope that it will be useful, but WITHOUT 12236592Sobrien * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13236592Sobrien * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14236592Sobrien * version 2 for more details (a copy is included in the LICENSE file that 15236592Sobrien * accompanied this code). 16236592Sobrien * 17236592Sobrien * You should have received a copy of the GNU General Public License version 18236592Sobrien * 2 along with this work; if not, write to the Free Software Foundation, 19236592Sobrien * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20236592Sobrien * 21236592Sobrien * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22236592Sobrien * or visit www.oracle.com if you need additional information or have any 23236592Sobrien * questions. 24236592Sobrien */ 25236592Sobrien 26236592Sobrienpackage com.sun.corba.se.impl.protocol.giopmsgheaders; 27236592Sobrien 28236592Sobrienimport org.omg.CORBA.INTERNAL; 29236592Sobrienimport org.omg.CORBA.CompletionStatus; 30236592Sobrienimport org.omg.CORBA.SystemException; 31287598Sbdrewery 32236592Sobrienimport com.sun.corba.se.spi.ior.IOR; 33236592Sobrienimport com.sun.corba.se.spi.ior.IORFactories; 34236592Sobrien 35287598Sbdreweryimport com.sun.corba.se.spi.orb.ORB; 36236592Sobrien 37236592Sobrienimport com.sun.corba.se.spi.ior.iiop.GIOPVersion; 38287598Sbdrewery 39236592Sobrienimport com.sun.corba.se.impl.encoding.CDRInputStream; 40236592Sobrien 41236592Sobrienimport com.sun.corba.se.spi.logging.CORBALogDomains ; 42287598Sbdreweryimport com.sun.corba.se.impl.logging.ORBUtilSystemException ; 43236592Sobrien 44236592Sobrien/** 45287598Sbdrewery * This implements the GIOP 1.0 LocateReply header. 46236592Sobrien * 47236592Sobrien * @author Ram Jeyaraman 05/14/2000 48236592Sobrien */ 49287598Sbdrewery 50236592Sobrienpublic final class LocateReplyMessage_1_0 extends Message_1_0 51236592Sobrien implements LocateReplyMessage { 52287598Sbdrewery 53236592Sobrien // Instance variables 54236592Sobrien 55236592Sobrien private ORB orb = null; 56287598Sbdrewery private int request_id = (int) 0; 57236592Sobrien private int locate_status = (int) 0; 58236592Sobrien private IOR ior = null; 59287598Sbdrewery 60236592Sobrien // Constructors 61236592Sobrien 62236592Sobrien LocateReplyMessage_1_0(ORB orb) { 63287598Sbdrewery this.orb = orb; 64236592Sobrien } 65236592Sobrien 66287598Sbdrewery LocateReplyMessage_1_0(ORB orb, int _request_id, 67236592Sobrien int _locate_status, IOR _ior) { 68236592Sobrien super(Message.GIOPBigMagic, false, Message.GIOPLocateReply, 0); 69236592Sobrien this.orb = orb; 70287598Sbdrewery request_id = _request_id; 71236592Sobrien locate_status = _locate_status; 72 ior = _ior; 73 } 74 75 // Accessor methods 76 77 public int getRequestId() { 78 return this.request_id; 79 } 80 81 public int getReplyStatus() { 82 return this.locate_status; 83 } 84 85 public short getAddrDisposition() { 86 return KeyAddr.value; 87 } 88 89 public SystemException getSystemException(String message) { 90 return null; // 1.0 LocateReply body does not contain SystemException 91 } 92 93 public IOR getIOR() { 94 return this.ior; 95 } 96 97 // IO methods 98 99 public void read(org.omg.CORBA.portable.InputStream istream) { 100 super.read(istream); 101 this.request_id = istream.read_ulong(); 102 this.locate_status = istream.read_long(); 103 isValidReplyStatus(this.locate_status); // raises exception on error 104 105 // The code below reads the reply body if status is OBJECT_FORWARD 106 if (this.locate_status == OBJECT_FORWARD) { 107 CDRInputStream cdr = (CDRInputStream) istream; 108 this.ior = IORFactories.makeIOR( cdr ) ; 109 } 110 } 111 112 // Note, this writes only the header information. 113 // IOR may be written afterwards into the reply mesg body. 114 public void write(org.omg.CORBA.portable.OutputStream ostream) { 115 super.write(ostream); 116 ostream.write_ulong(this.request_id); 117 ostream.write_long(this.locate_status); 118 } 119 120 // Static methods 121 122 public static void isValidReplyStatus(int replyStatus) { 123 switch (replyStatus) { 124 case UNKNOWN_OBJECT : 125 case OBJECT_HERE : 126 case OBJECT_FORWARD : 127 break; 128 default : 129 ORBUtilSystemException localWrapper = ORBUtilSystemException.get( 130 CORBALogDomains.RPC_PROTOCOL ) ; 131 throw localWrapper.illegalReplyStatus( CompletionStatus.COMPLETED_MAYBE); 132 } 133 } 134 135 public void callback(MessageHandler handler) 136 throws java.io.IOException 137 { 138 handler.handleInput(this); 139 } 140} // class LocateReplyMessage_1_0 141