1 /*
2  * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package com.sun.corba.se.impl.protocol.giopmsgheaders;
27 
28 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
29 
30 import com.sun.corba.se.spi.orb.ORB;
31 
32 import com.sun.corba.se.spi.ior.ObjectKey;
33 
34 /**
35  * This implements the GIOP 1.1 LocateRequest header.
36  *
37  * @author Ram Jeyaraman 05/14/2000
38  */
39 
40 public final class LocateRequestMessage_1_1 extends Message_1_1
41         implements LocateRequestMessage {
42 
43     // Instance variables
44 
45     private ORB orb = null;
46     private int request_id = (int) 0;
47     private byte[] object_key = null;
48     private ObjectKey objectKey = null;
49 
50     // Constructors
51 
LocateRequestMessage_1_1(ORB orb)52     LocateRequestMessage_1_1(ORB orb) {
53         this.orb = orb;
54     }
55 
LocateRequestMessage_1_1(ORB orb, int _request_id, byte[] _object_key)56     LocateRequestMessage_1_1(ORB orb, int _request_id, byte[] _object_key) {
57         super(Message.GIOPBigMagic, GIOPVersion.V1_1, FLAG_NO_FRAG_BIG_ENDIAN,
58             Message.GIOPLocateRequest, 0);
59         this.orb = orb;
60         request_id = _request_id;
61         object_key = _object_key;
62     }
63 
64     // Accessor methods (LocateRequestMessage interface)
65 
getRequestId()66     public int getRequestId() {
67         return this.request_id;
68     }
69 
getObjectKey()70     public ObjectKey getObjectKey() {
71         if (this.objectKey == null) {
72             // this will raise a MARSHAL exception upon errors.
73             this.objectKey = MessageBase.extractObjectKey(object_key, orb);
74         }
75 
76         return this.objectKey;
77     }
78 
79     // IO methods
80 
read(org.omg.CORBA.portable.InputStream istream)81     public void read(org.omg.CORBA.portable.InputStream istream) {
82         super.read(istream);
83         this.request_id = istream.read_ulong();
84         int _len1 = istream.read_long();
85         this.object_key = new byte[_len1];
86         istream.read_octet_array(this.object_key, 0, _len1);
87     }
88 
write(org.omg.CORBA.portable.OutputStream ostream)89     public void write(org.omg.CORBA.portable.OutputStream ostream) {
90         super.write(ostream);
91         ostream.write_ulong(this.request_id);
92         nullCheck(this.object_key);
93         ostream.write_long(this.object_key.length);
94         ostream.write_octet_array(this.object_key, 0, this.object_key.length);
95     }
96 
callback(MessageHandler handler)97     public void callback(MessageHandler handler)
98         throws java.io.IOException
99     {
100         handler.handleInput(this);
101     }
102 } // class LocateRequestMessage_1_1
103