SharedCDRContactInfoImpl.java revision 608:7e06bf1dcb09
1/*
2 * Copyright (c) 2003, 2013, 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
26package com.sun.corba.se.impl.transport;
27
28import com.sun.corba.se.pept.broker.Broker;
29import com.sun.corba.se.pept.encoding.OutputObject;
30import com.sun.corba.se.pept.protocol.ClientRequestDispatcher;
31import com.sun.corba.se.pept.protocol.MessageMediator;
32import com.sun.corba.se.pept.transport.Connection;
33import com.sun.corba.se.pept.transport.ContactInfo;
34
35import com.sun.corba.se.spi.orb.ORB;
36import com.sun.corba.se.spi.ior.IOR;
37import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
38import com.sun.corba.se.spi.logging.CORBALogDomains;
39import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
40import com.sun.corba.se.spi.transport.CorbaContactInfoList;
41
42import com.sun.corba.se.impl.encoding.BufferManagerFactory;
43import com.sun.corba.se.impl.encoding.CDROutputObject;
44import com.sun.corba.se.impl.encoding.CDROutputStream;
45import com.sun.corba.se.impl.logging.ORBUtilSystemException;
46import com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl;
47import com.sun.corba.se.impl.protocol.SharedCDRClientRequestDispatcherImpl;
48
49public class SharedCDRContactInfoImpl
50    extends
51        CorbaContactInfoBase
52{
53    // This is only necessary for the pi.clientrequestinfo test.
54    // It tests that request ids are different.
55    // Rather than rewrite the test, just fake it.
56    private static int requestId = 0;
57
58    protected ORBUtilSystemException wrapper;
59
60    public SharedCDRContactInfoImpl(
61        ORB orb,
62        CorbaContactInfoList contactInfoList,
63        IOR effectiveTargetIOR,
64        short addressingDisposition)
65    {
66        this.orb = orb;
67        this.contactInfoList = contactInfoList;
68        this.effectiveTargetIOR = effectiveTargetIOR;
69        this.addressingDisposition = addressingDisposition;
70    }
71
72    ////////////////////////////////////////////////////
73    //
74    // pept.transport.ContactInfo
75    //
76
77    public ClientRequestDispatcher getClientRequestDispatcher()
78    {
79        // REVISIT - use registry
80        return new SharedCDRClientRequestDispatcherImpl();
81    }
82
83    public boolean isConnectionBased()
84    {
85        return false;
86    }
87
88    public boolean shouldCacheConnection()
89    {
90        return false;
91    }
92
93    public String getConnectionCacheType()
94    {
95        throw getWrapper().methodShouldNotBeCalled();
96    }
97
98    public Connection createConnection()
99    {
100        throw getWrapper().methodShouldNotBeCalled();
101    }
102
103    // Called when client making an invocation.
104    public MessageMediator createMessageMediator(Broker broker,
105                                                 ContactInfo contactInfo,
106                                                 Connection connection,
107                                                 String methodName,
108                                                 boolean isOneWay)
109    {
110        if (connection != null) {
111            /// XXX LOGGING
112            throw new RuntimeException("connection is not null");
113        }
114
115        CorbaMessageMediator messageMediator =
116            new CorbaMessageMediatorImpl(
117                (ORB) broker,
118                contactInfo,
119                null, // Connection;
120                GIOPVersion.chooseRequestVersion( (ORB)broker,
121                     effectiveTargetIOR),
122                effectiveTargetIOR,
123                requestId++, // Fake RequestId
124                getAddressingDisposition(),
125                methodName,
126                isOneWay);
127
128        return messageMediator;
129    }
130
131    public OutputObject createOutputObject(MessageMediator messageMediator)
132    {
133        CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
134            messageMediator;
135        // NOTE: GROW.
136        OutputObject outputObject =
137            sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
138                                corbaMessageMediator.getRequestHeader(),
139                                corbaMessageMediator.getStreamFormatVersion(),
140                                BufferManagerFactory.GROW);
141        messageMediator.setOutputObject(outputObject);
142        return outputObject;
143    }
144
145    ////////////////////////////////////////////////////
146    //
147    // spi.transport.CorbaContactInfo
148    //
149
150    public String getMonitoringName()
151    {
152        throw getWrapper().methodShouldNotBeCalled();
153    }
154
155    ////////////////////////////////////////////////////
156    //
157    // java.lang.Object
158    //
159
160    ////////////////////////////////////////////////////
161    //
162    // java.lang.Object
163    //
164
165    public String toString()
166    {
167        return
168            "SharedCDRContactInfoImpl["
169            + "]";
170    }
171
172    //////////////////////////////////////////////////
173    //
174    // Implementation
175    //
176
177    protected ORBUtilSystemException getWrapper()
178    {
179        if (wrapper == null) {
180            wrapper = ORBUtilSystemException.get( orb,
181                          CORBALogDomains.RPC_TRANSPORT ) ;
182        }
183        return wrapper;
184    }
185}
186
187// End of file.
188