KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > protocol > SharedCDRClientRequestDispatcherImpl


1 /*
2  * @(#)SharedCDRClientRequestDispatcherImpl.java 1.13 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 /*
9  * Licensed Materials - Property of IBM
10  * RMI-IIOP v1.0
11  * Copyright IBM Corp. 1998 1999 All Rights Reserved
12  *
13  * US Government Users Restricted Rights - Use, duplication or
14  * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
15  */

16
17 package com.sun.corba.se.impl.protocol;
18
19 import java.io.IOException JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.rmi.RemoteException JavaDoc;
22 import java.nio.ByteBuffer JavaDoc;
23
24 import javax.rmi.CORBA.Util JavaDoc;
25 import javax.rmi.CORBA.Tie JavaDoc;
26
27 import org.omg.CORBA.COMM_FAILURE JavaDoc;
28 import org.omg.CORBA.INTERNAL JavaDoc;
29 import org.omg.CORBA.SystemException JavaDoc;
30 import org.omg.CORBA.CompletionStatus JavaDoc;
31 import org.omg.CORBA.WrongTransaction JavaDoc;
32 import org.omg.CORBA.Request JavaDoc;
33 import org.omg.CORBA.NamedValue JavaDoc;
34 import org.omg.CORBA.NVList JavaDoc;
35 import org.omg.CORBA.Context JavaDoc;
36 import org.omg.CORBA.ContextList JavaDoc;
37 import org.omg.CORBA.ExceptionList JavaDoc;
38 import org.omg.CORBA.TypeCode JavaDoc;
39 import org.omg.CORBA.DATA_CONVERSION JavaDoc;
40 import org.omg.CORBA.UNKNOWN JavaDoc;
41 import org.omg.CORBA.portable.RemarshalException JavaDoc;
42 import org.omg.CORBA_2_3.portable.InputStream JavaDoc;
43 import org.omg.CORBA_2_3.portable.OutputStream JavaDoc;
44 import org.omg.CORBA.portable.Delegate JavaDoc;
45 import org.omg.CORBA.portable.ServantObject JavaDoc;
46 import org.omg.CORBA.portable.ApplicationException JavaDoc;
47 import org.omg.CORBA.portable.UnknownException JavaDoc;
48 import org.omg.IOP.TAG_CODE_SETS JavaDoc;
49
50 import com.sun.org.omg.SendingContext.CodeBase;
51
52 import com.sun.corba.se.pept.broker.Broker;
53 import com.sun.corba.se.pept.encoding.InputObject;
54 import com.sun.corba.se.pept.encoding.OutputObject;
55 import com.sun.corba.se.pept.protocol.ClientRequestDispatcher;
56 import com.sun.corba.se.pept.protocol.MessageMediator;
57 import com.sun.corba.se.pept.transport.Connection;
58 import com.sun.corba.se.pept.transport.ConnectionCache;
59 import com.sun.corba.se.pept.transport.ContactInfo;
60
61 import com.sun.corba.se.spi.ior.IOR;
62 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
63 import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate;
64 import com.sun.corba.se.spi.ior.iiop.CodeSetsComponent;
65 import com.sun.corba.se.spi.oa.OAInvocationInfo;
66 import com.sun.corba.se.spi.oa.ObjectAdapterFactory;
67 import com.sun.corba.se.spi.orb.ORB;
68 import com.sun.corba.se.spi.orb.ORBVersion;
69 import com.sun.corba.se.spi.orb.ORBVersionFactory;
70 import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
71 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry;
72 import com.sun.corba.se.spi.transport.CorbaContactInfo ;
73 import com.sun.corba.se.spi.transport.CorbaContactInfoList ;
74 import com.sun.corba.se.spi.transport.CorbaContactInfoListIterator ;
75 import com.sun.corba.se.spi.transport.CorbaConnection;
76
77 import com.sun.corba.se.spi.servicecontext.ServiceContext;
78 import com.sun.corba.se.spi.servicecontext.ServiceContexts;
79 import com.sun.corba.se.spi.servicecontext.UEInfoServiceContext;
80 import com.sun.corba.se.spi.servicecontext.CodeSetServiceContext;
81 import com.sun.corba.se.spi.servicecontext.MaxStreamFormatVersionServiceContext;
82 import com.sun.corba.se.spi.servicecontext.SendingContextServiceContext;
83 import com.sun.corba.se.impl.encoding.ByteBufferWithInfo;
84 import com.sun.corba.se.impl.encoding.CDRInputObject;
85 import com.sun.corba.se.impl.encoding.CDROutputObject;
86 import com.sun.corba.se.impl.encoding.CDROutputStream;
87 import com.sun.corba.se.impl.encoding.CodeSetComponentInfo;
88 import com.sun.corba.se.impl.encoding.CodeSetConversion;
89 import com.sun.corba.se.impl.encoding.MarshalOutputStream;
90 import com.sun.corba.se.impl.encoding.MarshalInputStream;
91 import com.sun.corba.se.impl.orbutil.ORBUtility;
92 import com.sun.corba.se.impl.orbutil.ORBConstants;
93 import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage;
94 import com.sun.corba.se.impl.protocol.giopmsgheaders.KeyAddr;
95 import com.sun.corba.se.impl.protocol.giopmsgheaders.ProfileAddr;
96 import com.sun.corba.se.impl.protocol.giopmsgheaders.ReferenceAddr;
97 import com.sun.corba.se.impl.transport.CorbaContactInfoListIteratorImpl;
98 import com.sun.corba.se.impl.util.JDKBridge;
99
100 /**
101  * ClientDelegate is the RMI client-side subcontract or representation
102  * It implements RMI delegate as well as our internal ClientRequestDispatcher
103  * interface.
104  */

105 public class SharedCDRClientRequestDispatcherImpl
106     extends
107     CorbaClientRequestDispatcherImpl
108 {
109     // REVISIT:
110
// Rather than have separate CDR subcontract,
111
// use same CorbaClientRequestDispatcherImpl but have
112
// different MessageMediator finishSendingRequest and waitForResponse
113
// handle what is done below.
114
// Benefit: then in ContactInfo no need to do a direct new
115
// of subcontract - does not complicate subcontract registry.
116

117     public InputObject marshalingComplete(java.lang.Object JavaDoc self,
118                       OutputObject outputObject)
119     throws
120         ApplicationException JavaDoc,
121         org.omg.CORBA.portable.RemarshalException JavaDoc
122     {
123       ORB orb = null;
124       CorbaMessageMediator messageMediator = null;
125       try {
126     messageMediator = (CorbaMessageMediator)
127         outputObject.getMessageMediator();
128
129     orb = (ORB) messageMediator.getBroker();
130
131     if (orb.subcontractDebugFlag) {
132         dprint(".marshalingComplete->: " + opAndId(messageMediator));
133     }
134
135     CDROutputObject cdrOutputObject = (CDROutputObject) outputObject;
136
137     //
138
// Create server-side input object.
139
//
140

141     ByteBufferWithInfo bbwi = cdrOutputObject.getByteBufferWithInfo();
142     cdrOutputObject.getMessageHeader().setSize(bbwi.byteBuffer, bbwi.getSize());
143
144     CDRInputObject cdrInputObject =
145         new CDRInputObject(orb, null, bbwi.byteBuffer,
146                    cdrOutputObject.getMessageHeader());
147     messageMediator.setInputObject(cdrInputObject);
148     cdrInputObject.setMessageMediator(messageMediator);
149
150     //
151
// Dispatch
152
//
153

154     // REVISIT: Impl cast.
155
((CorbaMessageMediatorImpl)messageMediator).handleRequestRequest(
156             messageMediator);
157
158         // InputStream must be closed on the InputObject so that its
159
// ByteBuffer can be released to the ByteBufferPool. We must do
160
// this before we re-assign the cdrInputObject reference below.
161
try { cdrInputObject.close(); }
162         catch (IOException JavaDoc ex) {
163             // No need to do anything since we're done with the input stream
164
// and cdrInputObject will be re-assigned a new client-side input
165
// object, (i.e. won't result in a corba error).
166

167             if (orb.transportDebugFlag) {
168                dprint(".marshalingComplete: ignoring IOException - " + ex.toString());
169             }
170         }
171
172     //
173
// Create client-side input object
174
//
175

176     cdrOutputObject = (CDROutputObject) messageMediator.getOutputObject();
177     bbwi = cdrOutputObject.getByteBufferWithInfo();
178     cdrOutputObject.getMessageHeader().setSize(bbwi.byteBuffer, bbwi.getSize());
179     cdrInputObject =
180         new CDRInputObject(orb, null, bbwi.byteBuffer,
181                    cdrOutputObject.getMessageHeader());
182     messageMediator.setInputObject(cdrInputObject);
183     cdrInputObject.setMessageMediator(messageMediator);
184
185     cdrInputObject.unmarshalHeader();
186
187     InputObject inputObject = cdrInputObject;
188
189     return processResponse(orb, messageMediator, inputObject);
190
191       } finally {
192         if (orb.subcontractDebugFlag) {
193         dprint(".marshalingComplete<-: " + opAndId(messageMediator));
194     }
195       }
196     }
197
198     protected void dprint(String JavaDoc msg)
199     {
200     ORBUtility.dprint("SharedCDRClientRequestDispatcherImpl", msg);
201     }
202 }
203
204 // End of file.
205
Popular Tags