Tue, 25 May 2010 15:52:11 -0700
6943119: Rebrand source copyright notices
Reviewed-by: darcy
duke@1 | 1 | /* |
ohair@158 | 2 | * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@158 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@158 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@158 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@158 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@158 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.corba.se.impl.protocol.giopmsgheaders; |
duke@1 | 27 | |
duke@1 | 28 | import org.omg.CORBA.INTERNAL; |
duke@1 | 29 | import org.omg.CORBA.CompletionStatus; |
duke@1 | 30 | import org.omg.CORBA.SystemException; |
duke@1 | 31 | |
duke@1 | 32 | import com.sun.corba.se.spi.ior.IOR; |
duke@1 | 33 | import com.sun.corba.se.spi.ior.IORFactories; |
duke@1 | 34 | |
duke@1 | 35 | import com.sun.corba.se.spi.orb.ORB; |
duke@1 | 36 | |
duke@1 | 37 | import com.sun.corba.se.spi.servicecontext.ServiceContexts; |
duke@1 | 38 | import com.sun.corba.se.spi.ior.iiop.GIOPVersion; |
duke@1 | 39 | import com.sun.corba.se.impl.orbutil.ORBUtility; |
duke@1 | 40 | import com.sun.corba.se.impl.orbutil.ORBClassLoader; |
duke@1 | 41 | import com.sun.corba.se.spi.ior.IOR; |
duke@1 | 42 | import com.sun.corba.se.impl.encoding.CDRInputStream; |
duke@1 | 43 | |
duke@1 | 44 | import com.sun.corba.se.spi.logging.CORBALogDomains ; |
duke@1 | 45 | import com.sun.corba.se.impl.logging.ORBUtilSystemException ; |
duke@1 | 46 | |
duke@1 | 47 | /** |
duke@1 | 48 | * This implements the GIOP 1.1 Reply header. |
duke@1 | 49 | * |
duke@1 | 50 | * @author Ram Jeyaraman 05/14/2000 |
duke@1 | 51 | */ |
duke@1 | 52 | |
duke@1 | 53 | public final class ReplyMessage_1_1 extends Message_1_1 |
duke@1 | 54 | implements ReplyMessage { |
duke@1 | 55 | |
duke@1 | 56 | // Instance variables |
duke@1 | 57 | |
duke@1 | 58 | private ORB orb = null; |
duke@1 | 59 | private ORBUtilSystemException wrapper = null ; |
duke@1 | 60 | private ServiceContexts service_contexts = null; |
duke@1 | 61 | private int request_id = (int) 0; |
duke@1 | 62 | private int reply_status = (int) 0; |
duke@1 | 63 | private IOR ior = null; |
duke@1 | 64 | private String exClassName = null; |
duke@1 | 65 | private int minorCode = (int) 0; |
duke@1 | 66 | private CompletionStatus completionStatus = null; |
duke@1 | 67 | |
duke@1 | 68 | // Constructors |
duke@1 | 69 | |
duke@1 | 70 | ReplyMessage_1_1(ORB orb) { |
duke@1 | 71 | this.orb = orb; |
duke@1 | 72 | this.wrapper = ORBUtilSystemException.get( orb, |
duke@1 | 73 | CORBALogDomains.RPC_PROTOCOL ) ; |
duke@1 | 74 | } |
duke@1 | 75 | |
duke@1 | 76 | ReplyMessage_1_1(ORB orb, ServiceContexts _service_contexts, |
duke@1 | 77 | int _request_id, int _reply_status, IOR _ior) { |
duke@1 | 78 | super(Message.GIOPBigMagic, GIOPVersion.V1_1, FLAG_NO_FRAG_BIG_ENDIAN, |
duke@1 | 79 | Message.GIOPReply, 0); |
duke@1 | 80 | this.orb = orb; |
duke@1 | 81 | this.wrapper = ORBUtilSystemException.get( orb, |
duke@1 | 82 | CORBALogDomains.RPC_PROTOCOL ) ; |
duke@1 | 83 | service_contexts = _service_contexts; |
duke@1 | 84 | request_id = _request_id; |
duke@1 | 85 | reply_status = _reply_status; |
duke@1 | 86 | ior = _ior; |
duke@1 | 87 | } |
duke@1 | 88 | |
duke@1 | 89 | // Accessor methods |
duke@1 | 90 | |
duke@1 | 91 | public int getRequestId() { |
duke@1 | 92 | return this.request_id; |
duke@1 | 93 | } |
duke@1 | 94 | |
duke@1 | 95 | public int getReplyStatus() { |
duke@1 | 96 | return this.reply_status; |
duke@1 | 97 | } |
duke@1 | 98 | |
duke@1 | 99 | public short getAddrDisposition() { |
duke@1 | 100 | return KeyAddr.value; |
duke@1 | 101 | } |
duke@1 | 102 | |
duke@1 | 103 | public ServiceContexts getServiceContexts() { |
duke@1 | 104 | return this.service_contexts; |
duke@1 | 105 | } |
duke@1 | 106 | |
duke@1 | 107 | public void setServiceContexts( ServiceContexts sc ) { |
duke@1 | 108 | this.service_contexts = sc; |
duke@1 | 109 | } |
duke@1 | 110 | |
duke@1 | 111 | public SystemException getSystemException(String message) { |
duke@1 | 112 | return MessageBase.getSystemException( |
duke@1 | 113 | exClassName, minorCode, completionStatus, message, wrapper); |
duke@1 | 114 | } |
duke@1 | 115 | |
duke@1 | 116 | public IOR getIOR() { |
duke@1 | 117 | return this.ior; |
duke@1 | 118 | } |
duke@1 | 119 | |
duke@1 | 120 | public void setIOR( IOR ior ) { |
duke@1 | 121 | this.ior = ior; |
duke@1 | 122 | } |
duke@1 | 123 | |
duke@1 | 124 | // IO methods |
duke@1 | 125 | |
duke@1 | 126 | public void read(org.omg.CORBA.portable.InputStream istream) { |
duke@1 | 127 | super.read(istream); |
duke@1 | 128 | this.service_contexts |
duke@1 | 129 | = new ServiceContexts((org.omg.CORBA_2_3.portable.InputStream) istream); |
duke@1 | 130 | this.request_id = istream.read_ulong(); |
duke@1 | 131 | this.reply_status = istream.read_long(); |
duke@1 | 132 | isValidReplyStatus(this.reply_status); // raises exception on error |
duke@1 | 133 | |
duke@1 | 134 | // The code below reads the reply body in some cases |
duke@1 | 135 | // SYSTEM_EXCEPTION & LOCATION_FORWARD |
duke@1 | 136 | if (this.reply_status == SYSTEM_EXCEPTION) { |
duke@1 | 137 | |
duke@1 | 138 | String reposId = istream.read_string(); |
duke@1 | 139 | this.exClassName = ORBUtility.classNameOf(reposId); |
duke@1 | 140 | this.minorCode = istream.read_long(); |
duke@1 | 141 | int status = istream.read_long(); |
duke@1 | 142 | |
duke@1 | 143 | switch (status) { |
duke@1 | 144 | case CompletionStatus._COMPLETED_YES: |
duke@1 | 145 | this.completionStatus = CompletionStatus.COMPLETED_YES; |
duke@1 | 146 | break; |
duke@1 | 147 | case CompletionStatus._COMPLETED_NO: |
duke@1 | 148 | this.completionStatus = CompletionStatus.COMPLETED_NO; |
duke@1 | 149 | break; |
duke@1 | 150 | case CompletionStatus._COMPLETED_MAYBE: |
duke@1 | 151 | this.completionStatus = CompletionStatus.COMPLETED_MAYBE; |
duke@1 | 152 | break; |
duke@1 | 153 | default: |
duke@1 | 154 | throw wrapper.badCompletionStatusInReply( |
duke@1 | 155 | CompletionStatus.COMPLETED_MAYBE, new Integer(status) ); |
duke@1 | 156 | } |
duke@1 | 157 | } else if (this.reply_status == USER_EXCEPTION) { |
duke@1 | 158 | // do nothing. The client stub will read the exception from body. |
duke@1 | 159 | } else if (this.reply_status == LOCATION_FORWARD) { |
duke@1 | 160 | CDRInputStream cdr = (CDRInputStream) istream; |
duke@1 | 161 | this.ior = IORFactories.makeIOR(cdr) ; |
duke@1 | 162 | } |
duke@1 | 163 | } |
duke@1 | 164 | |
duke@1 | 165 | // Note, this writes only the header information. SystemException or |
duke@1 | 166 | // IOR may be written afterwards into the reply mesg body. |
duke@1 | 167 | public void write(org.omg.CORBA.portable.OutputStream ostream) { |
duke@1 | 168 | super.write(ostream); |
duke@1 | 169 | if (this.service_contexts != null) { |
duke@1 | 170 | service_contexts.write( |
duke@1 | 171 | (org.omg.CORBA_2_3.portable.OutputStream) ostream, |
duke@1 | 172 | GIOPVersion.V1_1); |
duke@1 | 173 | } else { |
duke@1 | 174 | ServiceContexts.writeNullServiceContext( |
duke@1 | 175 | (org.omg.CORBA_2_3.portable.OutputStream) ostream); |
duke@1 | 176 | } |
duke@1 | 177 | ostream.write_ulong(this.request_id); |
duke@1 | 178 | ostream.write_long(this.reply_status); |
duke@1 | 179 | } |
duke@1 | 180 | |
duke@1 | 181 | // Static methods |
duke@1 | 182 | |
duke@1 | 183 | public static void isValidReplyStatus(int replyStatus) { |
duke@1 | 184 | switch (replyStatus) { |
duke@1 | 185 | case NO_EXCEPTION : |
duke@1 | 186 | case USER_EXCEPTION : |
duke@1 | 187 | case SYSTEM_EXCEPTION : |
duke@1 | 188 | case LOCATION_FORWARD : |
duke@1 | 189 | break; |
duke@1 | 190 | default : |
duke@1 | 191 | ORBUtilSystemException localWrapper = ORBUtilSystemException.get( |
duke@1 | 192 | CORBALogDomains.RPC_PROTOCOL ) ; |
duke@1 | 193 | throw localWrapper.illegalReplyStatus( CompletionStatus.COMPLETED_MAYBE); |
duke@1 | 194 | } |
duke@1 | 195 | } |
duke@1 | 196 | |
duke@1 | 197 | public void callback(MessageHandler handler) |
duke@1 | 198 | throws java.io.IOException |
duke@1 | 199 | { |
duke@1 | 200 | handler.handleInput(this); |
duke@1 | 201 | } |
duke@1 | 202 | } // |