KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)RequestMessage_1_1.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 import com.sun.corba.se.spi.logging.CORBALogDomains ;
17 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
18
19 /**
20  * This implements the GIOP 1.1 Request header.
21  *
22  * @author Ram Jeyaraman 05/14/2000
23  * @version 1.0
24  */

25
26 public final class RequestMessage_1_1 extends Message_1_1
27         implements RequestMessage {
28
29     // Instance variables
30

31     private ORB orb = null;
32     private ORBUtilSystemException wrapper = null ;
33     private ServiceContexts service_contexts = null;
34     private int request_id = (int) 0;
35     private boolean response_expected = false;
36     private byte[] reserved = null; // Added in GIOP 1.1
37
private byte[] object_key = null;
38     private String JavaDoc operation = null;
39     private Principal JavaDoc requesting_principal = null;
40     private ObjectKey objectKey = null;
41
42     // Constructors
43

44     RequestMessage_1_1(ORB orb) {
45         this.orb = orb;
46     this.wrapper = ORBUtilSystemException.get( orb,
47         CORBALogDomains.RPC_PROTOCOL ) ;
48     }
49
50     RequestMessage_1_1(ORB orb, ServiceContexts _service_contexts,
51             int _request_id, boolean _response_expected, byte[] _reserved,
52             byte[] _object_key, String JavaDoc _operation,
53             Principal JavaDoc _requesting_principal) {
54         super(Message.GIOPBigMagic, GIOPVersion.V1_1, FLAG_NO_FRAG_BIG_ENDIAN,
55             Message.GIOPRequest, 0);
56         this.orb = orb;
57     this.wrapper = ORBUtilSystemException.get( orb,
58         CORBALogDomains.RPC_PROTOCOL ) ;
59         service_contexts = _service_contexts;
60         request_id = _request_id;
61         response_expected = _response_expected;
62         reserved = _reserved;
63         object_key = _object_key;
64         operation = _operation;
65         requesting_principal = _requesting_principal;
66     }
67
68     // Accessor methods (RequestMessage interface)
69

70     public ServiceContexts getServiceContexts() {
71         return this.service_contexts;
72     }
73
74     public int getRequestId() {
75         return this.request_id;
76     }
77
78     public boolean isResponseExpected() {
79         return this.response_expected;
80     }
81
82     public byte[] getReserved() {
83         return this.reserved;
84     }
85
86     public ObjectKey getObjectKey() {
87         if (this.objectKey == null) {
88         // this will raise a MARSHAL exception upon errors.
89
this.objectKey = MessageBase.extractObjectKey(object_key, orb);
90         }
91
92     return this.objectKey;
93     }
94
95     public String JavaDoc getOperation() {
96         return this.operation;
97     }
98
99     public Principal JavaDoc getPrincipal() {
100         return this.requesting_principal;
101     }
102
103     // IO methods
104

105     public void read(org.omg.CORBA.portable.InputStream JavaDoc istream) {
106         super.read(istream);
107         this.service_contexts
108             = new ServiceContexts((org.omg.CORBA_2_3.portable.InputStream JavaDoc) istream);
109         this.request_id = istream.read_ulong();
110         this.response_expected = istream.read_boolean();
111         this.reserved = new byte[3];
112         for (int _o0 = 0;_o0 < (3); ++_o0) {
113             this.reserved[_o0] = istream.read_octet();
114         }
115         int _len1 = istream.read_long();
116         this.object_key = new byte[_len1];
117         istream.read_octet_array(this.object_key, 0, _len1);
118         this.operation = istream.read_string();
119         this.requesting_principal = istream.read_Principal();
120     }
121
122     public void write(org.omg.CORBA.portable.OutputStream JavaDoc ostream) {
123         super.write(ostream);
124         if (this.service_contexts != null) {
125             service_contexts.write(
126                 (org.omg.CORBA_2_3.portable.OutputStream JavaDoc) ostream,
127                 GIOPVersion.V1_1);
128         } else {
129             ServiceContexts.writeNullServiceContext(
130                 (org.omg.CORBA_2_3.portable.OutputStream JavaDoc) ostream);
131         }
132         ostream.write_ulong(this.request_id);
133         ostream.write_boolean(this.response_expected);
134         nullCheck(this.reserved);
135         if (this.reserved.length != (3)) {
136         throw wrapper.badReservedLength(
137         org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
138         }
139         for (int _i0 = 0;_i0 < (3); ++_i0) {
140             ostream.write_octet(this.reserved[_i0]);
141         }
142         nullCheck(this.object_key);
143         ostream.write_long(this.object_key.length);
144         ostream.write_octet_array(this.object_key, 0, this.object_key.length);
145         ostream.write_string(this.operation);
146         if (this.requesting_principal != null) {
147             ostream.write_Principal(this.requesting_principal);
148         } else {
149             ostream.write_long(0);
150         }
151     }
152
153     public void callback(MessageHandler handler)
154         throws java.io.IOException JavaDoc
155     {
156         handler.handleInput(this);
157     }
158 } // class RequestMessage_1_1
159
Popular Tags