1 /* |
|
2 * Copyright (c) 1999, 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.iiop; |
|
27 |
|
28 import com.sun.corba.se.impl.protocol.Request; |
|
29 import com.sun.corba.se.impl.core.ClientRequest; |
|
30 import com.sun.corba.se.impl.core.ServiceContext; |
|
31 import com.sun.corba.se.impl.core.ServiceContexts; |
|
32 import com.sun.corba.se.impl.core.ClientResponse; |
|
33 import com.sun.corba.se.impl.core.ServerRequest; |
|
34 import com.sun.corba.se.impl.core.ServerResponse; |
|
35 import com.sun.corba.se.impl.corba.IOR; |
|
36 import com.sun.corba.se.impl.corba.GIOPVersion; |
|
37 import com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase; |
|
38 import com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage; |
|
39 import com.sun.corba.se.impl.orbutil.ORBConstants; |
|
40 import com.sun.corba.se.impl.core.ORBVersion; |
|
41 import com.sun.corba.se.impl.core.ORB; |
|
42 import com.sun.corba.se.impl.orbutil.ORBUtility; |
|
43 import com.sun.corba.se.impl.ior.ObjectKeyFactory ; |
|
44 import com.sun.corba.se.impl.ior.ObjectKey ; |
|
45 import com.sun.corba.se.impl.ior.ObjectKeyTemplate ; |
|
46 import com.sun.corba.se.impl.ior.IIOPProfile; |
|
47 |
|
48 public class LocalClientRequestImpl extends IIOPOutputStream |
|
49 implements ClientRequest |
|
50 { |
|
51 public LocalClientRequestImpl( GIOPVersion gv, |
|
52 ORB orb, IOR ior, short addrDisposition, |
|
53 String operationName, boolean oneway, ServiceContexts svc, |
|
54 int requestId, byte streamFormatVersion) |
|
55 { |
|
56 super(gv, |
|
57 orb, |
|
58 null, |
|
59 BufferManagerFactory.newBufferManagerWrite(BufferManagerFactory.GROW), |
|
60 streamFormatVersion); |
|
61 |
|
62 this.isOneway = oneway; |
|
63 boolean responseExpected = !isOneway; |
|
64 |
|
65 IIOPProfile iop = ior.getProfile(); |
|
66 ObjectKey okey = iop.getObjectKey(); |
|
67 ObjectKeyTemplate oktemp = okey.getTemplate() ; |
|
68 ORBVersion version = oktemp.getORBVersion() ; |
|
69 orb.setORBVersion( version ) ; |
|
70 |
|
71 this.request = MessageBase.createRequest(orb, gv, requestId, |
|
72 responseExpected, ior, addrDisposition, operationName, svc, null); |
|
73 setMessage(request); |
|
74 request.write(this); |
|
75 |
|
76 // mark beginning of msg body for possible later use |
|
77 bodyBegin = getSize(); |
|
78 } |
|
79 |
|
80 public int getRequestId() { |
|
81 return request.getRequestId(); |
|
82 } |
|
83 |
|
84 public boolean isOneWay() { |
|
85 return isOneway; |
|
86 } |
|
87 |
|
88 public ServiceContexts getServiceContexts() { |
|
89 return request.getServiceContexts(); |
|
90 } |
|
91 |
|
92 public String getOperationName() { |
|
93 return request.getOperation(); |
|
94 } |
|
95 |
|
96 public ObjectKey getObjectKey() { |
|
97 return request.getObjectKey(); |
|
98 } |
|
99 |
|
100 public ServerRequest getServerRequest() |
|
101 { |
|
102 // Set the size of the marshalled data in the message header. |
|
103 getMessage().setSize( getByteBuffer(), getSize() ) ; |
|
104 |
|
105 // Construct a new ServerRequest out of the buffer in this ClientRequest |
|
106 LocalServerRequestImpl serverRequest = new LocalServerRequestImpl( |
|
107 (ORB)orb(), toByteArray(), request ) ; |
|
108 |
|
109 // Skip over all of the GIOP header information. This positions |
|
110 // the offset in the buffer so that the skeleton can correctly read |
|
111 // the marshalled arguments. |
|
112 serverRequest.setIndex( bodyBegin ) ; |
|
113 |
|
114 return serverRequest ; |
|
115 } |
|
116 |
|
117 public ClientResponse invoke() |
|
118 { |
|
119 ORB myORB = (ORB)orb() ; |
|
120 |
|
121 ServerResponse serverResponse = myORB.process( getServerRequest() ) ; |
|
122 |
|
123 LocalServerResponseImpl lsr = (LocalServerResponseImpl)serverResponse ; |
|
124 |
|
125 return lsr.getClientResponse() ; |
|
126 } |
|
127 |
|
128 /** |
|
129 * Check to see if the request is local. |
|
130 */ |
|
131 public boolean isLocal(){ |
|
132 return true; |
|
133 } |
|
134 |
|
135 private RequestMessage request; |
|
136 private int bodyBegin; |
|
137 private boolean isOneway; |
|
138 } |
|