KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)RequestMessage_1_0.java 1.14 04/06/21
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.Principal JavaDoc;
11 import com.sun.corba.se.spi.servicecontext.ServiceContexts;
12 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
13 import com.sun.corba.se.spi.orb.ORB;
14 import com.sun.corba.se.spi.ior.ObjectKey;
15
16 /**
17  * This implements the GIOP 1.0 Request header.
18  *
19  * @author Ram Jeyaraman 05/14/2000
20  * @version 1.0
21  */

22
23 public final class RequestMessage_1_0 extends Message_1_0
24         implements RequestMessage {
25
26     // Instance variables
27

28     private ORB orb = null;
29     private ServiceContexts service_contexts = null;
30     private int request_id = (int) 0;
31     private boolean response_expected = false;
32     private byte[] object_key = null;
33     private String JavaDoc operation = null;
34     private Principal JavaDoc requesting_principal = null;
35     private ObjectKey objectKey = null;
36
37     // Constructor
38

39     RequestMessage_1_0(ORB orb) {
40         this.orb = orb;
41     }
42
43     RequestMessage_1_0(ORB orb, ServiceContexts _service_contexts,
44             int _request_id, boolean _response_expected, byte[] _object_key,
45             String JavaDoc _operation, Principal JavaDoc _requesting_principal) {
46         super(Message.GIOPBigMagic, false, Message.GIOPRequest, 0);
47         this.orb = orb;
48         service_contexts = _service_contexts;
49         request_id = _request_id;
50         response_expected = _response_expected;
51         object_key = _object_key;
52         operation = _operation;
53         requesting_principal = _requesting_principal;
54     }
55
56     // Accessor methods (RequestMessage interface)
57

58     public ServiceContexts getServiceContexts() {
59         return this.service_contexts;
60     }
61
62     public int getRequestId() {
63         return this.request_id;
64     }
65
66     public boolean isResponseExpected() {
67         return this.response_expected;
68     }
69
70     public byte[] getReserved() {
71         // REVISIT Should we throw an exception or return null ?
72
return null;
73     }
74
75     public ObjectKey getObjectKey() {
76         if (this.objectKey == null) {
77         // this will raise a MARSHAL exception upon errors.
78
this.objectKey = MessageBase.extractObjectKey(object_key, orb);
79         }
80
81     return this.objectKey;
82     }
83
84     public String JavaDoc getOperation() {
85         return this.operation;
86     }
87
88     public Principal JavaDoc getPrincipal() {
89         return this.requesting_principal;
90     }
91
92
93     // Mutators
94

95     public void setThreadPoolToUse(int poolToUse) {
96     // No-op, must be GIOP Version 1.1 or greater
97
// to support this SUN PROPRIETARY EXTENSION.
98
}
99
100
101     // IO methods
102

103     public void read(org.omg.CORBA.portable.InputStream JavaDoc istream) {
104         super.read(istream);
105         this.service_contexts
106             = new ServiceContexts((org.omg.CORBA_2_3.portable.InputStream JavaDoc) istream);
107         this.request_id = istream.read_ulong();
108         this.response_expected = istream.read_boolean();
109         int _len0 = istream.read_long();
110         this.object_key = new byte[_len0];
111         istream.read_octet_array(this.object_key, 0, _len0);
112         this.operation = istream.read_string();
113         this.requesting_principal = istream.read_Principal();
114     }
115
116     public void write(org.omg.CORBA.portable.OutputStream JavaDoc ostream) {
117         super.write(ostream);
118         if (this.service_contexts != null) {
119             service_contexts.write(
120                 (org.omg.CORBA_2_3.portable.OutputStream JavaDoc) ostream,
121                 GIOPVersion.V1_0);
122         } else {
123             ServiceContexts.writeNullServiceContext(
124                 (org.omg.CORBA_2_3.portable.OutputStream JavaDoc) ostream);
125         }
126         ostream.write_ulong(this.request_id);
127         ostream.write_boolean(this.response_expected);
128         nullCheck(this.object_key);
129         ostream.write_long(this.object_key.length);
130         ostream.write_octet_array(this.object_key, 0, this.object_key.length);
131         ostream.write_string(this.operation);
132         if (this.requesting_principal != null) {
133             ostream.write_Principal(this.requesting_principal);
134         } else {
135             ostream.write_long(0);
136         }
137     }
138
139     public void callback(MessageHandler handler)
140         throws java.io.IOException JavaDoc
141     {
142         handler.handleInput(this);
143     }
144 } // class RequestMessage_1_0
145
Popular Tags