KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > orb > ParserTable


1 /*
2  * @(#)ParserTable.java 1.50 05/01/04
3  *
4  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.impl.orb ;
9
10 import java.net.URL JavaDoc ;
11 import java.net.InetSocketAddress JavaDoc;
12 import java.net.Socket JavaDoc ;
13 import java.net.ServerSocket JavaDoc ;
14
15 import java.io.IOException JavaDoc ;
16
17 import java.util.HashMap JavaDoc ;
18 import java.util.List JavaDoc;
19 import java.util.Map JavaDoc ;
20
21 import java.security.AccessController JavaDoc ;
22 import java.security.PrivilegedExceptionAction JavaDoc ;
23 import java.security.PrivilegedActionException JavaDoc ;
24
25 import org.omg.PortableInterceptor.ORBInitializer JavaDoc ;
26 import org.omg.PortableInterceptor.ORBInitInfo JavaDoc ;
27
28 import com.sun.corba.se.pept.broker.Broker;
29 import com.sun.corba.se.pept.encoding.InputObject;
30 import com.sun.corba.se.pept.encoding.OutputObject;
31 import com.sun.corba.se.pept.protocol.MessageMediator;
32 import com.sun.corba.se.pept.transport.Acceptor;
33 import com.sun.corba.se.pept.transport.Connection;
34 import com.sun.corba.se.pept.transport.ContactInfo;
35 import com.sun.corba.se.pept.transport.ContactInfoList;
36 import com.sun.corba.se.pept.transport.EventHandler;
37 import com.sun.corba.se.pept.transport.InboundConnectionCache;
38
39 import com.sun.corba.se.spi.ior.IOR ;
40 import com.sun.corba.se.spi.ior.ObjectKey ;
41 import com.sun.corba.se.spi.ior.iiop.GIOPVersion ;
42 import com.sun.corba.se.spi.logging.CORBALogDomains ;
43 import com.sun.corba.se.spi.orb.ORB;
44 import com.sun.corba.se.spi.orb.Operation ;
45 import com.sun.corba.se.spi.orb.OperationFactory ;
46 import com.sun.corba.se.spi.orb.ParserData ;
47 import com.sun.corba.se.spi.orb.ParserDataFactory ;
48 import com.sun.corba.se.spi.orb.StringPair ;
49 import com.sun.corba.se.spi.transport.CorbaContactInfoList;
50 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory;
51 import com.sun.corba.se.spi.transport.CorbaTransportManager;
52 import com.sun.corba.se.spi.transport.IORToSocketInfo;
53 import com.sun.corba.se.spi.transport.ReadTimeouts;
54 import com.sun.corba.se.spi.transport.SocketInfo;
55 import com.sun.corba.se.spi.transport.IIOPPrimaryToContactInfo;
56 import com.sun.corba.se.spi.transport.TransportDefault;
57
58 import com.sun.corba.se.impl.encoding.CodeSetComponentInfo ;
59 import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry ;
60 import com.sun.corba.se.impl.legacy.connection.USLPort ;
61 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
62 import com.sun.corba.se.impl.oa.poa.BadServerIdHandler ;
63 import com.sun.corba.se.impl.orbutil.ORBClassLoader ;
64 import com.sun.corba.se.impl.orbutil.ORBConstants ;
65 import com.sun.corba.se.impl.protocol.giopmsgheaders.KeyAddr ;
66 import com.sun.corba.se.impl.protocol.giopmsgheaders.ProfileAddr ;
67 import com.sun.corba.se.impl.protocol.giopmsgheaders.ReferenceAddr ;
68 import com.sun.corba.se.impl.transport.DefaultIORToSocketInfoImpl;
69 import com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl;
70
71 /** Initialize the parser data for the standard ORB parser. This is used both
72  * to implement ORBDataParserImpl and to provide the basic testing framework
73  * for ORBDataParserImpl.
74  */

75 public class ParserTable {
76     private static String JavaDoc MY_CLASS_NAME = ParserTable.class.getName() ;
77
78     private static ParserTable myInstance = new ParserTable() ;
79
80     private ORBUtilSystemException wrapper ;
81
82     public static ParserTable get()
83     {
84     return myInstance ;
85     }
86
87     private ParserData[] parserData ;
88
89     public ParserData[] getParserData()
90     {
91     return parserData ;
92     }
93
94     private ParserTable() {
95     wrapper = ORBUtilSystemException.get( CORBALogDomains.ORB_LIFECYCLE ) ;
96
97     String JavaDoc codeSetTestString =
98         OSFCodeSetRegistry.ISO_8859_1_VALUE + "," +
99         OSFCodeSetRegistry.UTF_16_VALUE + "," +
100         OSFCodeSetRegistry.ISO_646_VALUE ;
101
102     String JavaDoc[] debugTestData = { "subcontract", "poa", "transport" } ;
103
104     USLPort[] USLPorts = { new USLPort( "FOO", 2701 ), new USLPort( "BAR", 3333 ) } ;
105
106     ReadTimeouts readTimeouts =
107            TransportDefault.makeReadTimeoutsFactory().create(
108             ORBConstants.TRANSPORT_TCP_INITIAL_TIME_TO_WAIT,
109             ORBConstants.TRANSPORT_TCP_MAX_TIME_TO_WAIT,
110             ORBConstants.TRANSPORT_TCP_GIOP_HEADER_MAX_TIME_TO_WAIT,
111             ORBConstants.TRANSPORT_TCP_TIME_TO_WAIT_BACKOFF_FACTOR);
112
113     ORBInitializer JavaDoc[] TestORBInitializers =
114         { null,
115               new TestORBInitializer1(),
116           new TestORBInitializer2() } ;
117     StringPair[] TestORBInitData = {
118         new StringPair( "foo.bar.blech.NonExistent", "dummy" ),
119         new StringPair( MY_CLASS_NAME + "$TestORBInitializer1", "dummy" ),
120         new StringPair( MY_CLASS_NAME + "$TestORBInitializer2", "dummy" ) } ;
121
122     Acceptor[] TestAcceptors =
123         { new TestAcceptor2(),
124           new TestAcceptor1(),
125           null } ;
126     // REVISIT: The test data gets put into a Properties object where
127
// order is not guaranteed. Thus the above array is in reverse.
128
StringPair[] TestAcceptorData = {
129         new StringPair( "foo.bar.blech.NonExistent", "dummy" ),
130         new StringPair( MY_CLASS_NAME + "$TestAcceptor1", "dummy" ),
131         new StringPair( MY_CLASS_NAME + "$TestAcceptor2", "dummy" ) } ;
132
133     StringPair[] TestORBInitRefData =
134         { new StringPair( "Foo", "ior:930492049394" ),
135           new StringPair( "Bar", "ior:3453465785633576" ) } ;
136
137     URL JavaDoc testServicesURL = null ;
138     String JavaDoc testServicesString = "corbaloc::camelot/NameService" ;
139
140     try {
141         testServicesURL = new URL JavaDoc( testServicesString ) ;
142     } catch (Exception JavaDoc exc) {
143     }
144
145     // propertyName,
146
// operation,
147
// fieldName, defaultValue,
148
// testValue, testData (string or Pair[])
149
ParserData[] pd = {
150         ParserDataFactory.make( ORBConstants.DEBUG_PROPERTY,
151         OperationFactory.listAction( ",", OperationFactory.stringAction()),
152         "debugFlags", new String JavaDoc[0],
153         debugTestData, "subcontract,poa,transport" ),
154         ParserDataFactory.make( ORBConstants.INITIAL_HOST_PROPERTY,
155         OperationFactory.stringAction(),
156         "ORBInitialHost", "",
157         "Foo", "Foo" ),
158         ParserDataFactory.make( ORBConstants.INITIAL_PORT_PROPERTY,
159         OperationFactory.integerAction(),
160         "ORBInitialPort", new Integer JavaDoc( ORBConstants.DEFAULT_INITIAL_PORT ),
161         new Integer JavaDoc( 27314 ), "27314" ),
162         // Where did this come from?
163
//ParserDataFactory.make( ORBConstants.INITIAL_PORT_PROPERTY,
164
//OperationFactory.booleanAction(),
165
//"ORBInitialPortInitialized", Boolean.FALSE,
166
//Boolean.TRUE, "27314" ),
167
ParserDataFactory.make( ORBConstants.SERVER_HOST_PROPERTY,
168         OperationFactory.stringAction(),
169         "ORBServerHost", "",
170         "camelot", "camelot" ),
171         ParserDataFactory.make( ORBConstants.SERVER_PORT_PROPERTY,
172         OperationFactory.integerAction(),
173         "ORBServerPort", new Integer JavaDoc( 0 ),
174         new Integer JavaDoc( 38143 ), "38143" ),
175         // NOTE: We are putting SERVER_HOST_NAME configuration info into
176
// DataCollectorBase to avoid a security hole. However, that forces
177
// us to also set LISTEN_ON_ALL_INTERFACES at the same time.
178
// This all needs to be cleaned up for two reasons: to get configuration
179
// out of DataCollectorBase and to correctly support multihoming.
180
ParserDataFactory.make( ORBConstants.LISTEN_ON_ALL_INTERFACES,
181         OperationFactory.stringAction(),
182             "listenOnAllInterfaces", ORBConstants.LISTEN_ON_ALL_INTERFACES,
183         "foo", "foo" ),
184         ParserDataFactory.make( ORBConstants.ORB_ID_PROPERTY,
185         OperationFactory.stringAction(),
186         "orbId", "",
187                 "foo", "foo" ),
188         ParserDataFactory.make( ORBConstants.OLD_ORB_ID_PROPERTY,
189         OperationFactory.stringAction(),
190         "orbId", "",
191                 "foo", "foo" ),
192         ParserDataFactory.make( ORBConstants.ORB_SERVER_ID_PROPERTY,
193         OperationFactory.integerAction(),
194         "persistentServerId", new Integer JavaDoc(-1),
195         new Integer JavaDoc( 1234), "1234" ),
196         ParserDataFactory.make(
197                 ORBConstants.ORB_SERVER_ID_PROPERTY,
198         OperationFactory.setFlagAction(),
199         "persistentServerIdInitialized", Boolean.FALSE,
200         Boolean.TRUE, "1234" ),
201         ParserDataFactory.make(
202                 ORBConstants.ORB_SERVER_ID_PROPERTY,
203         OperationFactory.setFlagAction(),
204         "orbServerIdPropertySpecified", Boolean.FALSE,
205         Boolean.TRUE, "1234" ),
206         // REVISIT after switch
207
// ParserDataFactory.make( ORBConstants.INITIAL_SERVICES_PROPERTY,
208
// OperationFactory.URLAction(),
209
// "servicesURL", null,
210
// testServicesURL, testServicesString ),
211
// ParserDataFactory.make( ORBConstants.DEFAULT_INIT_REF_PROPERTY,
212
// OperationFactory.stringAction(),
213
// "defaultInitRef", null,
214
// "Fooref", "Fooref" ),
215
ParserDataFactory.make( ORBConstants.HIGH_WATER_MARK_PROPERTY,
216         OperationFactory.integerAction(),
217             "highWaterMark", new Integer JavaDoc( 240 ),
218         new Integer JavaDoc( 3745 ), "3745" ),
219         ParserDataFactory.make( ORBConstants.LOW_WATER_MARK_PROPERTY,
220         OperationFactory.integerAction(),
221             "lowWaterMark", new Integer JavaDoc( 100 ),
222         new Integer JavaDoc( 12 ), "12" ),
223         ParserDataFactory.make( ORBConstants.NUMBER_TO_RECLAIM_PROPERTY,
224         OperationFactory.integerAction(),
225         "numberToReclaim", new Integer JavaDoc( 5 ),
226         new Integer JavaDoc( 231 ), "231" ),
227         ParserDataFactory.make( ORBConstants.GIOP_VERSION,
228         makeGVOperation(),
229         "giopVersion", GIOPVersion.DEFAULT_VERSION,
230         new GIOPVersion( 2, 3 ), "2.3" ),
231         ParserDataFactory.make( ORBConstants.GIOP_FRAGMENT_SIZE,
232         makeFSOperation(), "giopFragmentSize",
233         new Integer JavaDoc( ORBConstants.GIOP_DEFAULT_FRAGMENT_SIZE ),
234         new Integer JavaDoc( 65536 ), "65536" ),
235         ParserDataFactory.make( ORBConstants.GIOP_BUFFER_SIZE,
236         OperationFactory.integerAction(),
237         "giopBufferSize", new Integer JavaDoc( ORBConstants.GIOP_DEFAULT_BUFFER_SIZE ),
238         new Integer JavaDoc( 234000 ), "234000" ),
239         ParserDataFactory.make( ORBConstants.GIOP_11_BUFFMGR,
240         makeBMGROperation(),
241         "giop11BuffMgr", new Integer JavaDoc( ORBConstants.DEFAULT_GIOP_11_BUFFMGR ),
242         new Integer JavaDoc( 1 ), "CLCT" ),
243         ParserDataFactory.make( ORBConstants.GIOP_12_BUFFMGR,
244         makeBMGROperation(),
245         "giop12BuffMgr", new Integer JavaDoc( ORBConstants.DEFAULT_GIOP_12_BUFFMGR ),
246         new Integer JavaDoc( 0 ), "GROW" ),
247
248         // Note that the same property is used to set two different
249
// fields here. This requires that both entries use the same test
250
// data, or the test will fail.
251
ParserDataFactory.make( ORBConstants.GIOP_TARGET_ADDRESSING,
252         OperationFactory.compose( OperationFactory.integerRangeAction( 0, 3 ),
253             OperationFactory.convertIntegerToShort() ),
254         "giopTargetAddressPreference",
255         new Short JavaDoc( ORBConstants.ADDR_DISP_HANDLE_ALL ),
256         new Short JavaDoc( (short)2 ), "2" ),
257         ParserDataFactory.make( ORBConstants.GIOP_TARGET_ADDRESSING,
258         makeADOperation(),
259         "giopAddressDisposition", new Short JavaDoc( KeyAddr.value ),
260         new Short JavaDoc( (short)2 ), "2" ),
261         ParserDataFactory.make( ORBConstants.ALWAYS_SEND_CODESET_CTX_PROPERTY,
262         OperationFactory.booleanAction(),
263         "alwaysSendCodeSetCtx", Boolean.TRUE,
264         Boolean.FALSE, "false"),
265         ParserDataFactory.make( ORBConstants.USE_BOMS,
266         OperationFactory.booleanAction(),
267         "useByteOrderMarkers",
268             Boolean.valueOf( ORBConstants.DEFAULT_USE_BYTE_ORDER_MARKERS ),
269         Boolean.FALSE, "false" ),
270         ParserDataFactory.make( ORBConstants.USE_BOMS_IN_ENCAPS,
271         OperationFactory.booleanAction(),
272         "useByteOrderMarkersInEncaps",
273             Boolean.valueOf( ORBConstants.DEFAULT_USE_BYTE_ORDER_MARKERS_IN_ENCAPS ),
274         Boolean.FALSE, "false" ),
275         ParserDataFactory.make( ORBConstants.CHAR_CODESETS,
276         makeCSOperation(),
277         "charData", CodeSetComponentInfo.JAVASOFT_DEFAULT_CODESETS.getCharComponent(),
278         CodeSetComponentInfo.createFromString( codeSetTestString ), codeSetTestString ),
279         ParserDataFactory.make( ORBConstants.WCHAR_CODESETS,
280         makeCSOperation(),
281         "wcharData", CodeSetComponentInfo.JAVASOFT_DEFAULT_CODESETS.getWCharComponent(),
282         CodeSetComponentInfo.createFromString( codeSetTestString ), codeSetTestString ),
283         ParserDataFactory.make( ORBConstants.ALLOW_LOCAL_OPTIMIZATION,
284         OperationFactory.booleanAction(),
285         "allowLocalOptimization", Boolean.FALSE,
286         Boolean.TRUE, "true" ),
287         ParserDataFactory.make( ORBConstants.LEGACY_SOCKET_FACTORY_CLASS_PROPERTY,
288         makeLegacySocketFactoryOperation(),
289             // No default - must be set by user if they are using
290
// legacy socket factory.
291
"legacySocketFactory", null,
292         new TestLegacyORBSocketFactory(),
293         MY_CLASS_NAME + "$TestLegacyORBSocketFactory" ),
294         ParserDataFactory.make( ORBConstants.SOCKET_FACTORY_CLASS_PROPERTY,
295         makeSocketFactoryOperation(),
296         "socketFactory", new DefaultSocketFactoryImpl(),
297         new TestORBSocketFactory(),
298         MY_CLASS_NAME + "$TestORBSocketFactory" ),
299         ParserDataFactory.make( ORBConstants.LISTEN_SOCKET_PROPERTY,
300         makeUSLOperation() ,
301         "userSpecifiedListenPorts", new USLPort[0],
302         USLPorts, "FOO:2701,BAR:3333" ),
303         ParserDataFactory.make( ORBConstants.IOR_TO_SOCKET_INFO_CLASS_PROPERTY,
304             makeIORToSocketInfoOperation(),
305         "iorToSocketInfo", new DefaultIORToSocketInfoImpl(),
306         new TestIORToSocketInfo(),
307         MY_CLASS_NAME + "$TestIORToSocketInfo" ),
308         ParserDataFactory.make( ORBConstants.IIOP_PRIMARY_TO_CONTACT_INFO_CLASS_PROPERTY,
309             makeIIOPPrimaryToContactInfoOperation(),
310             "iiopPrimaryToContactInfo", null,
311         new TestIIOPPrimaryToContactInfo(),
312         MY_CLASS_NAME + "$TestIIOPPrimaryToContactInfo" ),
313         ParserDataFactory.make( ORBConstants.CONTACT_INFO_LIST_FACTORY_CLASS_PROPERTY,
314         makeContactInfoListFactoryOperation(),
315             "corbaContactInfoListFactory", null,
316         new TestContactInfoListFactory(),
317         MY_CLASS_NAME + "$TestContactInfoListFactory" ),
318         ParserDataFactory.make( ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY,
319         OperationFactory.integerAction(),
320         "persistentServerPort", new Integer JavaDoc( 0 ),
321         new Integer JavaDoc( 2743 ), "2743" ),
322         ParserDataFactory.make( ORBConstants.PERSISTENT_SERVER_PORT_PROPERTY,
323         OperationFactory.setFlagAction(),
324         "persistentPortInitialized", Boolean.FALSE,
325         Boolean.TRUE, "2743" ),
326         ParserDataFactory.make( ORBConstants.SERVER_ID_PROPERTY,
327         OperationFactory.integerAction(),
328         "persistentServerId", new Integer JavaDoc( 0 ),
329         new Integer JavaDoc( 294 ), "294" ),
330         ParserDataFactory.make( ORBConstants.SERVER_ID_PROPERTY,
331         OperationFactory.setFlagAction(),
332         "persistentServerIdInitialized", Boolean.FALSE,
333         Boolean.TRUE, "294" ),
334         ParserDataFactory.make( ORBConstants.ACTIVATED_PROPERTY,
335         OperationFactory.booleanAction(),
336         "serverIsORBActivated", Boolean.FALSE,
337         Boolean.TRUE, "true" ),
338         ParserDataFactory.make( ORBConstants.BAD_SERVER_ID_HANDLER_CLASS_PROPERTY,
339         OperationFactory.classAction(),
340         "badServerIdHandlerClass", null,
341         TestBadServerIdHandler.class, MY_CLASS_NAME + "$TestBadServerIdHandler" ),
342         ParserDataFactory.make( ORBConstants.PI_ORB_INITIALIZER_CLASS_PREFIX,
343         makeROIOperation(),
344         "orbInitializers", new ORBInitializer JavaDoc[0],
345         TestORBInitializers, TestORBInitData, ORBInitializer JavaDoc.class ),
346         ParserDataFactory.make( ORBConstants.ACCEPTOR_CLASS_PREFIX_PROPERTY,
347         makeAcceptorInstantiationOperation(),
348         "acceptors", new Acceptor[0],
349         TestAcceptors, TestAcceptorData, Acceptor.class ),
350
351         //
352
// Socket/Channel control
353
//
354

355         // Acceptor:
356
// useNIOSelector == true
357
// useSelectThreadToWait = true
358
// useWorkerThreadForEvent = false
359
// else
360
// useSelectThreadToWait = false
361
// useWorkerThreadForEvent = true
362

363         // Connection:
364
// useNIOSelector == true
365
// useSelectThreadToWait = true
366
// useWorkerThreadForEvent = true
367
// else
368
// useSelectThreadToWait = false
369
// useWorkerThreadForEvent = true
370

371         ParserDataFactory.make( ORBConstants.ACCEPTOR_SOCKET_TYPE_PROPERTY,
372         OperationFactory.stringAction(),
373             "acceptorSocketType", ORBConstants.SOCKETCHANNEL,
374         "foo", "foo" ),
375
376         ParserDataFactory.make( ORBConstants.USE_NIO_SELECT_TO_WAIT_PROPERTY,
377         OperationFactory.booleanAction(),
378             "acceptorSocketUseSelectThreadToWait", Boolean.TRUE,
379         Boolean.TRUE, "true" ),
380         ParserDataFactory.make( ORBConstants.ACCEPTOR_SOCKET_USE_WORKER_THREAD_FOR_EVENT_PROPERTY,
381         OperationFactory.booleanAction(),
382             "acceptorSocketUseWorkerThreadForEvent", Boolean.TRUE,
383         Boolean.TRUE, "true" ),
384         ParserDataFactory.make( ORBConstants.CONNECTION_SOCKET_TYPE_PROPERTY,
385         OperationFactory.stringAction(),
386             "connectionSocketType", ORBConstants.SOCKETCHANNEL,
387         "foo", "foo" ),
388         ParserDataFactory.make( ORBConstants.USE_NIO_SELECT_TO_WAIT_PROPERTY,
389         OperationFactory.booleanAction(),
390             "connectionSocketUseSelectThreadToWait", Boolean.TRUE,
391         Boolean.TRUE, "true" ),
392         ParserDataFactory.make( ORBConstants.CONNECTION_SOCKET_USE_WORKER_THREAD_FOR_EVENT_PROPERTY,
393         OperationFactory.booleanAction(),
394         "connectionSocketUseWorkerThreadForEvent", Boolean.TRUE,
395         Boolean.TRUE, "true" ),
396         ParserDataFactory.make( ORBConstants.DISABLE_DIRECT_BYTE_BUFFER_USE_PROPERTY,
397         OperationFactory.booleanAction(),
398         "disableDirectByteBufferUse", Boolean.FALSE,
399         Boolean.TRUE, "true" ),
400         ParserDataFactory.make(ORBConstants.TRANSPORT_TCP_READ_TIMEOUTS_PROPERTY,
401         makeTTCPRTOperation(),
402         "readTimeouts", TransportDefault.makeReadTimeoutsFactory().create(
403             ORBConstants.TRANSPORT_TCP_INITIAL_TIME_TO_WAIT,
404             ORBConstants.TRANSPORT_TCP_MAX_TIME_TO_WAIT,
405             ORBConstants.TRANSPORT_TCP_GIOP_HEADER_MAX_TIME_TO_WAIT,
406             ORBConstants.TRANSPORT_TCP_TIME_TO_WAIT_BACKOFF_FACTOR),
407         readTimeouts, "100:3000:300:20" ),
408         ParserDataFactory.make(
409         ORBConstants.ENABLE_JAVA_SERIALIZATION_PROPERTY,
410         OperationFactory.booleanAction(),
411             "enableJavaSerialization", Boolean.FALSE,
412         Boolean.FALSE, "false"),
413         ParserDataFactory.make(
414         ORBConstants.USE_REP_ID,
415         OperationFactory.booleanAction(),
416             "useRepId", Boolean.TRUE,
417         Boolean.TRUE, "true"),
418         ParserDataFactory.make( ORBConstants.ORB_INIT_REF_PROPERTY,
419         OperationFactory.identityAction(),
420         "orbInitialReferences", new StringPair[0],
421         TestORBInitRefData, TestORBInitRefData, StringPair.class )
422     } ;
423
424     parserData = pd ;
425     }
426
427     public final class TestBadServerIdHandler implements BadServerIdHandler
428     {
429     public boolean equals( Object JavaDoc other )
430     {
431         return other instanceof TestBadServerIdHandler ;
432     }
433
434     public void handle( ObjectKey objectKey )
435     {
436     }
437     }
438
439     private Operation makeTTCPRTOperation()
440     {
441     Operation[] fourIop = { OperationFactory.integerAction(),
442                             OperationFactory.integerAction(),
443                             OperationFactory.integerAction(),
444                             OperationFactory.integerAction() } ;
445
446     Operation op2 = OperationFactory.sequenceAction( ":", fourIop ) ;
447
448     Operation rtOp = new Operation() {
449         public Object JavaDoc operate(Object JavaDoc value)
450         {
451         Object JavaDoc[] values = (Object JavaDoc[])value ;
452         Integer JavaDoc initialTime = (Integer JavaDoc)(values[0]) ;
453         Integer JavaDoc maxGIOPHdrTime = (Integer JavaDoc)(values[1]) ;
454         Integer JavaDoc maxGIOPBodyTime = (Integer JavaDoc)(values[2]) ;
455         Integer JavaDoc backoffPercent = (Integer JavaDoc)(values[3]) ;
456             return TransportDefault.makeReadTimeoutsFactory().create(
457                                        initialTime.intValue(),
458                                        maxGIOPHdrTime.intValue(),
459                                        maxGIOPBodyTime.intValue(),
460                                        backoffPercent.intValue());
461         }
462     } ;
463
464     Operation ttcprtOp = OperationFactory.compose(op2, rtOp);
465     return ttcprtOp;
466     }
467
468     private Operation makeUSLOperation()
469     {
470     Operation[] siop = { OperationFactory.stringAction(),
471         OperationFactory.integerAction() } ;
472     Operation op2 = OperationFactory.sequenceAction( ":", siop ) ;
473
474     Operation uslop = new Operation() {
475         public Object JavaDoc operate( Object JavaDoc value )
476         {
477         Object JavaDoc[] values = (Object JavaDoc[])value ;
478         String JavaDoc type = (String JavaDoc)(values[0]) ;
479         Integer JavaDoc port = (Integer JavaDoc)(values[1]) ;
480         return new USLPort( type, port.intValue() ) ;
481         }
482     } ;
483     
484     Operation op3 = OperationFactory.compose( op2, uslop ) ;
485     Operation listenop = OperationFactory.listAction( ",", op3 ) ;
486     return listenop ;
487     }
488    
489     public static final class TestLegacyORBSocketFactory
490     implements com.sun.corba.se.spi.legacy.connection.ORBSocketFactory
491     {
492     public boolean equals( Object JavaDoc other )
493     {
494         return other instanceof TestLegacyORBSocketFactory ;
495     }
496
497     public ServerSocket JavaDoc createServerSocket( String JavaDoc type, int port )
498     {
499         return null ;
500     }
501
502     public SocketInfo getEndPointInfo( org.omg.CORBA.ORB JavaDoc orb,
503         IOR ior, SocketInfo socketInfo )
504     {
505         return null ;
506     }
507
508     public Socket JavaDoc createSocket( SocketInfo socketInfo )
509     {
510         return null ;
511     }
512     }
513
514     public static final class TestORBSocketFactory
515     implements com.sun.corba.se.spi.transport.ORBSocketFactory
516     {
517     public boolean equals( Object JavaDoc other )
518     {
519         return other instanceof TestORBSocketFactory ;
520     }
521
522     public void setORB(ORB orb)
523     {
524     }
525
526     public ServerSocket JavaDoc createServerSocket( String JavaDoc type, InetSocketAddress JavaDoc a )
527     {
528         return null ;
529     }
530
531     public Socket JavaDoc createSocket( String JavaDoc type, InetSocketAddress JavaDoc a )
532     {
533         return null ;
534     }
535
536     public void setAcceptedSocketOptions(Acceptor acceptor,
537                          ServerSocket JavaDoc serverSocket,
538                          Socket JavaDoc socket)
539     {
540     }
541     }
542
543     public static final class TestIORToSocketInfo
544     implements IORToSocketInfo
545     {
546     public boolean equals( Object JavaDoc other )
547     {
548         return other instanceof TestIORToSocketInfo;
549     }
550
551     public List JavaDoc getSocketInfo(IOR ior)
552     {
553         return null;
554     }
555     }
556
557     public static final class TestIIOPPrimaryToContactInfo
558     implements IIOPPrimaryToContactInfo
559     {
560     public void reset(ContactInfo primary)
561     {
562     }
563
564     public boolean hasNext(ContactInfo primary,
565                    ContactInfo previous,
566                    List JavaDoc contactInfos)
567     {
568         return true;
569     }
570
571     public ContactInfo next(ContactInfo primary,
572                 ContactInfo previous,
573                 List JavaDoc contactInfos)
574     {
575         return null;
576     }
577     }
578
579     public static final class TestContactInfoListFactory
580     implements CorbaContactInfoListFactory
581     {
582     public boolean equals( Object JavaDoc other )
583     {
584         return other instanceof TestContactInfoListFactory;
585     }
586
587     public void setORB(ORB orb) { }
588
589     public CorbaContactInfoList create( IOR ior ) { return null; }
590     }
591
592     private Operation makeMapOperation( final Map JavaDoc map )
593     {
594     return new Operation() {
595         public Object JavaDoc operate( Object JavaDoc value )
596         {
597         return map.get( value ) ;
598         }
599     } ;
600     }
601
602     private Operation makeBMGROperation()
603     {
604     Map JavaDoc map = new HashMap JavaDoc() ;
605     map.put( "GROW", new Integer JavaDoc(0) ) ;
606     map.put( "CLCT", new Integer JavaDoc(1) ) ;
607     map.put( "STRM", new Integer JavaDoc(2) ) ;
608     return makeMapOperation( map ) ;
609     }
610
611     private Operation makeLegacySocketFactoryOperation()
612     {
613     Operation sfop = new Operation() {
614         public Object JavaDoc operate( Object JavaDoc value )
615         {
616         String JavaDoc param = (String JavaDoc)value ;
617
618         try {
619             Class JavaDoc legacySocketFactoryClass =
620             ORBClassLoader.loadClass(param);
621             // For security reasons avoid creating an instance if
622
// this socket factory class is not one that would fail
623
// the class cast anyway.
624
if (com.sun.corba.se.spi.legacy.connection.ORBSocketFactory.class.isAssignableFrom(legacySocketFactoryClass)) {
625             return legacySocketFactoryClass.newInstance();
626             } else {
627             throw wrapper.illegalSocketFactoryType( legacySocketFactoryClass.toString() ) ;
628             }
629         } catch (Exception JavaDoc ex) {
630             // ClassNotFoundException, IllegalAccessException,
631
// InstantiationException, SecurityException or
632
// ClassCastException
633
throw wrapper.badCustomSocketFactory( ex, param ) ;
634         }
635         }
636     } ;
637
638     return sfop ;
639     }
640     
641     private Operation makeSocketFactoryOperation()
642     {
643     Operation sfop = new Operation() {
644         public Object JavaDoc operate( Object JavaDoc value )
645         {
646         String JavaDoc param = (String JavaDoc)value ;
647
648         try {
649             Class JavaDoc socketFactoryClass = ORBClassLoader.loadClass(param);
650             // For security reasons avoid creating an instance if
651
// this socket factory class is not one that would fail
652
// the class cast anyway.
653
if (com.sun.corba.se.spi.transport.ORBSocketFactory.class.isAssignableFrom(socketFactoryClass)) {
654             return socketFactoryClass.newInstance();
655             } else {
656             throw wrapper.illegalSocketFactoryType( socketFactoryClass.toString() ) ;
657             }
658         } catch (Exception JavaDoc ex) {
659             // ClassNotFoundException, IllegalAccessException,
660
// InstantiationException, SecurityException or
661
// ClassCastException
662
throw wrapper.badCustomSocketFactory( ex, param ) ;
663         }
664         }
665     } ;
666
667     return sfop ;
668     }
669     
670     private Operation makeIORToSocketInfoOperation()
671     {
672     Operation op = new Operation() {
673         public Object JavaDoc operate( Object JavaDoc value )
674         {
675         String JavaDoc param = (String JavaDoc)value ;
676
677         try {
678             Class JavaDoc iorToSocketInfoClass = ORBClassLoader.loadClass(param);
679             // For security reasons avoid creating an instance if
680
// this socket factory class is not one that would fail
681
// the class cast anyway.
682
if (IORToSocketInfo.class.isAssignableFrom(iorToSocketInfoClass)) {
683             return iorToSocketInfoClass.newInstance();
684             } else {
685             throw wrapper.illegalIorToSocketInfoType( iorToSocketInfoClass.toString() ) ;
686             }
687         } catch (Exception JavaDoc ex) {
688             // ClassNotFoundException, IllegalAccessException,
689
// InstantiationException, SecurityException or
690
// ClassCastException
691
throw wrapper.badCustomIorToSocketInfo( ex, param ) ;
692         }
693         }
694     } ;
695
696     return op ;
697     }
698     
699     private Operation makeIIOPPrimaryToContactInfoOperation()
700     {
701     Operation op = new Operation() {
702         public Object JavaDoc operate( Object JavaDoc value )
703         {
704         String JavaDoc param = (String JavaDoc)value ;
705
706         try {
707             Class JavaDoc iiopPrimaryToContactInfoClass = ORBClassLoader.loadClass(param);
708             // For security reasons avoid creating an instance if
709
// this socket factory class is not one that would fail
710
// the class cast anyway.
711
if (IIOPPrimaryToContactInfo.class.isAssignableFrom(iiopPrimaryToContactInfoClass)) {
712             return iiopPrimaryToContactInfoClass.newInstance();
713             } else {
714             throw wrapper.illegalIiopPrimaryToContactInfoType( iiopPrimaryToContactInfoClass.toString() ) ;
715             }
716         } catch (Exception JavaDoc ex) {
717             // ClassNotFoundException, IllegalAccessException,
718
// InstantiationException, SecurityException or
719
// ClassCastException
720
throw wrapper.badCustomIiopPrimaryToContactInfo( ex, param ) ;
721         }
722         }
723     } ;
724
725     return op ;
726     }
727     
728     private Operation makeContactInfoListFactoryOperation()
729     {
730     Operation op = new Operation() {
731         public Object JavaDoc operate( Object JavaDoc value )
732         {
733         String JavaDoc param = (String JavaDoc)value ;
734
735         try {
736             Class JavaDoc contactInfoListFactoryClass =
737             ORBClassLoader.loadClass(param);
738             // For security reasons avoid creating an instance if
739
// this socket factory class is not one that would fail
740
// the class cast anyway.
741
if (CorbaContactInfoListFactory.class.isAssignableFrom(
742             contactInfoListFactoryClass)) {
743             return contactInfoListFactoryClass.newInstance();
744             } else {
745             throw wrapper.illegalContactInfoListFactoryType(
746                             contactInfoListFactoryClass.toString() ) ;
747             }
748         } catch (Exception JavaDoc ex) {
749             // ClassNotFoundException, IllegalAccessException,
750
// InstantiationException, SecurityException or
751
// ClassCastException
752
throw wrapper.badContactInfoListFactory( ex, param ) ;
753         }
754         }
755     } ;
756
757     return op ;
758     }
759     
760     private Operation makeCSOperation()
761     {
762     Operation csop = new Operation() {
763         public Object JavaDoc operate( Object JavaDoc value )
764         {
765         String JavaDoc val = (String JavaDoc)value ;
766         return CodeSetComponentInfo.createFromString( val ) ;
767         }
768     } ;
769
770     return csop ;
771     }
772
773     private Operation makeADOperation()
774     {
775     Operation admap = new Operation() {
776         private Integer JavaDoc[] map = {
777         new Integer JavaDoc( KeyAddr.value ),
778         new Integer JavaDoc( ProfileAddr.value ),
779         new Integer JavaDoc( ReferenceAddr.value ),
780         new Integer JavaDoc( KeyAddr.value ) } ;
781
782         public Object JavaDoc operate( Object JavaDoc value )
783         {
784         int val = ((Integer JavaDoc)value).intValue() ;
785         return map[val] ;
786         }
787     } ;
788
789     Operation rangeop = OperationFactory.integerRangeAction( 0, 3 ) ;
790     Operation op1 = OperationFactory.compose( rangeop, admap ) ;
791     Operation result = OperationFactory.compose( op1, OperationFactory.convertIntegerToShort() ) ;
792     return result ;
793     }
794
795     private Operation makeFSOperation() {
796     Operation fschecker = new Operation() {
797         public Object JavaDoc operate( Object JavaDoc value )
798         {
799         int giopFragmentSize = ((Integer JavaDoc)value).intValue() ;
800         if (giopFragmentSize < ORBConstants.GIOP_FRAGMENT_MINIMUM_SIZE){
801             throw wrapper.fragmentSizeMinimum( new Integer JavaDoc( giopFragmentSize ),
802             new Integer JavaDoc( ORBConstants.GIOP_FRAGMENT_MINIMUM_SIZE ) ) ;
803         }
804
805                 if (giopFragmentSize % ORBConstants.GIOP_FRAGMENT_DIVISOR != 0)
806             throw wrapper.fragmentSizeDiv( new Integer JavaDoc( giopFragmentSize ),
807                 new Integer JavaDoc( ORBConstants.GIOP_FRAGMENT_DIVISOR ) ) ;
808
809         return value ;
810         }
811     } ;
812
813     Operation result = OperationFactory.compose( OperationFactory.integerAction(),
814         fschecker ) ;
815     return result ;
816     }
817
818     private Operation makeGVOperation() {
819     Operation gvHelper = OperationFactory.listAction( ".",
820         OperationFactory.integerAction() ) ;
821     Operation gvMain = new Operation() {
822         public Object JavaDoc operate( Object JavaDoc value )
823         {
824         Object JavaDoc[] nums = (Object JavaDoc[])value ;
825         int major = ((Integer JavaDoc)(nums[0])).intValue() ;
826         int minor = ((Integer JavaDoc)(nums[1])).intValue() ;
827
828         return new GIOPVersion( major, minor ) ;
829         }
830     } ;
831     
832     Operation result = OperationFactory.compose( gvHelper, gvMain );
833     return result ;
834     }
835
836     public static final class TestORBInitializer1 extends org.omg.CORBA.LocalObject JavaDoc
837     implements ORBInitializer JavaDoc
838     {
839     public boolean equals( Object JavaDoc other )
840     {
841         return other instanceof TestORBInitializer1 ;
842     }
843
844     public void pre_init( ORBInitInfo JavaDoc info )
845     {
846     }
847
848     public void post_init( ORBInitInfo JavaDoc info )
849     {
850     }
851     }
852
853     public static final class TestORBInitializer2 extends org.omg.CORBA.LocalObject JavaDoc
854     implements ORBInitializer JavaDoc
855     {
856     public boolean equals( Object JavaDoc other )
857     {
858         return other instanceof TestORBInitializer2 ;
859     }
860
861     public void pre_init( ORBInitInfo JavaDoc info )
862     {
863     }
864
865     public void post_init( ORBInitInfo JavaDoc info )
866     {
867     }
868     }
869
870     private Operation makeROIOperation() {
871     Operation clsop = OperationFactory.classAction() ;
872     Operation indexOp = OperationFactory.suffixAction() ;
873     Operation op1 = OperationFactory.compose( indexOp, clsop ) ;
874     Operation mop = OperationFactory.maskErrorAction( op1 ) ;
875
876     Operation mkinst = new Operation() {
877         public Object JavaDoc operate( Object JavaDoc value )
878         {
879         final Class JavaDoc initClass = (Class JavaDoc)value ;
880         if (initClass == null)
881             return null ;
882
883         // For security reasons avoid creating an instance
884
// if this class is one that would fail the class cast
885
// to ORBInitializer anyway.
886
if( org.omg.PortableInterceptor.ORBInitializer JavaDoc.class.isAssignableFrom(
887             initClass ) ) {
888             // Now that we have a class object, instantiate one and
889
// remember it:
890
ORBInitializer JavaDoc initializer = null ;
891
892             try {
893             initializer = (ORBInitializer JavaDoc)AccessController.doPrivileged(
894                 new PrivilegedExceptionAction JavaDoc() {
895                 public Object JavaDoc run()
896                     throws InstantiationException JavaDoc, IllegalAccessException JavaDoc
897                 {
898                     return initClass.newInstance() ;
899                 }
900                 }
901             ) ;
902             } catch (PrivilegedActionException JavaDoc exc) {
903             // Unwrap the exception, as we don't care exc here
904
throw wrapper.orbInitializerFailure( exc.getException(),
905                 initClass.getName() ) ;
906             } catch (Exception JavaDoc exc) {
907             throw wrapper.orbInitializerFailure( exc, initClass.getName() ) ;
908             }
909
910             return initializer ;
911         } else {
912             throw wrapper.orbInitializerType( initClass.getName() ) ;
913         }
914         }
915     } ;
916
917     Operation result = OperationFactory.compose( mop, mkinst ) ;
918
919     return result ;
920     }
921
922     public static final class TestAcceptor1
923     implements Acceptor
924     {
925     public boolean equals( Object JavaDoc other )
926     {
927         return other instanceof TestAcceptor1 ;
928     }
929     public boolean initialize() { return true; }
930     public boolean initialized() { return true; }
931     public String JavaDoc getConnectionCacheType() { return "FOO"; }
932     public void setConnectionCache(InboundConnectionCache connectionCache){}
933     public InboundConnectionCache getConnectionCache() { return null; }
934     public boolean shouldRegisterAcceptEvent() { return true; }
935     public void setUseSelectThreadForConnections(boolean x) { }
936     public boolean shouldUseSelectThreadForConnections() { return true; }
937     public void setUseWorkerThreadForConnections(boolean x) { }
938     public boolean shouldUseWorkerThreadForConnections() { return true; }
939     public void accept() { }
940     public void close() { }
941     public EventHandler getEventHandler() { return null; }
942     public MessageMediator createMessageMediator(
943             Broker xbroker, Connection xconnection) { return null; }
944     public MessageMediator finishCreatingMessageMediator(
945             Broker xbroker, Connection xconnection,
946         MessageMediator messageMediator) { return null; }
947     public InputObject createInputObject(
948             Broker broker, MessageMediator messageMediator) { return null; }
949     public OutputObject createOutputObject(
950             Broker broker, MessageMediator messageMediator) { return null; }
951     }
952
953     public static final class TestAcceptor2
954     implements Acceptor
955     {
956     public boolean equals( Object JavaDoc other )
957     {
958         return other instanceof TestAcceptor2 ;
959     }
960     public boolean initialize() { return true; }
961     public boolean initialized() { return true; }
962     public String JavaDoc getConnectionCacheType() { return "FOO"; }
963     public void setConnectionCache(InboundConnectionCache connectionCache){}
964     public InboundConnectionCache getConnectionCache() { return null; }
965     public boolean shouldRegisterAcceptEvent() { return true; }
966     public void setUseSelectThreadForConnections(boolean x) { }
967     public boolean shouldUseSelectThreadForConnections() { return true; }
968     public void setUseWorkerThreadForConnections(boolean x) { }
969     public boolean shouldUseWorkerThreadForConnections() { return true; }
970     public void accept() { }
971     public void close() { }
972     public EventHandler getEventHandler() { return null; }
973     public MessageMediator createMessageMediator(
974             Broker xbroker, Connection xconnection) { return null; }
975     public MessageMediator finishCreatingMessageMediator(
976             Broker xbroker, Connection xconnection,
977         MessageMediator messageMediator) { return null; }
978     public InputObject createInputObject(
979             Broker broker, MessageMediator messageMediator) { return null; }
980     public OutputObject createOutputObject(
981             Broker broker, MessageMediator messageMediator) { return null; }
982     }
983
984     // REVISIT - this is a cut and paste modification of makeROIOperation.
985
private Operation makeAcceptorInstantiationOperation() {
986     Operation clsop = OperationFactory.classAction() ;
987     Operation indexOp = OperationFactory.suffixAction() ;
988     Operation op1 = OperationFactory.compose( indexOp, clsop ) ;
989     Operation mop = OperationFactory.maskErrorAction( op1 ) ;
990
991     Operation mkinst = new Operation() {
992         public Object JavaDoc operate( Object JavaDoc value )
993         {
994         final Class JavaDoc initClass = (Class JavaDoc)value ;
995         if (initClass == null)
996             return null ;
997
998         // For security reasons avoid creating an instance
999
// if this class is one that would fail the class cast
1000
// to ORBInitializer anyway.
1001
if( Acceptor.class.isAssignableFrom( initClass ) ) {
1002            // Now that we have a class object, instantiate one and
1003
// remember it:
1004
Acceptor acceptor = null ;
1005
1006            try {
1007            acceptor = (Acceptor)AccessController.doPrivileged(
1008                new PrivilegedExceptionAction JavaDoc() {
1009                public Object JavaDoc run()
1010                    throws InstantiationException JavaDoc, IllegalAccessException JavaDoc
1011                {
1012                    return initClass.newInstance() ;
1013                }
1014                }
1015            ) ;
1016            } catch (PrivilegedActionException JavaDoc exc) {
1017            // Unwrap the exception, as we don't care exc here
1018
throw wrapper.acceptorInstantiationFailure( exc.getException(),
1019                initClass.getName() ) ;
1020            } catch (Exception JavaDoc exc) {
1021            throw wrapper.acceptorInstantiationFailure( exc, initClass.getName() ) ;
1022            }
1023
1024            return acceptor ;
1025        } else {
1026            throw wrapper.acceptorInstantiationTypeFailure( initClass.getName() ) ;
1027        }
1028        }
1029    } ;
1030
1031    Operation result = OperationFactory.compose( mop, mkinst ) ;
1032
1033    return result ;
1034    }
1035
1036    private Operation makeInitRefOperation() {
1037    return new Operation() {
1038        public Object JavaDoc operate( Object JavaDoc value )
1039        {
1040        // Object is String[] of length 2.
1041
String JavaDoc[] values = (String JavaDoc[])value ;
1042        if (values.length != 2)
1043            throw wrapper.orbInitialreferenceSyntax() ;
1044
1045        return values[0] + "=" + values[1] ;
1046        }
1047    } ;
1048    }
1049}
1050
1051// End of file.
1052
Popular Tags