KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > transport > SharedCDRContactInfoImpl


1 /*
2  * @(#)SharedCDRContactInfoImpl.java 1.9 03/12/19
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.transport;
9
10 import com.sun.corba.se.pept.broker.Broker;
11 import com.sun.corba.se.pept.encoding.OutputObject;
12 import com.sun.corba.se.pept.protocol.ClientRequestDispatcher;
13 import com.sun.corba.se.pept.protocol.MessageMediator;
14 import com.sun.corba.se.pept.transport.Connection;
15 import com.sun.corba.se.pept.transport.ContactInfo;
16
17 import com.sun.corba.se.spi.orb.ORB;
18 import com.sun.corba.se.spi.ior.IOR;
19 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
20 import com.sun.corba.se.spi.logging.CORBALogDomains;
21 import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
22 import com.sun.corba.se.spi.transport.CorbaContactInfoList;
23
24 import com.sun.corba.se.impl.encoding.BufferManagerFactory;
25 import com.sun.corba.se.impl.encoding.CDROutputObject;
26 import com.sun.corba.se.impl.encoding.CDROutputStream;
27 import com.sun.corba.se.impl.logging.ORBUtilSystemException;
28 import com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl;
29 import com.sun.corba.se.impl.protocol.SharedCDRClientRequestDispatcherImpl;
30
31 public class SharedCDRContactInfoImpl
32     extends
33     CorbaContactInfoBase
34 {
35     // This is only necessary for the pi.clientrequestinfo test.
36
// It tests that request ids are different.
37
// Rather than rewrite the test, just fake it.
38
private static int requestId = 0;
39
40     protected ORBUtilSystemException wrapper;
41
42     public SharedCDRContactInfoImpl(
43         ORB orb,
44     CorbaContactInfoList contactInfoList,
45     IOR effectiveTargetIOR,
46     short addressingDisposition)
47     {
48     this.orb = orb;
49     this.contactInfoList = contactInfoList;
50     this.effectiveTargetIOR = effectiveTargetIOR;
51         this.addressingDisposition = addressingDisposition;
52     }
53
54     ////////////////////////////////////////////////////
55
//
56
// pept.transport.ContactInfo
57
//
58

59     public ClientRequestDispatcher getClientRequestDispatcher()
60     {
61     // REVISIT - use registry
62
return new SharedCDRClientRequestDispatcherImpl();
63     }
64
65     public boolean isConnectionBased()
66     {
67     return false;
68     }
69
70     public boolean shouldCacheConnection()
71     {
72     return false;
73     }
74
75     public String JavaDoc getConnectionCacheType()
76     {
77     throw getWrapper().methodShouldNotBeCalled();
78     }
79     
80     public Connection createConnection()
81     {
82     throw getWrapper().methodShouldNotBeCalled();
83     }
84
85     // Called when client making an invocation.
86
public MessageMediator createMessageMediator(Broker broker,
87                          ContactInfo contactInfo,
88                          Connection connection,
89                          String JavaDoc methodName,
90                          boolean isOneWay)
91     {
92     if (connection != null) {
93         /// XXX LOGGING
94
throw new RuntimeException JavaDoc("connection is not null");
95     }
96
97     CorbaMessageMediator messageMediator =
98         new CorbaMessageMediatorImpl(
99             (ORB) broker,
100         contactInfo,
101         null, // Connection;
102
GIOPVersion.chooseRequestVersion( (ORB)broker,
103              effectiveTargetIOR),
104         effectiveTargetIOR,
105         requestId++, // Fake RequestId
106
getAddressingDisposition(),
107         methodName,
108         isOneWay);
109
110     return messageMediator;
111     }
112
113     public OutputObject createOutputObject(MessageMediator messageMediator)
114     {
115     CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
116         messageMediator;
117     // NOTE: GROW.
118
OutputObject outputObject =
119         new CDROutputObject(orb, messageMediator,
120                 corbaMessageMediator.getRequestHeader(),
121                 corbaMessageMediator.getStreamFormatVersion(),
122                 BufferManagerFactory.GROW);
123     messageMediator.setOutputObject(outputObject);
124     return outputObject;
125     }
126
127     ////////////////////////////////////////////////////
128
//
129
// spi.transport.CorbaContactInfo
130
//
131

132     public String JavaDoc getMonitoringName()
133     {
134     throw getWrapper().methodShouldNotBeCalled();
135     }
136
137     ////////////////////////////////////////////////////
138
//
139
// java.lang.Object
140
//
141

142     ////////////////////////////////////////////////////
143
//
144
// java.lang.Object
145
//
146

147     public String JavaDoc toString()
148     {
149     return
150         "SharedCDRContactInfoImpl["
151         + "]";
152     }
153
154     //////////////////////////////////////////////////
155
//
156
// Implementation
157
//
158

159     protected ORBUtilSystemException getWrapper()
160     {
161     if (wrapper == null) {
162         wrapper = ORBUtilSystemException.get( orb,
163                       CORBALogDomains.RPC_TRANSPORT ) ;
164     }
165     return wrapper;
166     }
167 }
168
169 // End of file.
170
Popular Tags