PageRenderTime 54ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/jre-1.6.0/src/com/sun/corba/se/impl/orb/ORBImpl.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 1569 lines | 951 code | 217 blank | 401 comment | 78 complexity | 3198198d6804692bae46259666aa3562 MD5 | raw file
  1. /* %W% %E%
  2. *
  3. * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  4. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  5. */
  6. package com.sun.corba.se.impl.orb ;
  7. import java.applet.Applet;
  8. import java.io.IOException ;
  9. import java.lang.reflect.Constructor;
  10. import java.lang.reflect.Field ;
  11. import java.lang.reflect.Modifier ;
  12. import java.lang.reflect.InvocationTargetException ;
  13. import java.util.Set ;
  14. import java.util.HashSet ;
  15. import java.util.ArrayList ;
  16. import java.util.Iterator ;
  17. import java.util.Properties ;
  18. import java.util.Vector ;
  19. import java.util.Hashtable ;
  20. import java.util.Map ;
  21. import java.util.HashMap ;
  22. import java.util.LinkedList ;
  23. import java.util.Collection ;
  24. import java.util.Collections ;
  25. import java.util.StringTokenizer ;
  26. import java.util.Enumeration ;
  27. import java.util.WeakHashMap ;
  28. import java.net.InetAddress ;
  29. import java.security.PrivilegedAction;
  30. import java.security.AccessController ;
  31. import javax.rmi.CORBA.Util;
  32. import javax.rmi.CORBA.ValueHandler;
  33. import org.omg.CORBA.Context;
  34. import org.omg.CORBA.ContextList;
  35. import org.omg.CORBA.Environment;
  36. import org.omg.CORBA.ExceptionList;
  37. import org.omg.CORBA.ORBPackage.InvalidName;
  38. import org.omg.CORBA.NVList;
  39. import org.omg.CORBA.TCKind;
  40. import org.omg.CORBA.NamedValue;
  41. import org.omg.CORBA.Request;
  42. import org.omg.CORBA.SystemException;
  43. import org.omg.CORBA.CompletionStatus;
  44. import org.omg.CORBA.TypeCode;
  45. import org.omg.CORBA.Any;
  46. import org.omg.CORBA.StructMember;
  47. import org.omg.CORBA.UnionMember;
  48. import org.omg.CORBA.ValueMember;
  49. import org.omg.CORBA.BAD_PARAM;
  50. import org.omg.CORBA.MARSHAL;
  51. import org.omg.CORBA.portable.ValueFactory;
  52. import org.omg.CORBA.ORBPackage.InvalidName;
  53. import com.sun.org.omg.SendingContext.CodeBase;
  54. import com.sun.corba.se.pept.broker.Broker;
  55. import com.sun.corba.se.pept.protocol.ClientInvocationInfo ;
  56. import com.sun.corba.se.pept.transport.ContactInfo;
  57. import com.sun.corba.se.pept.transport.ConnectionCache;
  58. import com.sun.corba.se.pept.transport.TransportManager;
  59. import com.sun.corba.se.spi.ior.IOR;
  60. import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ;
  61. import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder;
  62. import com.sun.corba.se.spi.ior.IORFactories ;
  63. import com.sun.corba.se.spi.ior.ObjectKey ;
  64. import com.sun.corba.se.spi.ior.ObjectKeyFactory ;
  65. import com.sun.corba.se.spi.ior.iiop.IIOPFactories ;
  66. import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
  67. import com.sun.corba.se.spi.oa.OAInvocationInfo;
  68. import com.sun.corba.se.spi.oa.ObjectAdapterFactory;
  69. import com.sun.corba.se.spi.orb.DataCollector;
  70. import com.sun.corba.se.spi.orb.Operation;
  71. import com.sun.corba.se.spi.orb.ORBData;
  72. import com.sun.corba.se.spi.orb.ORBConfigurator;
  73. import com.sun.corba.se.spi.orb.ParserImplBase;
  74. import com.sun.corba.se.spi.orb.PropertyParser;
  75. import com.sun.corba.se.spi.orb.OperationFactory;
  76. import com.sun.corba.se.spi.orb.ORBVersion;
  77. import com.sun.corba.se.spi.orb.ORBVersionFactory;
  78. import com.sun.corba.se.spi.orbutil.closure.ClosureFactory;
  79. import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
  80. import com.sun.corba.se.spi.protocol.ClientDelegateFactory;
  81. import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry;
  82. import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher;
  83. import com.sun.corba.se.spi.protocol.RequestDispatcherDefault;
  84. import com.sun.corba.se.spi.protocol.PIHandler;
  85. import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
  86. import com.sun.corba.se.spi.protocol.ForwardException;
  87. import com.sun.corba.se.spi.resolver.Resolver;
  88. import com.sun.corba.se.spi.resolver.LocalResolver;
  89. import com.sun.corba.se.spi.orb.StringPair;
  90. import com.sun.corba.se.spi.orb.StringPair;
  91. import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory;
  92. import com.sun.corba.se.spi.transport.CorbaTransportManager;
  93. import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
  94. import com.sun.corba.se.spi.copyobject.CopierManager ;
  95. import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults ;
  96. import com.sun.corba.se.spi.presentation.rmi.PresentationManager ;
  97. import com.sun.corba.se.spi.presentation.rmi.StubAdapter ;
  98. import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry;
  99. import com.sun.corba.se.impl.corba.TypeCodeFactory;
  100. import com.sun.corba.se.impl.corba.TypeCodeImpl;
  101. import com.sun.corba.se.impl.corba.NVListImpl;
  102. import com.sun.corba.se.impl.corba.ExceptionListImpl;
  103. import com.sun.corba.se.impl.corba.ContextListImpl;
  104. import com.sun.corba.se.impl.corba.NamedValueImpl;
  105. import com.sun.corba.se.impl.corba.EnvironmentImpl;
  106. import com.sun.corba.se.impl.corba.AsynchInvoke;
  107. import com.sun.corba.se.impl.corba.AnyImpl;
  108. import com.sun.corba.se.impl.corba.RequestImpl;
  109. import com.sun.corba.se.impl.dynamicany.DynAnyFactoryImpl;
  110. import com.sun.corba.se.impl.encoding.EncapsOutputStream;
  111. import com.sun.corba.se.impl.encoding.CachedCodeBase;
  112. import com.sun.corba.se.impl.interceptors.PIHandlerImpl;
  113. import com.sun.corba.se.impl.interceptors.PINoOpHandlerImpl;
  114. import com.sun.corba.se.impl.ior.TaggedComponentFactoryFinderImpl;
  115. import com.sun.corba.se.impl.ior.TaggedProfileFactoryFinderImpl;
  116. import com.sun.corba.se.impl.ior.TaggedProfileTemplateFactoryFinderImpl;
  117. import com.sun.corba.se.impl.oa.toa.TOAFactory;
  118. import com.sun.corba.se.impl.oa.poa.BadServerIdHandler;
  119. import com.sun.corba.se.impl.oa.poa.DelegateImpl;
  120. import com.sun.corba.se.impl.oa.poa.POAFactory;
  121. import com.sun.corba.se.impl.orbutil.ORBClassLoader;
  122. import com.sun.corba.se.impl.orbutil.ORBConstants;
  123. import com.sun.corba.se.impl.orbutil.ORBUtility;
  124. import com.sun.corba.se.impl.orbutil.StackImpl;
  125. import com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl;
  126. import com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolManagerImpl;
  127. import com.sun.corba.se.impl.protocol.RequestDispatcherRegistryImpl;
  128. import com.sun.corba.se.impl.protocol.CorbaInvocationInfo;
  129. import com.sun.corba.se.impl.transport.CorbaTransportManagerImpl;
  130. import com.sun.corba.se.impl.legacy.connection.LegacyServerSocketManagerImpl;
  131. import com.sun.corba.se.impl.util.Utility;
  132. import com.sun.corba.se.impl.logging.ORBUtilSystemException;
  133. import com.sun.corba.se.impl.copyobject.CopierManagerImpl;
  134. import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl;
  135. /**
  136. * The JavaIDL ORB implementation.
  137. */
  138. public class ORBImpl extends com.sun.corba.se.spi.orb.ORB
  139. {
  140. protected TransportManager transportManager;
  141. protected LegacyServerSocketManager legacyServerSocketManager;
  142. private ThreadLocal OAInvocationInfoStack ;
  143. private ThreadLocal clientInvocationInfoStack ;
  144. // pure java orb, caching the servant IOR per ORB
  145. private static IOR codeBaseIOR ;
  146. // Vector holding deferred Requests
  147. private Vector dynamicRequests ;
  148. private SynchVariable svResponseReceived ;
  149. private java.lang.Object runObj = new java.lang.Object();
  150. private java.lang.Object shutdownObj = new java.lang.Object();
  151. private java.lang.Object waitForCompletionObj = new java.lang.Object();
  152. private static final byte STATUS_OPERATING = 1;
  153. private static final byte STATUS_SHUTTING_DOWN = 2;
  154. private static final byte STATUS_SHUTDOWN = 3;
  155. private static final byte STATUS_DESTROYED = 4;
  156. private byte status = STATUS_OPERATING;
  157. // XXX Should we move invocation tracking to the first level server dispatcher?
  158. private java.lang.Object invocationObj = new java.lang.Object();
  159. private int numInvocations = 0;
  160. // thread local variable to store a boolean to detect deadlock in
  161. // ORB.shutdown(true).
  162. private ThreadLocal isProcessingInvocation = new ThreadLocal () {
  163. protected java.lang.Object initialValue() {
  164. return Boolean.FALSE;
  165. }
  166. };
  167. // This map is caching TypeCodes created for a certain class (key)
  168. // and is used in Util.writeAny()
  169. private Map typeCodeForClassMap ;
  170. // Cache to hold ValueFactories (Helper classes) keyed on repository ids
  171. private Hashtable valueFactoryCache = new Hashtable();
  172. // thread local variable to store the current ORB version.
  173. // default ORB version is the version of ORB with correct Rep-id
  174. // changes
  175. private ThreadLocal orbVersionThreadLocal ;
  176. private RequestDispatcherRegistry requestDispatcherRegistry ;
  177. private CopierManager copierManager ;
  178. private int transientServerId ;
  179. private ServiceContextRegistry serviceContextRegistry ;
  180. // Needed here to implement connect/disconnect
  181. private TOAFactory toaFactory ;
  182. // Needed here for set_delegate
  183. private POAFactory poaFactory ;
  184. // The interceptor handler, which provides portable interceptor services for
  185. // subcontracts and object adapters.
  186. private PIHandler pihandler ;
  187. private ORBData configData ;
  188. private BadServerIdHandler badServerIdHandler ;
  189. private ClientDelegateFactory clientDelegateFactory ;
  190. private CorbaContactInfoListFactory corbaContactInfoListFactory ;
  191. // All access to resolver, localResolver, and urlOperation must be protected using
  192. // resolverLock. Do not hold the ORBImpl lock while accessing
  193. // resolver, or deadlocks may occur.
  194. // Note that we now have separate locks for each resolver type. This is due
  195. // to bug 6980681 and 6238477, which was caused by a deadlock while resolving a
  196. // corbaname: URL that contained a reference to the same ORB as the
  197. // ORB making the call to string_to_object. This caused a deadlock between the
  198. // client thread holding the single lock for access to the urlOperation,
  199. // and the server thread handling the client is_a request waiting on the
  200. // same lock to access the localResolver.
  201. // Used for resolver_initial_references and list_initial_services
  202. private Resolver resolver ;
  203. // Used for register_initial_references
  204. private LocalResolver localResolver ;
  205. // Converts strings to object references for resolvers and string_to_object
  206. private Operation urlOperation ;
  207. private final Object urlOperationLock = new java.lang.Object() ;
  208. private CorbaServerRequestDispatcher insNamingDelegate ;
  209. // resolverLock must be used for all access to either resolver or
  210. // localResolver, since it is possible for the resolver to indirectly
  211. // refer to the localResolver. Also used to protect access to
  212. // insNamingDelegate.
  213. private final Object resolverLock = new Object() ;
  214. private TaggedComponentFactoryFinder taggedComponentFactoryFinder ;
  215. private IdentifiableFactoryFinder taggedProfileFactoryFinder ;
  216. private IdentifiableFactoryFinder taggedProfileTemplateFactoryFinder ;
  217. private ObjectKeyFactory objectKeyFactory ;
  218. private boolean orbOwnsThreadPoolManager = false ;
  219. private ThreadPoolManager threadpoolMgr;
  220. private void dprint( String msg )
  221. {
  222. ORBUtility.dprint( this, msg ) ;
  223. }
  224. ////////////////////////////////////////////////////
  225. //
  226. // NOTE:
  227. //
  228. // Methods that are synchronized MUST stay synchronized.
  229. //
  230. // Methods that are NOT synchronized must stay that way to avoid deadlock.
  231. //
  232. //
  233. // REVISIT:
  234. //
  235. // checkShutDownState - lock on different object - and normalize usage.
  236. // starting/FinishDispatch and Shutdown
  237. //
  238. public ORBData getORBData()
  239. {
  240. return configData ;
  241. }
  242. public PIHandler getPIHandler()
  243. {
  244. return pihandler ;
  245. }
  246. /**
  247. * Create a new ORB. Should be followed by the appropriate
  248. * set_parameters() call.
  249. */
  250. public ORBImpl()
  251. {
  252. // All initialization is done through set_parameters().
  253. }
  254. public ORBVersion getORBVersion()
  255. {
  256. synchronized (this) {
  257. checkShutdownState();
  258. }
  259. return (ORBVersion)(orbVersionThreadLocal.get()) ;
  260. }
  261. public void setORBVersion(ORBVersion verObj)
  262. {
  263. synchronized (this) {
  264. checkShutdownState();
  265. }
  266. orbVersionThreadLocal.set(verObj);
  267. }
  268. /****************************************************************************
  269. * The following methods are ORB initialization
  270. ****************************************************************************/
  271. // preInit initializes all non-pluggable ORB data that is independent
  272. // of the property parsing.
  273. private void preInit( String[] params, Properties props )
  274. {
  275. // Before ORBConfiguration we need to set a PINoOpHandlerImpl,
  276. // because PersisentServer Initialization inside configurator will
  277. // invoke orb.resolve_initial_references( ) which will result in a
  278. // check on piHandler to invoke Interceptors. We do not want any
  279. // Interceptors to be invoked before the complete ORB initialization.
  280. // piHandler will be replaced by a real PIHandler implementation at the
  281. // end of this method.
  282. pihandler = new PINoOpHandlerImpl( );
  283. // This is the unique id of this server (JVM). Multiple incarnations
  284. // of this server will get different ids.
  285. // Compute transientServerId = milliseconds since Jan 1, 1970
  286. // Note: transientServerId will wrap in about 2^32 / 86400000 = 49.7 days.
  287. // If two ORBS are started at the same time then there is a possibility
  288. // of having the same transientServerId. This may result in collision
  289. // and may be a problem in ior.isLocal() check to see if the object
  290. // belongs to the current ORB. This problem is taken care of by checking
  291. // to see if the IOR port matches ORB server port in legacyIsLocalServerPort()
  292. // method.
  293. //
  294. // XXX need to move server ID to a string for CORBA 3.0. At that point,
  295. // make this more unique (possibly use java.rmi.server.UID).
  296. transientServerId = (int)System.currentTimeMillis();
  297. orbVersionThreadLocal = new ThreadLocal () {
  298. protected java.lang.Object initialValue() {
  299. // set default to version of the ORB with correct Rep-ids
  300. return ORBVersionFactory.getORBVersion() ;
  301. }
  302. };
  303. requestDispatcherRegistry = new RequestDispatcherRegistryImpl(
  304. this, ORBConstants.DEFAULT_SCID);
  305. copierManager = new CopierManagerImpl( this ) ;
  306. taggedComponentFactoryFinder =
  307. new TaggedComponentFactoryFinderImpl(this) ;
  308. taggedProfileFactoryFinder =
  309. new TaggedProfileFactoryFinderImpl(this) ;
  310. taggedProfileTemplateFactoryFinder =
  311. new TaggedProfileTemplateFactoryFinderImpl(this) ;
  312. dynamicRequests = new Vector();
  313. svResponseReceived = new SynchVariable();
  314. OAInvocationInfoStack =
  315. new ThreadLocal () {
  316. protected java.lang.Object initialValue()
  317. {
  318. return new StackImpl();
  319. }
  320. };
  321. clientInvocationInfoStack =
  322. new ThreadLocal() {
  323. protected java.lang.Object initialValue() {
  324. return new StackImpl();
  325. }
  326. };
  327. serviceContextRegistry = new ServiceContextRegistry( this ) ;
  328. }
  329. protected void setDebugFlags( String[] args )
  330. {
  331. for (int ctr=0; ctr<args.length; ctr++ ) {
  332. String token = args[ctr] ;
  333. // If there is a public boolean data member in this class
  334. // named token + "DebugFlag", set it to true.
  335. try {
  336. Field fld = this.getClass().getField( token + "DebugFlag" ) ;
  337. int mod = fld.getModifiers() ;
  338. if (Modifier.isPublic( mod ) && !Modifier.isStatic( mod ))
  339. if (fld.getType() == boolean.class)
  340. fld.setBoolean( this, true ) ;
  341. } catch (Exception exc) {
  342. // ignore it XXX log this as info
  343. }
  344. }
  345. }
  346. // Class that defines a parser that gets the name of the
  347. // ORBConfigurator class.
  348. private static class ConfigParser extends ParserImplBase {
  349. // The default here is the ORBConfiguratorImpl that we define,
  350. // but this can be replaced.
  351. public Class configurator = ORBConfiguratorImpl.class ;
  352. public PropertyParser makeParser()
  353. {
  354. PropertyParser parser = new PropertyParser() ;
  355. parser.add( ORBConstants.SUN_PREFIX + "ORBConfigurator",
  356. OperationFactory.classAction(), "configurator" ) ;
  357. return parser ;
  358. }
  359. }
  360. private void postInit( String[] params, DataCollector dataCollector )
  361. {
  362. // First, create the standard ORB config data.
  363. // This must be initialized before the ORBConfigurator
  364. // is executed.
  365. configData = new ORBDataParserImpl( this, dataCollector) ;
  366. // Set the debug flags early so they can be used by other
  367. // parts of the initialization.
  368. setDebugFlags( configData.getORBDebugFlags() ) ;
  369. // REVISIT: this should go away after more transport init cleanup
  370. // and going to ORT based ORBD.
  371. getTransportManager();
  372. getLegacyServerSocketManager();
  373. // Create a parser to get the configured ORBConfigurator.
  374. ConfigParser parser = new ConfigParser() ;
  375. parser.init( dataCollector ) ;
  376. ORBConfigurator configurator = null ;
  377. try {
  378. configurator =
  379. (ORBConfigurator)(parser.configurator.newInstance()) ;
  380. } catch (Exception iexc) {
  381. throw wrapper.badOrbConfigurator( iexc, parser.configurator.getName() ) ;
  382. }
  383. // Finally, run the configurator. Note that the default implementation allows
  384. // other configurators with their own parsers to run,
  385. // using the same DataCollector.
  386. try {
  387. configurator.configure( dataCollector, this ) ;
  388. } catch (Exception exc) {
  389. throw wrapper.orbConfiguratorError( exc ) ;
  390. }
  391. // Last of all, create the PIHandler and run the ORB initializers.
  392. pihandler = new PIHandlerImpl( this, params) ;
  393. pihandler.initialize() ;
  394. // Initialize the thread manager pool and byte buffer pool
  395. // so they may be initialized & accessed without synchronization
  396. getThreadPoolManager();
  397. super.getByteBufferPool();
  398. }
  399. private synchronized POAFactory getPOAFactory()
  400. {
  401. if (poaFactory == null) {
  402. poaFactory = (POAFactory)requestDispatcherRegistry.getObjectAdapterFactory(
  403. ORBConstants.TRANSIENT_SCID ) ;
  404. }
  405. return poaFactory ;
  406. }
  407. private synchronized TOAFactory getTOAFactory()
  408. {
  409. if (toaFactory == null) {
  410. toaFactory = (TOAFactory)requestDispatcherRegistry.getObjectAdapterFactory(
  411. ORBConstants.TOA_SCID ) ;
  412. }
  413. return toaFactory ;
  414. }
  415. public void set_parameters( Properties props )
  416. {
  417. synchronized (this) {
  418. checkShutdownState();
  419. }
  420. preInit( null, props ) ;
  421. DataCollector dataCollector =
  422. DataCollectorFactory.create( props, getLocalHostName() ) ;
  423. postInit( null, dataCollector ) ;
  424. }
  425. protected void set_parameters(Applet app, Properties props)
  426. {
  427. preInit( null, props ) ;
  428. DataCollector dataCollector =
  429. DataCollectorFactory.create( app, props, getLocalHostName() ) ;
  430. postInit( null, dataCollector ) ;
  431. }
  432. protected void set_parameters (String[] params, Properties props)
  433. {
  434. preInit( params, props ) ;
  435. DataCollector dataCollector =
  436. DataCollectorFactory.create( params, props, getLocalHostName() ) ;
  437. postInit( params, dataCollector ) ;
  438. }
  439. /****************************************************************************
  440. * The following methods are standard public CORBA ORB APIs
  441. ****************************************************************************/
  442. public synchronized org.omg.CORBA.portable.OutputStream create_output_stream()
  443. {
  444. checkShutdownState();
  445. return new EncapsOutputStream(this);
  446. }
  447. /**
  448. * Get a Current pseudo-object.
  449. * The Current interface is used to manage thread-specific
  450. * information for use by the transactions, security and other
  451. * services. This method is deprecated,
  452. * and replaced by ORB.resolve_initial_references("NameOfCurrentObject");
  453. *
  454. * @return a Current pseudo-object.
  455. * @deprecated
  456. */
  457. public synchronized org.omg.CORBA.Current get_current()
  458. {
  459. checkShutdownState();
  460. /* _REVISIT_
  461. The implementation of get_current is not clear. How would
  462. ORB know whether the caller wants a Current for transactions
  463. or security ?? Or is it assumed that there is just one
  464. implementation for both ? If Current is thread-specific,
  465. then it should not be instantiated; so where does the
  466. ORB get a Current ?
  467. This should probably be deprecated. */
  468. throw wrapper.genericNoImpl() ;
  469. }
  470. /**
  471. * Create an NVList
  472. *
  473. * @param count size of list to create
  474. * @result NVList created
  475. *
  476. * @see NVList
  477. */
  478. public synchronized NVList create_list(int count)
  479. {
  480. checkShutdownState();
  481. return new NVListImpl(this, count);
  482. }
  483. /**
  484. * Create an NVList corresponding to an OperationDef
  485. *
  486. * @param oper operation def to use to create list
  487. * @result NVList created
  488. *
  489. * @see NVList
  490. */
  491. public synchronized NVList create_operation_list(org.omg.CORBA.Object oper)
  492. {
  493. checkShutdownState();
  494. throw wrapper.genericNoImpl() ;
  495. }
  496. /**
  497. * Create a NamedValue
  498. *
  499. * @result NamedValue created
  500. */
  501. public synchronized NamedValue create_named_value(String s, Any any, int flags)
  502. {
  503. checkShutdownState();
  504. return new NamedValueImpl(this, s, any, flags);
  505. }
  506. /**
  507. * Create an ExceptionList
  508. *
  509. * @result ExceptionList created
  510. */
  511. public synchronized org.omg.CORBA.ExceptionList create_exception_list()
  512. {
  513. checkShutdownState();
  514. return new ExceptionListImpl();
  515. }
  516. /**
  517. * Create a ContextList
  518. *
  519. * @result ContextList created
  520. */
  521. public synchronized org.omg.CORBA.ContextList create_context_list()
  522. {
  523. checkShutdownState();
  524. return new ContextListImpl(this);
  525. }
  526. /**
  527. * Get the default Context object
  528. *
  529. * @result the default Context object
  530. */
  531. public synchronized org.omg.CORBA.Context get_default_context()
  532. {
  533. checkShutdownState();
  534. throw wrapper.genericNoImpl() ;
  535. }
  536. /**
  537. * Create an Environment
  538. *
  539. * @result Environment created
  540. */
  541. public synchronized org.omg.CORBA.Environment create_environment()
  542. {
  543. checkShutdownState();
  544. return new EnvironmentImpl();
  545. }
  546. public synchronized void send_multiple_requests_oneway(Request[] req)
  547. {
  548. checkShutdownState();
  549. // Invoke the send_oneway on each new Request
  550. for (int i = 0; i < req.length; i++) {
  551. req[i].send_oneway();
  552. }
  553. }
  554. /**
  555. * Send multiple dynamic requests asynchronously.
  556. *
  557. * @param req an array of request objects.
  558. */
  559. public synchronized void send_multiple_requests_deferred(Request[] req)
  560. {
  561. checkShutdownState();
  562. // add the new Requests to pending dynamic Requests
  563. for (int i = 0; i < req.length; i++) {
  564. dynamicRequests.addElement(req[i]);
  565. }
  566. // Invoke the send_deferred on each new Request
  567. for (int i = 0; i < req.length; i++) {
  568. AsynchInvoke invokeObject = new AsynchInvoke( this,
  569. (com.sun.corba.se.impl.corba.RequestImpl)req[i], true);
  570. new Thread(invokeObject).start();
  571. }
  572. }
  573. /**
  574. * Find out if any of the deferred invocations have a response yet.
  575. */
  576. public synchronized boolean poll_next_response()
  577. {
  578. checkShutdownState();
  579. Request currRequest;
  580. // poll on each pending request
  581. Enumeration ve = dynamicRequests.elements();
  582. while (ve.hasMoreElements() == true) {
  583. currRequest = (Request)ve.nextElement();
  584. if (currRequest.poll_response() == true) {
  585. return true;
  586. }
  587. }
  588. return false;
  589. }
  590. /**
  591. * Get the next request that has gotten a response.
  592. *
  593. * @result the next request ready with a response.
  594. */
  595. public org.omg.CORBA.Request get_next_response()
  596. throws org.omg.CORBA.WrongTransaction
  597. {
  598. synchronized( this ) {
  599. checkShutdownState();
  600. }
  601. while (true) {
  602. // check if there already is a response
  603. synchronized ( dynamicRequests ) {
  604. Enumeration elems = dynamicRequests.elements();
  605. while ( elems.hasMoreElements() ) {
  606. Request currRequest = (Request)elems.nextElement();
  607. if ( currRequest.poll_response() ) {
  608. // get the response for this successfully polled Request
  609. currRequest.get_response();
  610. dynamicRequests.removeElement(currRequest);
  611. return currRequest;
  612. }
  613. }
  614. }
  615. // wait for a response
  616. synchronized(this.svResponseReceived) {
  617. while (!this.svResponseReceived.value()) {
  618. try {
  619. this.svResponseReceived.wait();
  620. } catch(java.lang.InterruptedException ex) {
  621. // NO-OP
  622. }
  623. }
  624. // reinitialize the response flag
  625. this.svResponseReceived.reset();
  626. }
  627. }
  628. }
  629. /**
  630. * Notify response to ORB for get_next_response
  631. */
  632. public void notifyORB()
  633. {
  634. synchronized (this) {
  635. checkShutdownState();
  636. }
  637. synchronized (this.svResponseReceived) {
  638. this.svResponseReceived.set();
  639. this.svResponseReceived.notify();
  640. }
  641. }
  642. /**
  643. * Convert an object ref to a string.
  644. * @param obj The object to stringify.
  645. * @return A stringified object reference.
  646. */
  647. public synchronized String object_to_string(org.omg.CORBA.Object obj)
  648. {
  649. checkShutdownState();
  650. // Handle the null objref case
  651. if (obj == null) {
  652. IOR nullIOR = IORFactories.makeIOR( this ) ;
  653. return nullIOR.stringify();
  654. }
  655. IOR ior = null ;
  656. try {
  657. ior = ORBUtility.connectAndGetIOR( this, obj ) ;
  658. } catch (BAD_PARAM bp) {
  659. // Throw MARSHAL instead if this is a LOCAL_OBJECT_NOT_ALLOWED error.
  660. if (bp.minor == ORBUtilSystemException.LOCAL_OBJECT_NOT_ALLOWED) {
  661. throw omgWrapper.notAnObjectImpl( bp ) ;
  662. } else
  663. // Not a local object problem: just rethrow the exception.
  664. // Do not wrap and log this, since it was already logged at its
  665. // point of origin.
  666. throw bp ;
  667. }
  668. return ior.stringify() ;
  669. }
  670. /**
  671. * Convert a stringified object reference to the object it represents.
  672. * @param str The stringified object reference.
  673. * @return The unstringified object reference.
  674. */
  675. public org.omg.CORBA.Object string_to_object(String str)
  676. {
  677. Operation op ;
  678. synchronized (this) {
  679. checkShutdownState();
  680. op = urlOperation ;
  681. }
  682. if (str == null)
  683. throw wrapper.nullParam() ;
  684. synchronized (urlOperationLock) {
  685. org.omg.CORBA.Object obj = (org.omg.CORBA.Object)op.operate( str ) ;
  686. return obj ;
  687. }
  688. }
  689. // pure java orb support, moved this method from FVDCodeBaseImpl.
  690. // Note that we connect this if we have not already done so.
  691. public synchronized IOR getFVDCodeBaseIOR()
  692. {
  693. checkShutdownState();
  694. if (codeBaseIOR != null) // i.e. We are already connected to it
  695. return codeBaseIOR;
  696. // backward compatability 4365188
  697. CodeBase cb;
  698. ValueHandler vh = ORBUtility.createValueHandler(this);
  699. cb = (CodeBase)vh.getRunTimeCodeBase();
  700. return ORBUtility.connectAndGetIOR( this, cb ) ;
  701. }
  702. /**
  703. * Get the TypeCode for a primitive type.
  704. *
  705. * @param tcKind the integer kind for the primitive type
  706. * @return the requested TypeCode
  707. */
  708. public synchronized TypeCode get_primitive_tc(TCKind tcKind)
  709. {
  710. checkShutdownState();
  711. return get_primitive_tc( tcKind.value() ) ;
  712. }
  713. /**
  714. * Create a TypeCode for a structure.
  715. *
  716. * @param id the logical id for the typecode.
  717. * @param name the name for the typecode.
  718. * @param members an array describing the members of the TypeCode.
  719. * @return the requested TypeCode.
  720. */
  721. public synchronized TypeCode create_struct_tc(String id,
  722. String name,
  723. StructMember[] members)
  724. {
  725. checkShutdownState();
  726. return new TypeCodeImpl(this, TCKind._tk_struct, id, name, members);
  727. }
  728. /**
  729. * Create a TypeCode for a union.
  730. *
  731. * @param id the logical id for the typecode.
  732. * @param name the name for the typecode.
  733. * @param discriminator_type
  734. * the type of the union discriminator.
  735. * @param members an array describing the members of the TypeCode.
  736. * @return the requested TypeCode.
  737. */
  738. public synchronized TypeCode create_union_tc(String id,
  739. String name,
  740. TypeCode discriminator_type,
  741. UnionMember[] members)
  742. {
  743. checkShutdownState();
  744. return new TypeCodeImpl(this,
  745. TCKind._tk_union,
  746. id,
  747. name,
  748. discriminator_type,
  749. members);
  750. }
  751. /**
  752. * Create a TypeCode for an enum.
  753. *
  754. * @param id the logical id for the typecode.
  755. * @param name the name for the typecode.
  756. * @param members an array describing the members of the TypeCode.
  757. * @return the requested TypeCode.
  758. */
  759. public synchronized TypeCode create_enum_tc(String id,
  760. String name,
  761. String[] members)
  762. {
  763. checkShutdownState();
  764. return new TypeCodeImpl(this, TCKind._tk_enum, id, name, members);
  765. }
  766. /**
  767. * Create a TypeCode for an alias.
  768. *
  769. * @param id the logical id for the typecode.
  770. * @param name the name for the typecode.
  771. * @param original_type
  772. * the type this is an alias for.
  773. * @return the requested TypeCode.
  774. */
  775. public synchronized TypeCode create_alias_tc(String id,
  776. String name,
  777. TypeCode original_type)
  778. {
  779. checkShutdownState();
  780. return new TypeCodeImpl(this, TCKind._tk_alias, id, name, original_type);
  781. }
  782. /**
  783. * Create a TypeCode for an exception.
  784. *
  785. * @param id the logical id for the typecode.
  786. * @param name the name for the typecode.
  787. * @param members an array describing the members of the TypeCode.
  788. * @return the requested TypeCode.
  789. */
  790. public synchronized TypeCode create_exception_tc(String id,
  791. String name,
  792. StructMember[] members)
  793. {
  794. checkShutdownState();
  795. return new TypeCodeImpl(this, TCKind._tk_except, id, name, members);
  796. }
  797. /**
  798. * Create a TypeCode for an interface.
  799. *
  800. * @param id the logical id for the typecode.
  801. * @param name the name for the typecode.
  802. * @return the requested TypeCode.
  803. */
  804. public synchronized TypeCode create_interface_tc(String id,
  805. String name)
  806. {
  807. checkShutdownState();
  808. return new TypeCodeImpl(this, TCKind._tk_objref, id, name);
  809. }
  810. /**
  811. * Create a TypeCode for a string.
  812. *
  813. * @param bound the bound for the string.
  814. * @return the requested TypeCode.
  815. */
  816. public synchronized TypeCode create_string_tc(int bound)
  817. {
  818. checkShutdownState();
  819. return new TypeCodeImpl(this, TCKind._tk_string, bound);
  820. }
  821. /**
  822. * Create a TypeCode for a wide string.
  823. *
  824. * @param bound the bound for the string.
  825. * @return the requested TypeCode.
  826. */
  827. public synchronized TypeCode create_wstring_tc(int bound)
  828. {
  829. checkShutdownState();
  830. return new TypeCodeImpl(this, TCKind._tk_wstring, bound);
  831. }
  832. /**
  833. * Create a TypeCode for a sequence.
  834. *
  835. * @param bound the bound for the sequence.
  836. * @param element_type
  837. * the type of elements of the sequence.
  838. * @return the requested TypeCode.
  839. */
  840. public synchronized TypeCode create_sequence_tc(int bound,
  841. TypeCode element_type)
  842. {
  843. checkShutdownState();
  844. return new TypeCodeImpl(this, TCKind._tk_sequence, bound, element_type);
  845. }
  846. /**
  847. * Create a recursive TypeCode in a sequence.
  848. *
  849. * @param bound the bound for the sequence.
  850. * @param offset the index to the enclosing TypeCode that is
  851. * being referenced.
  852. * @return the requested TypeCode.
  853. */
  854. public synchronized TypeCode create_recursive_sequence_tc(int bound,
  855. int offset)
  856. {
  857. checkShutdownState();
  858. return new TypeCodeImpl(this, TCKind._tk_sequence, bound, offset);
  859. }
  860. /**
  861. * Create a TypeCode for an array.
  862. *
  863. * @param length the length of the array.
  864. * @param element_type
  865. * the type of elements of the array.
  866. * @return the requested TypeCode.
  867. */
  868. public synchronized TypeCode create_array_tc(int length,
  869. TypeCode element_type)
  870. {
  871. checkShutdownState();
  872. return new TypeCodeImpl(this, TCKind._tk_array, length, element_type);
  873. }
  874. public synchronized org.omg.CORBA.TypeCode create_native_tc(String id,
  875. String name)
  876. {
  877. checkShutdownState();
  878. return new TypeCodeImpl(this, TCKind._tk_native, id, name);
  879. }
  880. public synchronized org.omg.CORBA.TypeCode create_abstract_interface_tc(
  881. String id,
  882. String name)
  883. {
  884. checkShutdownState();
  885. return new TypeCodeImpl(this, TCKind._tk_abstract_interface, id, name);
  886. }
  887. public synchronized org.omg.CORBA.TypeCode create_fixed_tc(short digits, short scale)
  888. {
  889. checkShutdownState();
  890. return new TypeCodeImpl(this, TCKind._tk_fixed, digits, scale);
  891. }
  892. public synchronized org.omg.CORBA.TypeCode create_value_tc(String id,
  893. String name,
  894. short type_modifier,
  895. TypeCode concrete_base,
  896. ValueMember[] members)
  897. {
  898. checkShutdownState();
  899. return new TypeCodeImpl(this, TCKind._tk_value, id, name,
  900. type_modifier, concrete_base, members);
  901. }
  902. public synchronized org.omg.CORBA.TypeCode create_recursive_tc(String id) {
  903. checkShutdownState();
  904. return new TypeCodeImpl(this, id);
  905. }
  906. public synchronized org.omg.CORBA.TypeCode create_value_box_tc(String id,
  907. String name,
  908. TypeCode boxed_type)
  909. {
  910. checkShutdownState();
  911. return new TypeCodeImpl(this, TCKind._tk_value_box, id, name,
  912. boxed_type);
  913. }
  914. /**
  915. * Create a new Any
  916. *
  917. * @return the new Any created.
  918. */
  919. public synchronized Any create_any()
  920. {
  921. checkShutdownState();
  922. return new AnyImpl(this);
  923. }
  924. // TypeCodeFactory interface methods.
  925. // Keeping track of type codes by repository id.
  926. // Keeping a cache of TypeCodes associated with the class
  927. // they got created from in Util.writeAny().
  928. public synchronized void setTypeCodeForClass(Class c, TypeCodeImpl tci)
  929. {
  930. checkShutdownState();
  931. if (typeCodeForClassMap == null)
  932. typeCodeForClassMap = Collections.synchronizedMap(
  933. new WeakHashMap(64));
  934. // Store only one TypeCode per class.
  935. if ( ! typeCodeForClassMap.containsKey(c))
  936. typeCodeForClassMap.put(c, tci);
  937. }
  938. public synchronized TypeCodeImpl getTypeCodeForClass(Class c)
  939. {
  940. checkShutdownState();
  941. if (typeCodeForClassMap == null)
  942. return null;
  943. return (TypeCodeImpl)typeCodeForClassMap.get(c);
  944. }
  945. /****************************************************************************
  946. * The following methods deal with listing and resolving the initial
  947. * (bootstrap) object references such as "NameService".
  948. ****************************************************************************/
  949. /**
  950. * Get a list of the initially available CORBA services.
  951. * This does not work unless an ORBInitialHost is specified during
  952. * initialization (or unless there is an ORB running on the AppletHost)
  953. * since the localhostname
  954. * is inaccessible to applets. If a service properties URL was specified,
  955. * then it is used, otherwise the bootstrapping protocol is used.
  956. * @return A list of the initial services available.
  957. */
  958. public String[] list_initial_services()
  959. {
  960. Resolver res ;
  961. synchronized( this ) {
  962. checkShutdownState();
  963. res = resolver ;
  964. }
  965. synchronized (resolverLock) {
  966. java.util.Set keys = res.list() ;
  967. return (String[])keys.toArray( new String[keys.size()] ) ;
  968. }
  969. }
  970. /**
  971. * Resolve the stringified reference of one of the initially
  972. * available CORBA services.
  973. * @param identifier The stringified object reference of the
  974. * desired service.
  975. * @return An object reference for the desired service.
  976. * @exception InvalidName The supplied identifier is not associated
  977. * with a known service.
  978. * @exception SystemException One of a fixed set of Corba system exceptions.
  979. */
  980. public org.omg.CORBA.Object resolve_initial_references(
  981. String identifier) throws InvalidName
  982. {
  983. Resolver res ;
  984. synchronized( this ) {
  985. checkShutdownState();
  986. res = resolver ;
  987. }
  988. synchronized (resolverLock) {
  989. org.omg.CORBA.Object result = res.resolve( identifier ) ;
  990. if (result == null)
  991. throw new InvalidName() ;
  992. else
  993. return result ;
  994. }
  995. }
  996. /**
  997. * If this operation is called with an id, <code>"Y"</code>, and an
  998. * object, <code>YY</code>, then a subsequent call to
  999. * <code>ORB.resolve_initial_references( "Y" )</code> will
  1000. * return object <code>YY</code>.
  1001. *
  1002. * @param id The ID by which the initial reference will be known.
  1003. * @param obj The initial reference itself.
  1004. * @throws InvalidName if this operation is called with an empty string id
  1005. * or this operation is called with an id that is already registered,
  1006. * including the default names defined by OMG.
  1007. * @throws BAD_PARAM if the obj parameter is null.
  1008. */
  1009. public void register_initial_reference(
  1010. String id, org.omg.CORBA.Object obj ) throws InvalidName
  1011. {
  1012. CorbaServerRequestDispatcher insnd ;
  1013. synchronized (this) {
  1014. checkShutdownState();
  1015. }
  1016. if ((id == null) || (id.length() == 0))
  1017. throw new InvalidName() ;
  1018. synchronized (this) {
  1019. checkShutdownState();
  1020. }
  1021. synchronized (resolverLock) {
  1022. insnd = insNamingDelegate ;
  1023. java.lang.Object obj2 = localResolver.resolve( id ) ;
  1024. if (obj2 != null)
  1025. throw new InvalidName(id + " already registered") ;
  1026. localResolver.register( id, ClosureFactory.makeConstant( obj )) ;
  1027. }
  1028. synchronized (this) {
  1029. if (StubAdapter.isStub(obj))
  1030. // Make all remote object references available for INS.
  1031. requestDispatcherRegistry.registerServerRequestDispatcher(
  1032. insnd, id ) ;
  1033. }
  1034. }
  1035. /****************************************************************************
  1036. * The following methods (introduced in POA / CORBA2.1) deal with
  1037. * shutdown / single threading.
  1038. ****************************************************************************/
  1039. public void run()
  1040. {
  1041. synchronized (this) {
  1042. checkShutdownState();
  1043. }
  1044. synchronized (runObj) {
  1045. try {
  1046. runObj.wait();
  1047. } catch ( InterruptedException ex ) {}
  1048. }
  1049. }
  1050. public void shutdown(boolean wait_for_completion) {
  1051. boolean wait = false ;
  1052. synchronized (this) {
  1053. checkShutdownState();
  1054. // This is to avoid deadlock: don't allow a thread that is
  1055. // processing a request to call shutdown( true ), because
  1056. // the shutdown would block waiting for the request to complete,
  1057. // while the request would block waiting for shutdown to complete.
  1058. if (wait_for_completion &&
  1059. isProcessingInvocation.get() == Boolean.TRUE) {
  1060. throw omgWrapper.shutdownWaitForCompletionDeadlock() ;
  1061. }
  1062. if (status == STATUS_SHUTTING_DOWN) {
  1063. if (wait_for_completion) {
  1064. wait = true ;
  1065. } else {
  1066. return ;
  1067. }
  1068. }
  1069. status = STATUS_SHUTTING_DOWN ;
  1070. }
  1071. // Avoid more than one thread performing shutdown at a time.
  1072. synchronized (shutdownObj) {
  1073. // At this point, the ORB status is certainly STATUS_SHUTTING_DOWN.
  1074. // If wait is true, another thread already called shutdown( true ),
  1075. // and so we wait for completion
  1076. if (wait) {
  1077. while (true) {
  1078. synchronized (this) {
  1079. if (status == STATUS_SHUTDOWN)
  1080. break ;
  1081. }
  1082. try {
  1083. shutdownObj.wait() ;
  1084. } catch (InterruptedException exc) {
  1085. // NOP: just loop and wait until state is changed
  1086. }
  1087. }
  1088. } else {
  1089. // perform the actual shutdown
  1090. shutdownServants(wait_for_completion);
  1091. if (wait_for_completion) {
  1092. synchronized ( waitForCompletionObj ) {
  1093. while (numInvocations > 0) {
  1094. try {
  1095. waitForCompletionObj.wait();
  1096. } catch (InterruptedException ex) {}
  1097. }
  1098. }
  1099. }
  1100. synchronized ( runObj ) {
  1101. runObj.notifyAll();
  1102. }
  1103. status = STATUS_SHUTDOWN;
  1104. shutdownObj.notifyAll() ;
  1105. }
  1106. }
  1107. }
  1108. // Cause all ObjectAdapaterFactories to clean up all of their internal state, which
  1109. // may include activated objects that have associated state and callbacks that must
  1110. // complete in order to shutdown. This will cause new request to be rejected.
  1111. protected void shutdownServants(boolean wait_for_completion) {
  1112. Set<ObjectAdapterFactory> oaset ;
  1113. synchronized(this) {
  1114. oaset = new HashSet<ObjectAdapterFactory>(
  1115. requestDispatcherRegistry.getObjectAdapterFactories() ) ;
  1116. }
  1117. for (ObjectAdapterFactory oaf : oaset)
  1118. oaf.shutdown( wait_for_completion ) ;
  1119. }
  1120. // Note that the caller must hold the ORBImpl lock.
  1121. public void checkShutdownState()
  1122. {
  1123. if (status == STATUS_DESTROYED) {
  1124. throw wrapper.orbDestroyed() ;
  1125. }
  1126. if (status == STATUS_SHUTDOWN) {
  1127. throw omgWrapper.badOperationAfterShutdown() ;
  1128. }
  1129. }
  1130. public boolean isDuringDispatch()
  1131. {
  1132. synchronized (this) {
  1133. checkShutdownState();
  1134. }
  1135. Boolean value = (Boolean)(isProcessingInvocation.get()) ;
  1136. return value.booleanValue() ;
  1137. }
  1138. public void startingDispatch()
  1139. {
  1140. synchronized (this) {
  1141. checkShutdownState();
  1142. }
  1143. synchronized (invocationObj) {
  1144. isProcessingInvocation.set(Boolean.TRUE);
  1145. numInvocations++;
  1146. }
  1147. }
  1148. public void finishedDispatch()
  1149. {
  1150. synchronized (this) {
  1151. checkShutdownState();
  1152. }
  1153. synchronized (invocationObj) {
  1154. numInvocations--;
  1155. isProcessingInvocation.set(false);
  1156. if (numInvocations == 0) {
  1157. synchronized (waitForCompletionObj) {
  1158. waitForCompletionObj.notifyAll();
  1159. }
  1160. } else if (numInvocations < 0) {
  1161. throw wrapper.numInvocationsAlreadyZero(
  1162. CompletionStatus.COMPLETED_YES ) ;
  1163. }
  1164. }
  1165. }
  1166. /**
  1167. * formal/99-10-07 p 159: "If destroy is called on an ORB that has
  1168. * not been shut down, it will start the shutdown process and block until
  1169. * the ORB has shut down before it destroys the ORB."
  1170. */
  1171. public void destroy()
  1172. {
  1173. boolean shutdownFirst = false ;
  1174. synchronized (this) {
  1175. shutdownFirst = (status == STATUS_OPERATING) ;
  1176. }
  1177. if (shutdownFirst) {
  1178. shutdown(true);
  1179. }
  1180. synchronized (this) {
  1181. if (status < STATUS_DESTROYED) {
  1182. getCorbaTransportManager().close();
  1183. getPIHandler().destroyInterceptors() ;
  1184. status = STATUS_DESTROYED;
  1185. }
  1186. }
  1187. synchronized (threadPoolManagerAccessLock) {
  1188. if (orbOwnsThreadPoolManager) {
  1189. try {
  1190. threadpoolMgr.close() ;
  1191. threadpoolMgr = null ;
  1192. } catch (IOException exc) {
  1193. wrapper.ioExceptionOnClose( exc ) ;
  1194. }
  1195. }
  1196. }
  1197. try {
  1198. monitoringManager.close() ;
  1199. monitoringManager = null ;
  1200. } catch (IOException exc) {
  1201. wrapper.ioExceptionOnClose( exc ) ;
  1202. }
  1203. CachedCodeBase.cleanCache( this ) ;
  1204. try {
  1205. pihandler.close() ;
  1206. } catch (IOException exc) {
  1207. wrapper.ioExceptionOnClose( exc ) ;
  1208. }
  1209. super.destroy() ;
  1210. badServerIdHandlerAccessLock = null ;
  1211. clientDelegateFactoryAccessorLock = null ;
  1212. corbaContactInfoListFactoryAccessLock = null ;
  1213. objectKeyFactoryAccessLock = null ;
  1214. legacyServerSocketManagerAccessLock = null ;
  1215. threadPoolManagerAccessLock = null ;
  1216. transportManager = null ;
  1217. legacyServerSocketManager = null ;
  1218. OAInvocationInfoStack = null ;
  1219. clientInvocationInfoStack = null ;
  1220. codeBaseIOR = null ;
  1221. dynamicRequests = null ;
  1222. svResponseReceived = null ;
  1223. runObj = null ;
  1224. shutdownObj = null ;
  1225. waitForCompletionObj = null ;
  1226. invocationObj = null ;
  1227. isProcessingInvocation = null ;
  1228. typeCodeForClassMap = null ;
  1229. valueFactoryCache = null ;
  1230. orbVersionThreadLocal = null ;
  1231. requestDispatcherRegistry = null ;
  1232. copierManager = null ;
  1233. toaFactory = null ;
  1234. poaFactory = null ;
  1235. pihandler = null ;
  1236. configData = null ;
  1237. badServerIdHandler = null ;
  1238. clientDelegateFactory = null ;
  1239. corbaContactInfoListFactory = null ;
  1240. resolver = null ;
  1241. localResolver = null ;
  1242. insNamingDelegate = null ;
  1243. urlOperation = null ;
  1244. taggedComponentFactoryFinder = null ;
  1245. taggedProfileFactoryFinder = null ;
  1246. taggedProfileTemplateFactoryFinder = null ;
  1247. objectKeyFactory = null ;
  1248. }
  1249. /**
  1250. * Registers a value factory for a particular repository ID.
  1251. *
  1252. * @param repositoryID the repository ID.
  1253. * @param factory the factory.
  1254. * @return the previously registered factory for the given repository ID,
  1255. * or null if no such factory was previously registered.
  1256. * @exception org.omg.CORBA.BAD_PARAM if the registration fails.
  1257. **/
  1258. public synchronized ValueFactory register_value_factory(String repositoryID,
  1259. ValueFactory factory)
  1260. {
  1261. checkShutdownState();
  1262. if ((repositoryID == null) || (factory == null))
  1263. throw omgWrapper.unableRegisterValueFactory() ;
  1264. return (ValueFactory)valueFactoryCache.put(repositoryID, factory);
  1265. }
  1266. /**
  1267. * Unregisters a value factory for a particular repository ID.
  1268. *
  1269. * @param repositoryID the repository ID.
  1270. **/
  1271. public synchronized void unregister_value_factory(String repositoryID)
  1272. {
  1273. checkShutdownState();
  1274. if (valueFactoryCache.remove(repositoryID) == null)
  1275. throw wrapper.nullParam() ;
  1276. }
  1277. /**
  1278. * Finds and returns a value factory for the given repository ID.
  1279. * The value factory returned was previously registered by a call to
  1280. * {@link #register_value_factory} or is the default factory.
  1281. *
  1282. * @param repositoryID the repository ID.
  1283. * @return the value factory.
  1284. * @exception org.omg.CORBA.BAD_PARAM if unable to locate a factory.
  1285. **/
  1286. public synchronized ValueFactory lookup_value_factory(String repositoryID)
  1287. {
  1288. checkShutdownState();
  1289. ValueFactory factory =
  1290. (ValueFactory)valueFactoryCache.get(repositoryID);
  1291. if (factory == null) {
  1292. try {
  1293. factory = Utility.getFactory(null, null, null, repositoryID);
  1294. } catch(org.omg.CORBA.MARSHAL ex) {
  1295. throw wrapper.unableFindValueFactory( ex ) ;
  1296. }
  1297. }
  1298. return factory ;
  1299. }
  1300. public OAInvocationInfo peekInvocationInfo()
  1301. {
  1302. synchronized (this) {
  1303. checkShutdownState();
  1304. }
  1305. StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ;
  1306. return (OAInvocationInfo)(stack.peek()) ;
  1307. }
  1308. public void pushInvocationInfo( OAInvocationInfo info )
  1309. {
  1310. synchronized (this) {
  1311. checkShutdownState();
  1312. }
  1313. StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ;
  1314. stack.push( info ) ;
  1315. }
  1316. public OAInvocationInfo popInvocationInfo()
  1317. {
  1318. synchronized (this) {
  1319. checkShutdownState();
  1320. }
  1321. StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ;
  1322. return (OAInvocationInfo)(stack.pop()) ;
  1323. }
  1324. /**
  1325. * The bad server id handler is used by the Locator to
  1326. * send back the location of a persistant server to the client.
  1327. */
  1328. private Object badServerIdHandlerAccessLock = new Object();
  1329. public void initBadServerIdHandler()
  1330. {
  1331. synchronized (this) {
  1332. checkShutdownState();
  1333. }
  1334. synchronized (badServerIdHandlerAccessLock) {
  1335. Class cls = configData.getBadServerIdHandler() ;
  1336. if (cls != null) {
  1337. try {
  1338. Class[] params = new Class[] { org.omg.CORBA.ORB.class };
  1339. java.lang.Object[] args = new java.lang.Object[]{this};
  1340. Constructor cons = cls.getConstructor(params);
  1341. badServerIdHandler =
  1342. (BadServerIdHandler) cons.newInstance(args);
  1343. } catch (Exception e) {
  1344. throw wrapper.errorInitBadserveridhandler( e ) ;
  1345. }
  1346. }
  1347. }
  1348. }
  1349. public void setBadServerIdHandler( BadServerIdHandler handler )
  1350. {
  1351. synchronized (th