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