Mon, 17 Jun 2013 11:11:48 +0100
Merge
duke@1 | 1 | /* |
coffeys@475 | 2 | * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@158 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@158 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@158 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@158 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@158 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.corba.se.impl.orb ; |
duke@1 | 27 | |
duke@1 | 28 | import java.net.URL ; |
duke@1 | 29 | import java.net.InetSocketAddress; |
duke@1 | 30 | import java.net.Socket ; |
duke@1 | 31 | import java.net.ServerSocket ; |
duke@1 | 32 | |
duke@1 | 33 | import java.io.IOException ; |
duke@1 | 34 | |
duke@1 | 35 | import java.util.HashMap ; |
duke@1 | 36 | import java.util.List; |
duke@1 | 37 | import java.util.Map ; |
duke@1 | 38 | |
duke@1 | 39 | import java.security.AccessController ; |
duke@1 | 40 | import java.security.PrivilegedExceptionAction ; |
duke@1 | 41 | import java.security.PrivilegedActionException ; |
duke@1 | 42 | |
duke@1 | 43 | import org.omg.PortableInterceptor.ORBInitializer ; |
duke@1 | 44 | import org.omg.PortableInterceptor.ORBInitInfo ; |
duke@1 | 45 | |
duke@1 | 46 | import com.sun.corba.se.pept.broker.Broker; |
duke@1 | 47 | import com.sun.corba.se.pept.encoding.InputObject; |
duke@1 | 48 | import com.sun.corba.se.pept.encoding.OutputObject; |
duke@1 | 49 | import com.sun.corba.se.pept.protocol.MessageMediator; |
duke@1 | 50 | import com.sun.corba.se.pept.transport.Acceptor; |
duke@1 | 51 | import com.sun.corba.se.pept.transport.Connection; |
duke@1 | 52 | import com.sun.corba.se.pept.transport.ContactInfo; |
duke@1 | 53 | import com.sun.corba.se.pept.transport.ContactInfoList; |
duke@1 | 54 | import com.sun.corba.se.pept.transport.EventHandler; |
duke@1 | 55 | import com.sun.corba.se.pept.transport.InboundConnectionCache; |
duke@1 | 56 | |
duke@1 | 57 | import com.sun.corba.se.spi.ior.IOR ; |
duke@1 | 58 | import com.sun.corba.se.spi.ior.ObjectKey ; |
duke@1 | 59 | import com.sun.corba.se.spi.ior.iiop.GIOPVersion ; |
duke@1 | 60 | import com.sun.corba.se.spi.logging.CORBALogDomains ; |
duke@1 | 61 | import com.sun.corba.se.spi.orb.ORB; |
duke@1 | 62 | import com.sun.corba.se.spi.orb.Operation ; |
duke@1 | 63 | import com.sun.corba.se.spi.orb.OperationFactory ; |
duke@1 | 64 | import com.sun.corba.se.spi.orb.ParserData ; |
duke@1 | 65 | import com.sun.corba.se.spi.orb.ParserDataFactory ; |
duke@1 | 66 | import com.sun.corba.se.spi.orb.StringPair ; |
duke@1 | 67 | import com.sun.corba.se.spi.transport.CorbaContactInfoList; |
duke@1 | 68 | import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory; |
duke@1 | 69 | import com.sun.corba.se.spi.transport.CorbaTransportManager; |
duke@1 | 70 | import com.sun.corba.se.spi.transport.IORToSocketInfo; |
duke@1 | 71 | import com.sun.corba.se.spi.transport.ReadTimeouts; |
duke@1 | 72 | import com.sun.corba.se.spi.transport.SocketInfo; |
duke@1 | 73 | import com.sun.corba.se.spi.transport.IIOPPrimaryToContactInfo; |
duke@1 | 74 | import com.sun.corba.se.spi.transport.TransportDefault; |
duke@1 | 75 | |
duke@1 | 76 | import com.sun.corba.se.impl.encoding.CodeSetComponentInfo ; |
duke@1 | 77 | import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry ; |
duke@1 | 78 | import com.sun.corba.se.impl.legacy.connection.USLPort ; |
duke@1 | 79 | import com.sun.corba.se.impl.logging.ORBUtilSystemException ; |
duke@1 | 80 | import com.sun.corba.se.impl.oa.poa.BadServerIdHandler ; |
duke@1 | 81 | import com.sun.corba.se.impl.orbutil.ORBConstants ; |
duke@1 | 82 | import com.sun.corba.se.impl.protocol.giopmsgheaders.KeyAddr ; |
duke@1 | 83 | import com.sun.corba.se.impl.protocol.giopmsgheaders.ProfileAddr ; |
duke@1 | 84 | import com.sun.corba.se.impl.protocol.giopmsgheaders.ReferenceAddr ; |
duke@1 | 85 | import com.sun.corba.se.impl.transport.DefaultIORToSocketInfoImpl; |
duke@1 | 86 | import com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl; |
duke@1 | 87 | |
coffeys@475 | 88 | import sun.corba.SharedSecrets; |
coffeys@475 | 89 | |
duke@1 | 90 | /** Initialize the parser data for the standard ORB parser. This is used both |
duke@1 | 91 | * to implement ORBDataParserImpl and to provide the basic testing framework |
duke@1 | 92 | * for ORBDataParserImpl. |
duke@1 | 93 | */ |
duke@1 | 94 | public class ParserTable { |
duke@1 | 95 | private static String MY_CLASS_NAME = ParserTable.class.getName() ; |
duke@1 | 96 | |
duke@1 | 97 | private static ParserTable myInstance = new ParserTable() ; |
duke@1 | 98 | |
duke@1 | 99 | private ORBUtilSystemException wrapper ; |
duke@1 | 100 | |
duke@1 | 101 | public static ParserTable get() |
duke@1 | 102 | { |
duke@1 | 103 | return myInstance ; |
duke@1 | 104 | } |
duke@1 | 105 | |
duke@1 | 106 | private ParserData[] parserData ; |
duke@1 | 107 | |
duke@1 | 108 | public ParserData[] getParserData() |
duke@1 | 109 | { |
mbankal@371 | 110 | ParserData[] parserArray = new ParserData[parserData.length]; |
mbankal@371 | 111 | System.arraycopy(parserData, 0, parserArray, 0, parserData.length); |
mbankal@371 | 112 | return parserArray; |
duke@1 | 113 | } |
duke@1 | 114 | |
duke@1 | 115 | private ParserTable() { |
duke@1 | 116 | wrapper = ORBUtilSystemException.get( CORBALogDomains.ORB_LIFECYCLE ) ; |
duke@1 | 117 | |
duke@1 | 118 | String codeSetTestString = |
duke@1 | 119 | OSFCodeSetRegistry.ISO_8859_1_VALUE + "," + |
duke@1 | 120 | OSFCodeSetRegistry.UTF_16_VALUE + "," + |
duke@1 | 121 | OSFCodeSetRegistry.ISO_646_VALUE ; |
duke@1 | 122 | |
duke@1 | 123 | String[] debugTestData = { "subcontract", "poa", "transport" } ; |
duke@1 | 124 | |
duke@1 | 125 | USLPort[] USLPorts = { new USLPort( "FOO", 2701 ), new USLPort( "BAR", 3333 ) } ; |
duke@1 | 126 | |
duke@1 | 127 | ReadTimeouts readTimeouts = |
duke@1 | 128 | TransportDefault.makeReadTimeoutsFactory().create( |
duke@1 | 129 | ORBConstants.TRANSPORT_TCP_INITIAL_TIME_TO_WAIT, |
duke@1 | 130 | ORBConstants.TRANSPORT_TCP_MAX_TIME_TO_WAIT, |
duke@1 | 131 | ORBConstants.TRANSPORT_TCP_GIOP_HEADER_MAX_TIME_TO_WAIT, |
duke@1 | 132 | ORBConstants.TRANSPORT_TCP_TIME_TO_WAIT_BACKOFF_FACTOR); |
duke@1 | 133 | |
duke@1 | 134 | ORBInitializer[] TestORBInitializers = |
duke@1 | 135 | { null, |
duke@1 | 136 | new TestORBInitializer1(), |
duke@1 | 137 | new TestORBInitializer2() } ; |
duke@1 | 138 | StringPair[] TestORBInitData = { |
duke@1 | 139 | new StringPair( "foo.bar.blech.NonExistent", "dummy" ), |
duke@1 | 140 | new StringPair( MY_CLASS_NAME + "$TestORBInitializer1", "dummy" ), |
duke@1 | 141 | new StringPair( MY_CLASS_NAME + "$TestORBInitializer2", "dummy" ) } ; |
duke@1 | 142 | |
duke@1 | 143 | Acceptor[] TestAcceptors = |
duke@1 | 144 | { new TestAcceptor2(), |
duke@1 | 145 | new TestAcceptor1(), |
duke@1 | 146 | null } ; |
duke@1 | 147 | // REVISIT: The test data gets put into a Properties object where |
duke@1 | 148 | // order is not guaranteed. Thus the above array is in reverse. |
duke@1 | 149 | StringPair[] TestAcceptorData = { |
duke@1 | 150 | new StringPair( "foo.bar.blech.NonExistent", "dummy" ), |
duke@1 | 151 | new StringPair( MY_CLASS_NAME + "$TestAcceptor1", "dummy" ), |
duke@1 | 152 | new StringPair( MY_CLASS_NAME + "$TestAcceptor2", "dummy" ) } ; |
duke@1 | 153 | |
duke@1 | 154 | StringPair[] TestORBInitRefData = |
duke@1 | 155 | { new StringPair( "Foo", "ior:930492049394" ), |
duke@1 | 156 | new StringPair( "Bar", "ior:3453465785633576" ) } ; |
duke@1 | 157 | |
duke@1 | 158 | URL testServicesURL = null ; |
duke@1 | 159 | String testServicesString = "corbaloc::camelot/NameService" ; |
duke@1 | 160 | |
duke@1 | 161 | try { |
duke@1 | 162 | testServicesURL = new URL( testServicesString ) ; |
duke@1 | 163 | } catch (Exception exc) { |
duke@1 | 164 | } |
duke@1 | 165 | |
duke@1 | 166 | // propertyName, |
duke@1 | 167 | // operation, |
duke@1 | 168 | // fieldName, defaultValue, |
duke@1 | 169 | // testValue, testData (string or Pair[]) |
duke@1 | 170 | ParserData[] pd = { |
duke@1 | 171 | ParserDataFactory.make( ORBConstants.DEBUG_PROPERTY, |
duke@1 | 172 | OperationFactory.listAction( ",", OperationFactory.stringAction()), |
duke@1 | 173 | "debugFlags", new String[0], |
duke@1 | 174 | debugTestData, "subcontract,poa,transport" ), |
duke@1 | 175 | ParserDataFactory.make( ORBConstants.INITIAL_HOST_PROPERTY, |
duke@1 | 176 | OperationFactory.stringAction(), |
duke@1 | 177 | "ORBInitialHost", "", |
duke@1 | 178 | "Foo", "Foo" ), |
duke@1 | 179 | ParserDataFactory.make( ORBConstants.INITIAL_PORT_PROPERTY, |
duke@1 | 180 | OperationFactory.integerAction(), |
duke@1 | 181 | "ORBInitialPort", new Integer( ORBConstants.DEFAULT_INITIAL_PORT ), |
duke@1 | 182 | new Integer( 27314 ), "27314" ), |
duke@1 | 183 | // Where did this come from? |
duke@1 | 184 | //ParserDataFactory.make( ORBConstants.INITIAL_PORT_PROPERTY, |
duke@1 | 185 | //OperationFactory.booleanAction(), |
duke@1 | 186 | //"ORBInitialPortInitialized", Boolean.FALSE, |
duke@1 | 187 | //Boolean.TRUE, "27314" ), |
duke@1 | 188 | ParserDataFactory.make( ORBConstants.SERVER_HOST_PROPERTY, |
duke@1 | 189 | OperationFactory.stringAction(), |
duke@1 | 190 | "ORBServerHost", "", |
duke@1 | 191 | "camelot", "camelot" ), |
duke@1 | 192 | ParserDataFactory.make( ORBConstants.SERVER_PORT_PROPERTY, |
duke@1 | 193 | OperationFactory.integerAction(), |
duke@1 | 194 | "ORBServerPort", new Integer( 0 ), |
duke@1 | 195 | new Integer( 38143 ), "38143" ), |
duke@1 | 196 | // NOTE: We are putting SERVER_HOST_NAME configuration info into |
duke@1 | 197 | // DataCollectorBase to avoid a security hole. However, that forces |
duke@1 | 198 | // us to also set LISTEN_ON_ALL_INTERFACES at the same time. |
duke@1 | 199 | // This all needs to be cleaned up for two reasons: to get configuration |
duke@1 | 200 | // out of DataCollectorBase and to correctly support multihoming. |
duke@1 | 201 | ParserDataFactory.make( ORBConstants.LISTEN_ON_ALL_INTERFACES, |
duke@1 | 202 | OperationFactory.stringAction(), |
duke@1 | 203 | "listenOnAllInterfaces", ORBConstants.LISTEN_ON_ALL_INTERFACES, |
duke@1 | 204 | "foo", "foo" ), |
duke@1 | 205 | ParserDataFactory.make( ORBConstants.ORB_ID_PROPERTY, |
duke@1 | 206 | OperationFactory.stringAction(), |
duke@1 | 207 | "orbId", "", |
duke@1 | 208 | "foo", "foo" ), |
duke@1 | 209 | ParserDataFactory.make( ORBConstants.OLD_ORB_ID_PROPERTY, |
duke@1 | 210 | OperationFactory.stringAction(), |
duke@1 | 211 | "orbId", "", |
duke@1 | 212 | "foo", "foo" ), |
duke@1 | 213 | ParserDataFactory.make( ORBConstants.ORB_SERVER_ID_PROPERTY, |
duke@1 | 214 | OperationFactory.integerAction(), |
duke@1 | 215 | "persistentServerId", new Integer(-1), |
duke@1 | 216 | new Integer( 1234), "1234" ), |
duke@1 | 217 | ParserDataFactory.make( |
duke@1 | 218 | ORBConstants.ORB_SERVER_ID_PROPERTY, |
duke@1 | 219 | OperationFactory.setFlagAction(), |
duke@1 | 220 | "persistentServerIdInitialized", Boolean.FALSE, |
duke@1 | 221 | Boolean.TRUE, "1234" ), |
duke@1 | 222 | ParserDataFactory.make( |
duke@1 | 223 | ORBConstants.ORB_SERVER_ID_PROPERTY, |
duke@1 | 224 | OperationFactory.setFlagAction(), |
duke@1 | 225 | "orbServerIdPropertySpecified", Boolean.FALSE, |
duke@1 | 226 | Boolean.TRUE, "1234" ), |
duke@1 | 227 | // REVISIT after switch |
duke@1 | 228 | // ParserDataFactory.make( ORBConstants.INITIAL_SERVICES_PROPERTY, |
duke@1 | 229 | // OperationFactory.URLAction(), |
duke@1 | 230 | // "servicesURL", null, |
duke@1 | 231 | // testServicesURL, testServicesString ), |
duke@1 | 232 | // ParserDataFactory.make( ORBConstants.DEFAULT_INIT_REF_PROPERTY, |
duke@1 | 233 | // OperationFactory.stringAction(), |
duke@1 | 234 | // "defaultInitRef", null, |
duke@1 | 235 | // "Fooref", "Fooref" ), |
duke@1 | 236 | ParserDataFactory.make( ORBConstants.HIGH_WATER_MARK_PROPERTY, |
duke@1 | 237 | OperationFactory.integerAction(), |
duke@1 | 238 | "highWaterMark", new Integer( 240 ), |
duke@1 | 239 | new Integer( 3745 ), "3745" ), |
duke@1 | 240 | ParserDataFactory.make( ORBConstants.LOW_WATER_MARK_PROPERTY, |
duke@1 | 241 | OperationFactory.integerAction(), |
duke@1 | 242 | "lowWaterMark", new Integer( 100 ), |
duke@1 | 243 | new Integer( 12 ), "12" ), |
duke@1 | 244 | ParserDataFactory.make( ORBConstants.NUMBER_TO_RECLAIM_PROPERTY, |
duke@1 | 245 | OperationFactory.integerAction(), |
duke@1 | 246 | "numberToReclaim", new Integer( 5 ), |
duke@1 | 247 | new Integer( 231 ), "231" ), |
duke@1 | 248 | ParserDataFactory.make( ORBConstants.GIOP_VERSION, |
duke@1 | 249 | makeGVOperation(), |
duke@1 | 250 | "giopVersion", GIOPVersion.DEFAULT_VERSION, |
duke@1 | 251 | new GIOPVersion( 2, 3 ), "2.3" ), |
duke@1 | 252 | ParserDataFactory.make( ORBConstants.GIOP_FRAGMENT_SIZE, |
duke@1 | 253 | makeFSOperation(), "giopFragmentSize", |
duke@1 | 254 | new Integer( ORBConstants.GIOP_DEFAULT_FRAGMENT_SIZE ), |
duke@1 | 255 | new Integer( 65536 ), "65536" ), |
duke@1 | 256 | ParserDataFactory.make( ORBConstants.GIOP_BUFFER_SIZE, |
duke@1 | 257 | OperationFactory.integerAction(), |
duke@1 | 258 | "giopBufferSize", new Integer( ORBConstants.GIOP_DEFAULT_BUFFER_SIZE ), |
duke@1 | 259 | new Integer( 234000 ), "234000" ), |
duke@1 | 260 | ParserDataFactory.make( ORBConstants.GIOP_11_BUFFMGR, |
duke@1 | 261 | makeBMGROperation(), |
duke@1 | 262 | "giop11BuffMgr", new Integer( ORBConstants.DEFAULT_GIOP_11_BUFFMGR ), |
duke@1 | 263 | new Integer( 1 ), "CLCT" ), |
duke@1 | 264 | ParserDataFactory.make( ORBConstants.GIOP_12_BUFFMGR, |
duke@1 | 265 | makeBMGROperation(), |
duke@1 | 266 | "giop12BuffMgr", new Integer( ORBConstants.DEFAULT_GIOP_12_BUFFMGR ), |
duke@1 | 267 | new Integer( 0 ), "GROW" ), |
duke@1 | 268 | |
duke@1 | 269 | // Note that the same property is used to set two different |
duke@1 | 270 | // fields here. This requires that both entries use the same test |
duke@1 | 271 | // data, or the test will fail. |
duke@1 | 272 | ParserDataFactory.make( ORBConstants.GIOP_TARGET_ADDRESSING, |
duke@1 | 273 | OperationFactory.compose( OperationFactory.integerRangeAction( 0, 3 ), |
duke@1 | 274 | OperationFactory.convertIntegerToShort() ), |
duke@1 | 275 | "giopTargetAddressPreference", |
duke@1 | 276 | new Short( ORBConstants.ADDR_DISP_HANDLE_ALL ), |
duke@1 | 277 | new Short( (short)2 ), "2" ), |
duke@1 | 278 | ParserDataFactory.make( ORBConstants.GIOP_TARGET_ADDRESSING, |
duke@1 | 279 | makeADOperation(), |
duke@1 | 280 | "giopAddressDisposition", new Short( KeyAddr.value ), |
duke@1 | 281 | new Short( (short)2 ), "2" ), |
duke@1 | 282 | ParserDataFactory.make( ORBConstants.ALWAYS_SEND_CODESET_CTX_PROPERTY, |
duke@1 | 283 | OperationFactory.booleanAction(), |
duke@1 | 284 | "alwaysSendCodeSetCtx", Boolean.TRUE, |
duke@1 | 285 | Boolean.FALSE, "false"), |
duke@1 | 286 | ParserDataFactory.make( ORBConstants.USE_BOMS, |
duke@1 | 287 | OperationFactory.booleanAction(), |
duke@1 | 288 | "useByteOrderMarkers", |
duke@1 | 289 | Boolean.valueOf( ORBConstants.DEFAULT_USE_BYTE_ORDER_MARKERS ), |
duke@1 | 290 | Boolean.FALSE, "false" ), |
duke@1 | 291 | ParserDataFactory.make( ORBConstants.USE_BOMS_IN_ENCAPS, |
duke@1 | 292 | OperationFactory.booleanAction(), |
duke@1 | 293 | "useByteOrderMarkersInEncaps", |
duke@1 | 294 | Boolean.valueOf( ORBConstants.DEFAULT_USE_BYTE_ORDER_MARKERS_IN_ENCAPS ), |
duke@1 | 295 | Boolean.FALSE, "false" ), |
duke@1 | 296 | ParserDataFactory.make( ORBConstants.CHAR_CODESETS, |
duke@1 | 297 | makeCSOperation(), |
duke@1 | 298 | "charData", CodeSetComponentInfo.JAVASOFT_DEFAULT_CODESETS.getCharComponent(), |
duke@1 | 299 | CodeSetComponentInfo.createFromString( codeSetTestString ), codeSetTestString ), |
duke@1 | 300 | ParserDataFactory.make( ORBConstants.WCHAR_CODESETS, |
duke@1 | 301 | makeCSOperation(), |
duke@1 | 302 | "wcharData", CodeSetComponentInfo.JAVASOFT_DEFAULT_CODESETS.getWCharComponent(), |
duke@1 | 303 | CodeSetComponentInfo.createFromString( codeSetTestString ), codeSetTestString ), |
duke@1 | 304 | ParserDataFactory.make( ORBConstants.ALLOW_LOCAL_OPTIMIZATION, |
duke@1 | 305 | OperationFactory.booleanAction(), |
duke@1 | 306 | "allowLocalOptimization", Boolean.FALSE, |
duke@1 | 307 | Boolean.TRUE, "true" ), |
duke@1 | 308 | ParserDataFactory.make( ORBConstants.LEGACY_SOCKET_FACTORY_CLASS_PROPERTY, |
duke@1 | 309 | makeLegacySocketFactoryOperation(), |
duke@1 | 310 | // No default - must be set by user if they are using |
duke@1 | 311 | // legacy socket factory. |
duke@1 | 312 | "legacySocketFactory", null, |
duke@1 | 313 | new TestLegacyORBSocketFactory(), |
duke@1 | 314 | MY_CLASS_NAME + "$TestLegacyORBSocketFactory" ), |
duke@1 | 315 | ParserDataFactory.make( ORBConstants.SOCKET_FACTORY_CLASS_PROPERTY, |
duke@1 | 316 | makeSocketFactoryOperation(), |
duke@1 | 317 | "socketFactory", new DefaultSocketFactoryImpl(), |
duke@1 | 318 | new TestORBSocketFactory(), |
duke@1 | 319 | MY_CLASS_NAME + "$TestORBSocketFactory" ), |
duke@1 | 320 | ParserDataFactory.make( ORBConstants.LISTEN_SOCKET_PROPERTY, |
duke@1 | 321 | makeUSLOperation() , |
duke@1 | 322 | "userSpecifiedListenPorts", new USLPort[0], |
duke@1 | 323 | USLPorts, "FOO:2701,BAR:3333" ), |
duke@1 | 324 | ParserDataFactory.make( ORBConstants.IOR_TO_SOCKET_INFO_CLASS_PROPERTY, |
duke@1 | 325 | makeIORToSocketInfoOperation(), |
duke@1 | 326 | "iorToSocketInfo", new DefaultIORToSocketInfoImpl(), |
duke@1 | 327 | new TestIORToSocketInfo(), |
duke@1 | 328 | MY_CLASS_NAME + "$TestIORToSocketInfo" ), |
duke@1 | 329 | ParserDataFactory.make( ORBConstants.IIOP_PRIMARY_TO_CONTACT_INFO_CLASS_PROPERTY, |
duke@1 | 330 | makeIIOPPrimaryToContactInfoOperation(), |
duke@1 | 331 | "iiopPrimaryToContactInfo", null, |
duke@1 | 332 | new TestIIOPPrimaryToContactInfo(), |
duke@1 | 333 | MY_CLASS_NAME + "$TestIIOPPrimaryToContactInfo" ), |
duke@1 | 334 | ParserDataFactory.make( ORBConstants.CONTACT_INFO_LIST_FACTORY_CLASS_PROPERTY, |
duke@1 | 335 | makeContactInfoListFactoryOperation(), |
duke@1 | 336 | "corbaContactInfoListFactory", null, |
duke@1 | 337 | new TestContactInfoListFactory(), |
duke@1 | 338 | MY_CLASS_NAME + "$TestContactInfoListFactory" ), |
duke@1 | 339 | ParserDataFactory.make( ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY, |
duke@1 | 340 | OperationFactory.integerAction(), |
duke@1 | 341 | "persistentServerPort", new Integer( 0 ), |
duke@1 | 342 | new Integer( 2743 ), "2743" ), |
duke@1 | 343 | ParserDataFactory.make( ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY, |
duke@1 | 344 | OperationFactory.setFlagAction(), |
duke@1 | 345 | "persistentPortInitialized", Boolean.FALSE, |
duke@1 | 346 | Boolean.TRUE, "2743" ), |
duke@1 | 347 | ParserDataFactory.make( ORBConstants.SERVER_ID_PROPERTY, |
duke@1 | 348 | OperationFactory.integerAction(), |
duke@1 | 349 | "persistentServerId", new Integer( 0 ), |
duke@1 | 350 | new Integer( 294 ), "294" ), |
duke@1 | 351 | ParserDataFactory.make( ORBConstants.SERVER_ID_PROPERTY, |
duke@1 | 352 | OperationFactory.setFlagAction(), |
duke@1 | 353 | "persistentServerIdInitialized", Boolean.FALSE, |
duke@1 | 354 | Boolean.TRUE, "294" ), |
duke@1 | 355 | ParserDataFactory.make( ORBConstants.SERVER_ID_PROPERTY, |
duke@1 | 356 | OperationFactory.setFlagAction(), |
duke@1 | 357 | "orbServerIdPropertySpecified", Boolean.FALSE, |
duke@1 | 358 | Boolean.TRUE, "294" ), |
duke@1 | 359 | ParserDataFactory.make( ORBConstants.ACTIVATED_PROPERTY, |
duke@1 | 360 | OperationFactory.booleanAction(), |
duke@1 | 361 | "serverIsORBActivated", Boolean.FALSE, |
duke@1 | 362 | Boolean.TRUE, "true" ), |
duke@1 | 363 | ParserDataFactory.make( ORBConstants.BAD_SERVER_ID_HANDLER_CLASS_PROPERTY, |
duke@1 | 364 | OperationFactory.classAction(), |
duke@1 | 365 | "badServerIdHandlerClass", null, |
duke@1 | 366 | TestBadServerIdHandler.class, MY_CLASS_NAME + "$TestBadServerIdHandler" ), |
duke@1 | 367 | ParserDataFactory.make( ORBConstants.PI_ORB_INITIALIZER_CLASS_PREFIX, |
duke@1 | 368 | makeROIOperation(), |
duke@1 | 369 | "orbInitializers", new ORBInitializer[0], |
duke@1 | 370 | TestORBInitializers, TestORBInitData, ORBInitializer.class ), |
duke@1 | 371 | ParserDataFactory.make( ORBConstants.ACCEPTOR_CLASS_PREFIX_PROPERTY, |
duke@1 | 372 | makeAcceptorInstantiationOperation(), |
duke@1 | 373 | "acceptors", new Acceptor[0], |
duke@1 | 374 | TestAcceptors, TestAcceptorData, Acceptor.class ), |
duke@1 | 375 | |
duke@1 | 376 | // |
duke@1 | 377 | // Socket/Channel control |
duke@1 | 378 | // |
duke@1 | 379 | |
duke@1 | 380 | // Acceptor: |
duke@1 | 381 | // useNIOSelector == true |
duke@1 | 382 | // useSelectThreadToWait = true |
duke@1 | 383 | // useWorkerThreadForEvent = false |
duke@1 | 384 | // else |
duke@1 | 385 | // useSelectThreadToWait = false |
duke@1 | 386 | // useWorkerThreadForEvent = true |
duke@1 | 387 | |
duke@1 | 388 | // Connection: |
duke@1 | 389 | // useNIOSelector == true |
duke@1 | 390 | // useSelectThreadToWait = true |
duke@1 | 391 | // useWorkerThreadForEvent = true |
duke@1 | 392 | // else |
duke@1 | 393 | // useSelectThreadToWait = false |
duke@1 | 394 | // useWorkerThreadForEvent = true |
duke@1 | 395 | |
duke@1 | 396 | ParserDataFactory.make( ORBConstants.ACCEPTOR_SOCKET_TYPE_PROPERTY, |
duke@1 | 397 | OperationFactory.stringAction(), |
duke@1 | 398 | "acceptorSocketType", ORBConstants.SOCKETCHANNEL, |
duke@1 | 399 | "foo", "foo" ), |
duke@1 | 400 | |
duke@1 | 401 | ParserDataFactory.make( ORBConstants.USE_NIO_SELECT_TO_WAIT_PROPERTY, |
duke@1 | 402 | OperationFactory.booleanAction(), |
duke@1 | 403 | "acceptorSocketUseSelectThreadToWait", Boolean.TRUE, |
duke@1 | 404 | Boolean.TRUE, "true" ), |
duke@1 | 405 | ParserDataFactory.make( ORBConstants.ACCEPTOR_SOCKET_USE_WORKER_THREAD_FOR_EVENT_PROPERTY, |
duke@1 | 406 | OperationFactory.booleanAction(), |
duke@1 | 407 | "acceptorSocketUseWorkerThreadForEvent", Boolean.TRUE, |
duke@1 | 408 | Boolean.TRUE, "true" ), |
duke@1 | 409 | ParserDataFactory.make( ORBConstants.CONNECTION_SOCKET_TYPE_PROPERTY, |
duke@1 | 410 | OperationFactory.stringAction(), |
duke@1 | 411 | "connectionSocketType", ORBConstants.SOCKETCHANNEL, |
duke@1 | 412 | "foo", "foo" ), |
duke@1 | 413 | ParserDataFactory.make( ORBConstants.USE_NIO_SELECT_TO_WAIT_PROPERTY, |
duke@1 | 414 | OperationFactory.booleanAction(), |
duke@1 | 415 | "connectionSocketUseSelectThreadToWait", Boolean.TRUE, |
duke@1 | 416 | Boolean.TRUE, "true" ), |
duke@1 | 417 | ParserDataFactory.make( ORBConstants.CONNECTION_SOCKET_USE_WORKER_THREAD_FOR_EVENT_PROPERTY, |
duke@1 | 418 | OperationFactory.booleanAction(), |
duke@1 | 419 | "connectionSocketUseWorkerThreadForEvent", Boolean.TRUE, |
duke@1 | 420 | Boolean.TRUE, "true" ), |
duke@1 | 421 | ParserDataFactory.make( ORBConstants.DISABLE_DIRECT_BYTE_BUFFER_USE_PROPERTY, |
duke@1 | 422 | OperationFactory.booleanAction(), |
duke@1 | 423 | "disableDirectByteBufferUse", Boolean.FALSE, |
duke@1 | 424 | Boolean.TRUE, "true" ), |
duke@1 | 425 | ParserDataFactory.make(ORBConstants.TRANSPORT_TCP_READ_TIMEOUTS_PROPERTY, |
duke@1 | 426 | makeTTCPRTOperation(), |
duke@1 | 427 | "readTimeouts", TransportDefault.makeReadTimeoutsFactory().create( |
duke@1 | 428 | ORBConstants.TRANSPORT_TCP_INITIAL_TIME_TO_WAIT, |
duke@1 | 429 | ORBConstants.TRANSPORT_TCP_MAX_TIME_TO_WAIT, |
duke@1 | 430 | ORBConstants.TRANSPORT_TCP_GIOP_HEADER_MAX_TIME_TO_WAIT, |
duke@1 | 431 | ORBConstants.TRANSPORT_TCP_TIME_TO_WAIT_BACKOFF_FACTOR), |
duke@1 | 432 | readTimeouts, "100:3000:300:20" ), |
duke@1 | 433 | ParserDataFactory.make( |
duke@1 | 434 | ORBConstants.ENABLE_JAVA_SERIALIZATION_PROPERTY, |
duke@1 | 435 | OperationFactory.booleanAction(), |
duke@1 | 436 | "enableJavaSerialization", Boolean.FALSE, |
duke@1 | 437 | Boolean.FALSE, "false"), |
duke@1 | 438 | ParserDataFactory.make( |
duke@1 | 439 | ORBConstants.USE_REP_ID, |
duke@1 | 440 | OperationFactory.booleanAction(), |
duke@1 | 441 | "useRepId", Boolean.TRUE, |
duke@1 | 442 | Boolean.TRUE, "true"), |
duke@1 | 443 | ParserDataFactory.make( ORBConstants.ORB_INIT_REF_PROPERTY, |
duke@1 | 444 | OperationFactory.identityAction(), |
duke@1 | 445 | "orbInitialReferences", new StringPair[0], |
duke@1 | 446 | TestORBInitRefData, TestORBInitRefData, StringPair.class ) |
duke@1 | 447 | } ; |
duke@1 | 448 | |
duke@1 | 449 | parserData = pd ; |
duke@1 | 450 | } |
duke@1 | 451 | |
duke@1 | 452 | public final class TestBadServerIdHandler implements BadServerIdHandler |
duke@1 | 453 | { |
duke@1 | 454 | public boolean equals( Object other ) |
duke@1 | 455 | { |
duke@1 | 456 | return other instanceof TestBadServerIdHandler ; |
duke@1 | 457 | } |
duke@1 | 458 | |
alanb@473 | 459 | public int hashCode() { |
alanb@473 | 460 | return 1; |
alanb@473 | 461 | } |
alanb@473 | 462 | |
duke@1 | 463 | public void handle( ObjectKey objectKey ) |
duke@1 | 464 | { |
duke@1 | 465 | } |
duke@1 | 466 | } |
duke@1 | 467 | |
duke@1 | 468 | private Operation makeTTCPRTOperation() |
duke@1 | 469 | { |
duke@1 | 470 | Operation[] fourIop = { OperationFactory.integerAction(), |
duke@1 | 471 | OperationFactory.integerAction(), |
duke@1 | 472 | OperationFactory.integerAction(), |
duke@1 | 473 | OperationFactory.integerAction() } ; |
duke@1 | 474 | |
duke@1 | 475 | Operation op2 = OperationFactory.sequenceAction( ":", fourIop ) ; |
duke@1 | 476 | |
duke@1 | 477 | Operation rtOp = new Operation() { |
duke@1 | 478 | public Object operate(Object value) |
duke@1 | 479 | { |
duke@1 | 480 | Object[] values = (Object[])value ; |
duke@1 | 481 | Integer initialTime = (Integer)(values[0]) ; |
duke@1 | 482 | Integer maxGIOPHdrTime = (Integer)(values[1]) ; |
duke@1 | 483 | Integer maxGIOPBodyTime = (Integer)(values[2]) ; |
duke@1 | 484 | Integer backoffPercent = (Integer)(values[3]) ; |
duke@1 | 485 | return TransportDefault.makeReadTimeoutsFactory().create( |
duke@1 | 486 | initialTime.intValue(), |
duke@1 | 487 | maxGIOPHdrTime.intValue(), |
duke@1 | 488 | maxGIOPBodyTime.intValue(), |
duke@1 | 489 | backoffPercent.intValue()); |
duke@1 | 490 | } |
duke@1 | 491 | } ; |
duke@1 | 492 | |
duke@1 | 493 | Operation ttcprtOp = OperationFactory.compose(op2, rtOp); |
duke@1 | 494 | return ttcprtOp; |
duke@1 | 495 | } |
duke@1 | 496 | |
duke@1 | 497 | private Operation makeUSLOperation() |
duke@1 | 498 | { |
duke@1 | 499 | Operation[] siop = { OperationFactory.stringAction(), |
duke@1 | 500 | OperationFactory.integerAction() } ; |
duke@1 | 501 | Operation op2 = OperationFactory.sequenceAction( ":", siop ) ; |
duke@1 | 502 | |
duke@1 | 503 | Operation uslop = new Operation() { |
duke@1 | 504 | public Object operate( Object value ) |
duke@1 | 505 | { |
duke@1 | 506 | Object[] values = (Object[])value ; |
duke@1 | 507 | String type = (String)(values[0]) ; |
duke@1 | 508 | Integer port = (Integer)(values[1]) ; |
duke@1 | 509 | return new USLPort( type, port.intValue() ) ; |
duke@1 | 510 | } |
duke@1 | 511 | } ; |
duke@1 | 512 | |
duke@1 | 513 | Operation op3 = OperationFactory.compose( op2, uslop ) ; |
duke@1 | 514 | Operation listenop = OperationFactory.listAction( ",", op3 ) ; |
duke@1 | 515 | return listenop ; |
duke@1 | 516 | } |
duke@1 | 517 | |
duke@1 | 518 | public static final class TestLegacyORBSocketFactory |
duke@1 | 519 | implements com.sun.corba.se.spi.legacy.connection.ORBSocketFactory |
duke@1 | 520 | { |
duke@1 | 521 | public boolean equals( Object other ) |
duke@1 | 522 | { |
duke@1 | 523 | return other instanceof TestLegacyORBSocketFactory ; |
duke@1 | 524 | } |
duke@1 | 525 | |
alanb@473 | 526 | public int hashCode() { |
alanb@473 | 527 | return 1; |
alanb@473 | 528 | } |
alanb@473 | 529 | |
duke@1 | 530 | public ServerSocket createServerSocket( String type, int port ) |
duke@1 | 531 | { |
duke@1 | 532 | return null ; |
duke@1 | 533 | } |
duke@1 | 534 | |
duke@1 | 535 | public SocketInfo getEndPointInfo( org.omg.CORBA.ORB orb, |
duke@1 | 536 | IOR ior, SocketInfo socketInfo ) |
duke@1 | 537 | { |
duke@1 | 538 | return null ; |
duke@1 | 539 | } |
duke@1 | 540 | |
duke@1 | 541 | public Socket createSocket( SocketInfo socketInfo ) |
duke@1 | 542 | { |
duke@1 | 543 | return null ; |
duke@1 | 544 | } |
duke@1 | 545 | } |
duke@1 | 546 | |
duke@1 | 547 | public static final class TestORBSocketFactory |
duke@1 | 548 | implements com.sun.corba.se.spi.transport.ORBSocketFactory |
duke@1 | 549 | { |
duke@1 | 550 | public boolean equals( Object other ) |
duke@1 | 551 | { |
duke@1 | 552 | return other instanceof TestORBSocketFactory ; |
duke@1 | 553 | } |
duke@1 | 554 | |
alanb@473 | 555 | public int hashCode() { |
alanb@473 | 556 | return 1; |
alanb@473 | 557 | } |
alanb@473 | 558 | |
duke@1 | 559 | public void setORB(ORB orb) |
duke@1 | 560 | { |
duke@1 | 561 | } |
duke@1 | 562 | |
duke@1 | 563 | public ServerSocket createServerSocket( String type, InetSocketAddress a ) |
duke@1 | 564 | { |
duke@1 | 565 | return null ; |
duke@1 | 566 | } |
duke@1 | 567 | |
duke@1 | 568 | public Socket createSocket( String type, InetSocketAddress a ) |
duke@1 | 569 | { |
duke@1 | 570 | return null ; |
duke@1 | 571 | } |
duke@1 | 572 | |
duke@1 | 573 | public void setAcceptedSocketOptions(Acceptor acceptor, |
duke@1 | 574 | ServerSocket serverSocket, |
duke@1 | 575 | Socket socket) |
duke@1 | 576 | { |
duke@1 | 577 | } |
duke@1 | 578 | } |
duke@1 | 579 | |
duke@1 | 580 | public static final class TestIORToSocketInfo |
duke@1 | 581 | implements IORToSocketInfo |
duke@1 | 582 | { |
duke@1 | 583 | public boolean equals( Object other ) |
duke@1 | 584 | { |
duke@1 | 585 | return other instanceof TestIORToSocketInfo; |
duke@1 | 586 | } |
duke@1 | 587 | |
alanb@473 | 588 | public int hashCode() { |
alanb@473 | 589 | return 1; |
alanb@473 | 590 | } |
alanb@473 | 591 | |
duke@1 | 592 | public List getSocketInfo(IOR ior) |
duke@1 | 593 | { |
duke@1 | 594 | return null; |
duke@1 | 595 | } |
duke@1 | 596 | } |
duke@1 | 597 | |
duke@1 | 598 | public static final class TestIIOPPrimaryToContactInfo |
duke@1 | 599 | implements IIOPPrimaryToContactInfo |
duke@1 | 600 | { |
duke@1 | 601 | public void reset(ContactInfo primary) |
duke@1 | 602 | { |
duke@1 | 603 | } |
duke@1 | 604 | |
duke@1 | 605 | public boolean hasNext(ContactInfo primary, |
duke@1 | 606 | ContactInfo previous, |
duke@1 | 607 | List contactInfos) |
duke@1 | 608 | { |
duke@1 | 609 | return true; |
duke@1 | 610 | } |
duke@1 | 611 | |
duke@1 | 612 | public ContactInfo next(ContactInfo primary, |
duke@1 | 613 | ContactInfo previous, |
duke@1 | 614 | List contactInfos) |
duke@1 | 615 | { |
duke@1 | 616 | return null; |
duke@1 | 617 | } |
duke@1 | 618 | } |
duke@1 | 619 | |
duke@1 | 620 | public static final class TestContactInfoListFactory |
duke@1 | 621 | implements CorbaContactInfoListFactory |
duke@1 | 622 | { |
duke@1 | 623 | public boolean equals( Object other ) |
duke@1 | 624 | { |
duke@1 | 625 | return other instanceof TestContactInfoListFactory; |
duke@1 | 626 | } |
duke@1 | 627 | |
alanb@473 | 628 | public int hashCode() { |
alanb@473 | 629 | return 1; |
alanb@473 | 630 | } |
alanb@473 | 631 | |
duke@1 | 632 | public void setORB(ORB orb) { } |
duke@1 | 633 | |
duke@1 | 634 | public CorbaContactInfoList create( IOR ior ) { return null; } |
duke@1 | 635 | } |
duke@1 | 636 | |
duke@1 | 637 | private Operation makeMapOperation( final Map map ) |
duke@1 | 638 | { |
duke@1 | 639 | return new Operation() { |
duke@1 | 640 | public Object operate( Object value ) |
duke@1 | 641 | { |
duke@1 | 642 | return map.get( value ) ; |
duke@1 | 643 | } |
duke@1 | 644 | } ; |
duke@1 | 645 | } |
duke@1 | 646 | |
duke@1 | 647 | private Operation makeBMGROperation() |
duke@1 | 648 | { |
duke@1 | 649 | Map map = new HashMap() ; |
duke@1 | 650 | map.put( "GROW", new Integer(0) ) ; |
duke@1 | 651 | map.put( "CLCT", new Integer(1) ) ; |
duke@1 | 652 | map.put( "STRM", new Integer(2) ) ; |
duke@1 | 653 | return makeMapOperation( map ) ; |
duke@1 | 654 | } |
duke@1 | 655 | |
duke@1 | 656 | private Operation makeLegacySocketFactoryOperation() |
duke@1 | 657 | { |
duke@1 | 658 | Operation sfop = new Operation() { |
duke@1 | 659 | public Object operate( Object value ) |
duke@1 | 660 | { |
duke@1 | 661 | String param = (String)value ; |
duke@1 | 662 | |
duke@1 | 663 | try { |
coffeys@475 | 664 | Class<?> legacySocketFactoryClass = |
coffeys@475 | 665 | SharedSecrets.getJavaCorbaAccess().loadClass(param); |
duke@1 | 666 | // For security reasons avoid creating an instance if |
duke@1 | 667 | // this socket factory class is not one that would fail |
duke@1 | 668 | // the class cast anyway. |
duke@1 | 669 | if (com.sun.corba.se.spi.legacy.connection.ORBSocketFactory.class.isAssignableFrom(legacySocketFactoryClass)) { |
duke@1 | 670 | return legacySocketFactoryClass.newInstance(); |
duke@1 | 671 | } else { |
duke@1 | 672 | throw wrapper.illegalSocketFactoryType( legacySocketFactoryClass.toString() ) ; |
duke@1 | 673 | } |
duke@1 | 674 | } catch (Exception ex) { |
duke@1 | 675 | // ClassNotFoundException, IllegalAccessException, |
duke@1 | 676 | // InstantiationException, SecurityException or |
duke@1 | 677 | // ClassCastException |
duke@1 | 678 | throw wrapper.badCustomSocketFactory( ex, param ) ; |
duke@1 | 679 | } |
duke@1 | 680 | } |
duke@1 | 681 | } ; |
duke@1 | 682 | |
duke@1 | 683 | return sfop ; |
duke@1 | 684 | } |
duke@1 | 685 | |
duke@1 | 686 | private Operation makeSocketFactoryOperation() |
duke@1 | 687 | { |
duke@1 | 688 | Operation sfop = new Operation() { |
duke@1 | 689 | public Object operate( Object value ) |
duke@1 | 690 | { |
duke@1 | 691 | String param = (String)value ; |
duke@1 | 692 | |
duke@1 | 693 | try { |
coffeys@475 | 694 | Class<?> socketFactoryClass = |
coffeys@475 | 695 | SharedSecrets.getJavaCorbaAccess().loadClass(param); |
duke@1 | 696 | // For security reasons avoid creating an instance if |
duke@1 | 697 | // this socket factory class is not one that would fail |
duke@1 | 698 | // the class cast anyway. |
duke@1 | 699 | if (com.sun.corba.se.spi.transport.ORBSocketFactory.class.isAssignableFrom(socketFactoryClass)) { |
duke@1 | 700 | return socketFactoryClass.newInstance(); |
duke@1 | 701 | } else { |
duke@1 | 702 | throw wrapper.illegalSocketFactoryType( socketFactoryClass.toString() ) ; |
duke@1 | 703 | } |
duke@1 | 704 | } catch (Exception ex) { |
duke@1 | 705 | // ClassNotFoundException, IllegalAccessException, |
duke@1 | 706 | // InstantiationException, SecurityException or |
duke@1 | 707 | // ClassCastException |
duke@1 | 708 | throw wrapper.badCustomSocketFactory( ex, param ) ; |
duke@1 | 709 | } |
duke@1 | 710 | } |
duke@1 | 711 | } ; |
duke@1 | 712 | |
duke@1 | 713 | return sfop ; |
duke@1 | 714 | } |
duke@1 | 715 | |
duke@1 | 716 | private Operation makeIORToSocketInfoOperation() |
duke@1 | 717 | { |
duke@1 | 718 | Operation op = new Operation() { |
duke@1 | 719 | public Object operate( Object value ) |
duke@1 | 720 | { |
duke@1 | 721 | String param = (String)value ; |
duke@1 | 722 | |
duke@1 | 723 | try { |
coffeys@475 | 724 | Class<?> iorToSocketInfoClass = |
coffeys@475 | 725 | SharedSecrets.getJavaCorbaAccess().loadClass(param); |
duke@1 | 726 | // For security reasons avoid creating an instance if |
duke@1 | 727 | // this socket factory class is not one that would fail |
duke@1 | 728 | // the class cast anyway. |
duke@1 | 729 | if (IORToSocketInfo.class.isAssignableFrom(iorToSocketInfoClass)) { |
duke@1 | 730 | return iorToSocketInfoClass.newInstance(); |
duke@1 | 731 | } else { |
duke@1 | 732 | throw wrapper.illegalIorToSocketInfoType( iorToSocketInfoClass.toString() ) ; |
duke@1 | 733 | } |
duke@1 | 734 | } catch (Exception ex) { |
duke@1 | 735 | // ClassNotFoundException, IllegalAccessException, |
duke@1 | 736 | // InstantiationException, SecurityException or |
duke@1 | 737 | // ClassCastException |
duke@1 | 738 | throw wrapper.badCustomIorToSocketInfo( ex, param ) ; |
duke@1 | 739 | } |
duke@1 | 740 | } |
duke@1 | 741 | } ; |
duke@1 | 742 | |
duke@1 | 743 | return op ; |
duke@1 | 744 | } |
duke@1 | 745 | |
duke@1 | 746 | private Operation makeIIOPPrimaryToContactInfoOperation() |
duke@1 | 747 | { |
duke@1 | 748 | Operation op = new Operation() { |
duke@1 | 749 | public Object operate( Object value ) |
duke@1 | 750 | { |
duke@1 | 751 | String param = (String)value ; |
duke@1 | 752 | |
duke@1 | 753 | try { |
coffeys@475 | 754 | Class<?> iiopPrimaryToContactInfoClass = |
coffeys@475 | 755 | SharedSecrets.getJavaCorbaAccess().loadClass(param); |
duke@1 | 756 | // For security reasons avoid creating an instance if |
duke@1 | 757 | // this socket factory class is not one that would fail |
duke@1 | 758 | // the class cast anyway. |
duke@1 | 759 | if (IIOPPrimaryToContactInfo.class.isAssignableFrom(iiopPrimaryToContactInfoClass)) { |
duke@1 | 760 | return iiopPrimaryToContactInfoClass.newInstance(); |
duke@1 | 761 | } else { |
duke@1 | 762 | throw wrapper.illegalIiopPrimaryToContactInfoType( iiopPrimaryToContactInfoClass.toString() ) ; |
duke@1 | 763 | } |
duke@1 | 764 | } catch (Exception ex) { |
duke@1 | 765 | // ClassNotFoundException, IllegalAccessException, |
duke@1 | 766 | // InstantiationException, SecurityException or |
duke@1 | 767 | // ClassCastException |
duke@1 | 768 | throw wrapper.badCustomIiopPrimaryToContactInfo( ex, param ) ; |
duke@1 | 769 | } |
duke@1 | 770 | } |
duke@1 | 771 | } ; |
duke@1 | 772 | |
duke@1 | 773 | return op ; |
duke@1 | 774 | } |
duke@1 | 775 | |
duke@1 | 776 | private Operation makeContactInfoListFactoryOperation() |
duke@1 | 777 | { |
duke@1 | 778 | Operation op = new Operation() { |
duke@1 | 779 | public Object operate( Object value ) |
duke@1 | 780 | { |
duke@1 | 781 | String param = (String)value ; |
duke@1 | 782 | |
duke@1 | 783 | try { |
coffeys@475 | 784 | Class<?> contactInfoListFactoryClass = |
coffeys@475 | 785 | SharedSecrets.getJavaCorbaAccess().loadClass(param); |
duke@1 | 786 | // For security reasons avoid creating an instance if |
duke@1 | 787 | // this socket factory class is not one that would fail |
duke@1 | 788 | // the class cast anyway. |
duke@1 | 789 | if (CorbaContactInfoListFactory.class.isAssignableFrom( |
duke@1 | 790 | contactInfoListFactoryClass)) { |
duke@1 | 791 | return contactInfoListFactoryClass.newInstance(); |
duke@1 | 792 | } else { |
duke@1 | 793 | throw wrapper.illegalContactInfoListFactoryType( |
duke@1 | 794 | contactInfoListFactoryClass.toString() ) ; |
duke@1 | 795 | } |
duke@1 | 796 | } catch (Exception ex) { |
duke@1 | 797 | // ClassNotFoundException, IllegalAccessException, |
duke@1 | 798 | // InstantiationException, SecurityException or |
duke@1 | 799 | // ClassCastException |
duke@1 | 800 | throw wrapper.badContactInfoListFactory( ex, param ) ; |
duke@1 | 801 | } |
duke@1 | 802 | } |
duke@1 | 803 | } ; |
duke@1 | 804 | |
duke@1 | 805 | return op ; |
duke@1 | 806 | } |
duke@1 | 807 | |
duke@1 | 808 | private Operation makeCSOperation() |
duke@1 | 809 | { |
duke@1 | 810 | Operation csop = new Operation() { |
duke@1 | 811 | public Object operate( Object value ) |
duke@1 | 812 | { |
duke@1 | 813 | String val = (String)value ; |
duke@1 | 814 | return CodeSetComponentInfo.createFromString( val ) ; |
duke@1 | 815 | } |
duke@1 | 816 | } ; |
duke@1 | 817 | |
duke@1 | 818 | return csop ; |
duke@1 | 819 | } |
duke@1 | 820 | |
duke@1 | 821 | private Operation makeADOperation() |
duke@1 | 822 | { |
duke@1 | 823 | Operation admap = new Operation() { |
duke@1 | 824 | private Integer[] map = { |
duke@1 | 825 | new Integer( KeyAddr.value ), |
duke@1 | 826 | new Integer( ProfileAddr.value ), |
duke@1 | 827 | new Integer( ReferenceAddr.value ), |
duke@1 | 828 | new Integer( KeyAddr.value ) } ; |
duke@1 | 829 | |
duke@1 | 830 | public Object operate( Object value ) |
duke@1 | 831 | { |
duke@1 | 832 | int val = ((Integer)value).intValue() ; |
duke@1 | 833 | return map[val] ; |
duke@1 | 834 | } |
duke@1 | 835 | } ; |
duke@1 | 836 | |
duke@1 | 837 | Operation rangeop = OperationFactory.integerRangeAction( 0, 3 ) ; |
duke@1 | 838 | Operation op1 = OperationFactory.compose( rangeop, admap ) ; |
duke@1 | 839 | Operation result = OperationFactory.compose( op1, OperationFactory.convertIntegerToShort() ) ; |
duke@1 | 840 | return result ; |
duke@1 | 841 | } |
duke@1 | 842 | |
duke@1 | 843 | private Operation makeFSOperation() { |
duke@1 | 844 | Operation fschecker = new Operation() { |
duke@1 | 845 | public Object operate( Object value ) |
duke@1 | 846 | { |
duke@1 | 847 | int giopFragmentSize = ((Integer)value).intValue() ; |
duke@1 | 848 | if (giopFragmentSize < ORBConstants.GIOP_FRAGMENT_MINIMUM_SIZE){ |
duke@1 | 849 | throw wrapper.fragmentSizeMinimum( new Integer( giopFragmentSize ), |
duke@1 | 850 | new Integer( ORBConstants.GIOP_FRAGMENT_MINIMUM_SIZE ) ) ; |
duke@1 | 851 | } |
duke@1 | 852 | |
duke@1 | 853 | if (giopFragmentSize % ORBConstants.GIOP_FRAGMENT_DIVISOR != 0) |
duke@1 | 854 | throw wrapper.fragmentSizeDiv( new Integer( giopFragmentSize ), |
duke@1 | 855 | new Integer( ORBConstants.GIOP_FRAGMENT_DIVISOR ) ) ; |
duke@1 | 856 | |
duke@1 | 857 | return value ; |
duke@1 | 858 | } |
duke@1 | 859 | } ; |
duke@1 | 860 | |
duke@1 | 861 | Operation result = OperationFactory.compose( OperationFactory.integerAction(), |
duke@1 | 862 | fschecker ) ; |
duke@1 | 863 | return result ; |
duke@1 | 864 | } |
duke@1 | 865 | |
duke@1 | 866 | private Operation makeGVOperation() { |
duke@1 | 867 | Operation gvHelper = OperationFactory.listAction( ".", |
duke@1 | 868 | OperationFactory.integerAction() ) ; |
duke@1 | 869 | Operation gvMain = new Operation() { |
duke@1 | 870 | public Object operate( Object value ) |
duke@1 | 871 | { |
duke@1 | 872 | Object[] nums = (Object[])value ; |
duke@1 | 873 | int major = ((Integer)(nums[0])).intValue() ; |
duke@1 | 874 | int minor = ((Integer)(nums[1])).intValue() ; |
duke@1 | 875 | |
duke@1 | 876 | return new GIOPVersion( major, minor ) ; |
duke@1 | 877 | } |
duke@1 | 878 | } ; |
duke@1 | 879 | |
duke@1 | 880 | Operation result = OperationFactory.compose( gvHelper, gvMain ); |
duke@1 | 881 | return result ; |
duke@1 | 882 | } |
duke@1 | 883 | |
duke@1 | 884 | public static final class TestORBInitializer1 extends org.omg.CORBA.LocalObject |
duke@1 | 885 | implements ORBInitializer |
duke@1 | 886 | { |
duke@1 | 887 | public boolean equals( Object other ) |
duke@1 | 888 | { |
duke@1 | 889 | return other instanceof TestORBInitializer1 ; |
duke@1 | 890 | } |
duke@1 | 891 | |
alanb@473 | 892 | public int hashCode() { |
alanb@473 | 893 | return 1; |
alanb@473 | 894 | } |
alanb@473 | 895 | |
duke@1 | 896 | public void pre_init( ORBInitInfo info ) |
duke@1 | 897 | { |
duke@1 | 898 | } |
duke@1 | 899 | |
duke@1 | 900 | public void post_init( ORBInitInfo info ) |
duke@1 | 901 | { |
duke@1 | 902 | } |
duke@1 | 903 | } |
duke@1 | 904 | |
duke@1 | 905 | public static final class TestORBInitializer2 extends org.omg.CORBA.LocalObject |
duke@1 | 906 | implements ORBInitializer |
duke@1 | 907 | { |
duke@1 | 908 | public boolean equals( Object other ) |
duke@1 | 909 | { |
duke@1 | 910 | return other instanceof TestORBInitializer2 ; |
duke@1 | 911 | } |
duke@1 | 912 | |
alanb@473 | 913 | public int hashCode() { |
alanb@473 | 914 | return 1; |
alanb@473 | 915 | } |
alanb@473 | 916 | |
duke@1 | 917 | public void pre_init( ORBInitInfo info ) |
duke@1 | 918 | { |
duke@1 | 919 | } |
duke@1 | 920 | |
duke@1 | 921 | public void post_init( ORBInitInfo info ) |
duke@1 | 922 | { |
duke@1 | 923 | } |
duke@1 | 924 | } |
duke@1 | 925 | |
duke@1 | 926 | private Operation makeROIOperation() { |
duke@1 | 927 | Operation clsop = OperationFactory.classAction() ; |
duke@1 | 928 | Operation indexOp = OperationFactory.suffixAction() ; |
duke@1 | 929 | Operation op1 = OperationFactory.compose( indexOp, clsop ) ; |
duke@1 | 930 | Operation mop = OperationFactory.maskErrorAction( op1 ) ; |
duke@1 | 931 | |
duke@1 | 932 | Operation mkinst = new Operation() { |
duke@1 | 933 | public Object operate( Object value ) |
duke@1 | 934 | { |
duke@1 | 935 | final Class initClass = (Class)value ; |
duke@1 | 936 | if (initClass == null) |
duke@1 | 937 | return null ; |
duke@1 | 938 | |
duke@1 | 939 | // For security reasons avoid creating an instance |
duke@1 | 940 | // if this class is one that would fail the class cast |
duke@1 | 941 | // to ORBInitializer anyway. |
duke@1 | 942 | if( org.omg.PortableInterceptor.ORBInitializer.class.isAssignableFrom( |
duke@1 | 943 | initClass ) ) { |
duke@1 | 944 | // Now that we have a class object, instantiate one and |
duke@1 | 945 | // remember it: |
duke@1 | 946 | ORBInitializer initializer = null ; |
duke@1 | 947 | |
duke@1 | 948 | try { |
duke@1 | 949 | initializer = (ORBInitializer)AccessController.doPrivileged( |
duke@1 | 950 | new PrivilegedExceptionAction() { |
duke@1 | 951 | public Object run() |
duke@1 | 952 | throws InstantiationException, IllegalAccessException |
duke@1 | 953 | { |
duke@1 | 954 | return initClass.newInstance() ; |
duke@1 | 955 | } |
duke@1 | 956 | } |
duke@1 | 957 | ) ; |
duke@1 | 958 | } catch (PrivilegedActionException exc) { |
duke@1 | 959 | // Unwrap the exception, as we don't care exc here |
duke@1 | 960 | throw wrapper.orbInitializerFailure( exc.getException(), |
duke@1 | 961 | initClass.getName() ) ; |
duke@1 | 962 | } catch (Exception exc) { |
duke@1 | 963 | throw wrapper.orbInitializerFailure( exc, initClass.getName() ) ; |
duke@1 | 964 | } |
duke@1 | 965 | |
duke@1 | 966 | return initializer ; |
duke@1 | 967 | } else { |
duke@1 | 968 | throw wrapper.orbInitializerType( initClass.getName() ) ; |
duke@1 | 969 | } |
duke@1 | 970 | } |
duke@1 | 971 | } ; |
duke@1 | 972 | |
duke@1 | 973 | Operation result = OperationFactory.compose( mop, mkinst ) ; |
duke@1 | 974 | |
duke@1 | 975 | return result ; |
duke@1 | 976 | } |
duke@1 | 977 | |
duke@1 | 978 | public static final class TestAcceptor1 |
duke@1 | 979 | implements Acceptor |
duke@1 | 980 | { |
duke@1 | 981 | public boolean equals( Object other ) |
duke@1 | 982 | { |
duke@1 | 983 | return other instanceof TestAcceptor1 ; |
duke@1 | 984 | } |
alanb@473 | 985 | |
alanb@473 | 986 | public int hashCode() { return 1; } |
duke@1 | 987 | public boolean initialize() { return true; } |
duke@1 | 988 | public boolean initialized() { return true; } |
duke@1 | 989 | public String getConnectionCacheType() { return "FOO"; } |
duke@1 | 990 | public void setConnectionCache(InboundConnectionCache connectionCache){} |
duke@1 | 991 | public InboundConnectionCache getConnectionCache() { return null; } |
duke@1 | 992 | public boolean shouldRegisterAcceptEvent() { return true; } |
duke@1 | 993 | public void setUseSelectThreadForConnections(boolean x) { } |
duke@1 | 994 | public boolean shouldUseSelectThreadForConnections() { return true; } |
duke@1 | 995 | public void setUseWorkerThreadForConnections(boolean x) { } |
duke@1 | 996 | public boolean shouldUseWorkerThreadForConnections() { return true; } |
duke@1 | 997 | public void accept() { } |
duke@1 | 998 | public void close() { } |
duke@1 | 999 | public EventHandler getEventHandler() { return null; } |
duke@1 | 1000 | public MessageMediator createMessageMediator( |
duke@1 | 1001 | Broker xbroker, Connection xconnection) { return null; } |
duke@1 | 1002 | public MessageMediator finishCreatingMessageMediator( |
duke@1 | 1003 | Broker xbroker, Connection xconnection, |
duke@1 | 1004 | MessageMediator messageMediator) { return null; } |
duke@1 | 1005 | public InputObject createInputObject( |
duke@1 | 1006 | Broker broker, MessageMediator messageMediator) { return null; } |
duke@1 | 1007 | public OutputObject createOutputObject( |
duke@1 | 1008 | Broker broker, MessageMediator messageMediator) { return null; } |
duke@1 | 1009 | } |
duke@1 | 1010 | |
duke@1 | 1011 | public static final class TestAcceptor2 |
duke@1 | 1012 | implements Acceptor |
duke@1 | 1013 | { |
duke@1 | 1014 | public boolean equals( Object other ) |
duke@1 | 1015 | { |
duke@1 | 1016 | return other instanceof TestAcceptor2 ; |
duke@1 | 1017 | } |
alanb@473 | 1018 | public int hashCode() { return 1; } |
duke@1 | 1019 | public boolean initialize() { return true; } |
duke@1 | 1020 | public boolean initialized() { return true; } |
duke@1 | 1021 | public String getConnectionCacheType() { return "FOO"; } |
duke@1 | 1022 | public void setConnectionCache(InboundConnectionCache connectionCache){} |
duke@1 | 1023 | public InboundConnectionCache getConnectionCache() { return null; } |
duke@1 | 1024 | public boolean shouldRegisterAcceptEvent() { return true; } |
duke@1 | 1025 | public void setUseSelectThreadForConnections(boolean x) { } |
duke@1 | 1026 | public boolean shouldUseSelectThreadForConnections() { return true; } |
duke@1 | 1027 | public void setUseWorkerThreadForConnections(boolean x) { } |
duke@1 | 1028 | public boolean shouldUseWorkerThreadForConnections() { return true; } |
duke@1 | 1029 | public void accept() { } |
duke@1 | 1030 | public void close() { } |
duke@1 | 1031 | public EventHandler getEventHandler() { return null; } |
duke@1 | 1032 | public MessageMediator createMessageMediator( |
duke@1 | 1033 | Broker xbroker, Connection xconnection) { return null; } |
duke@1 | 1034 | public MessageMediator finishCreatingMessageMediator( |
duke@1 | 1035 | Broker xbroker, Connection xconnection, |
duke@1 | 1036 | MessageMediator messageMediator) { return null; } |
duke@1 | 1037 | public InputObject createInputObject( |
duke@1 | 1038 | Broker broker, MessageMediator messageMediator) { return null; } |
duke@1 | 1039 | public OutputObject createOutputObject( |
duke@1 | 1040 | Broker broker, MessageMediator messageMediator) { return null; } |
duke@1 | 1041 | } |
duke@1 | 1042 | |
duke@1 | 1043 | // REVISIT - this is a cut and paste modification of makeROIOperation. |
duke@1 | 1044 | private Operation makeAcceptorInstantiationOperation() { |
duke@1 | 1045 | Operation clsop = OperationFactory.classAction() ; |
duke@1 | 1046 | Operation indexOp = OperationFactory.suffixAction() ; |
duke@1 | 1047 | Operation op1 = OperationFactory.compose( indexOp, clsop ) ; |
duke@1 | 1048 | Operation mop = OperationFactory.maskErrorAction( op1 ) ; |
duke@1 | 1049 | |
duke@1 | 1050 | Operation mkinst = new Operation() { |
duke@1 | 1051 | public Object operate( Object value ) |
duke@1 | 1052 | { |
duke@1 | 1053 | final Class initClass = (Class)value ; |
duke@1 | 1054 | if (initClass == null) |
duke@1 | 1055 | return null ; |
duke@1 | 1056 | |
duke@1 | 1057 | // For security reasons avoid creating an instance |
duke@1 | 1058 | // if this class is one that would fail the class cast |
duke@1 | 1059 | // to ORBInitializer anyway. |
duke@1 | 1060 | if( Acceptor.class.isAssignableFrom( initClass ) ) { |
duke@1 | 1061 | // Now that we have a class object, instantiate one and |
duke@1 | 1062 | // remember it: |
duke@1 | 1063 | Acceptor acceptor = null ; |
duke@1 | 1064 | |
duke@1 | 1065 | try { |
duke@1 | 1066 | acceptor = (Acceptor)AccessController.doPrivileged( |
duke@1 | 1067 | new PrivilegedExceptionAction() { |
duke@1 | 1068 | public Object run() |
duke@1 | 1069 | throws InstantiationException, IllegalAccessException |
duke@1 | 1070 | { |
duke@1 | 1071 | return initClass.newInstance() ; |
duke@1 | 1072 | } |
duke@1 | 1073 | } |
duke@1 | 1074 | ) ; |
duke@1 | 1075 | } catch (PrivilegedActionException exc) { |
duke@1 | 1076 | // Unwrap the exception, as we don't care exc here |
duke@1 | 1077 | throw wrapper.acceptorInstantiationFailure( exc.getException(), |
duke@1 | 1078 | initClass.getName() ) ; |
duke@1 | 1079 | } catch (Exception exc) { |
duke@1 | 1080 | throw wrapper.acceptorInstantiationFailure( exc, initClass.getName() ) ; |
duke@1 | 1081 | } |
duke@1 | 1082 | |
duke@1 | 1083 | return acceptor ; |
duke@1 | 1084 | } else { |
duke@1 | 1085 | throw wrapper.acceptorInstantiationTypeFailure( initClass.getName() ) ; |
duke@1 | 1086 | } |
duke@1 | 1087 | } |
duke@1 | 1088 | } ; |
duke@1 | 1089 | |
duke@1 | 1090 | Operation result = OperationFactory.compose( mop, mkinst ) ; |
duke@1 | 1091 | |
duke@1 | 1092 | return result ; |
duke@1 | 1093 | } |
duke@1 | 1094 | |
duke@1 | 1095 | private Operation makeInitRefOperation() { |
duke@1 | 1096 | return new Operation() { |
duke@1 | 1097 | public Object operate( Object value ) |
duke@1 | 1098 | { |
duke@1 | 1099 | // Object is String[] of length 2. |
duke@1 | 1100 | String[] values = (String[])value ; |
duke@1 | 1101 | if (values.length != 2) |
duke@1 | 1102 | throw wrapper.orbInitialreferenceSyntax() ; |
duke@1 | 1103 | |
duke@1 | 1104 | return values[0] + "=" + values[1] ; |
duke@1 | 1105 | } |
duke@1 | 1106 | } ; |
duke@1 | 1107 | } |
duke@1 | 1108 | } |
duke@1 | 1109 | |
duke@1 | 1110 | // End of file. |