Mon, 28 May 2018 10:29:43 +0800
Merge
aoqi@0 | 1 | /* |
aefimov@1618 | 2 | * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.corba.se.impl.orb; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import java.applet.Applet; |
aoqi@0 | 29 | |
aoqi@0 | 30 | import java.io.IOException; |
aoqi@0 | 31 | |
aoqi@0 | 32 | import java.lang.reflect.Constructor; |
aoqi@0 | 33 | import java.lang.reflect.Field; |
aoqi@0 | 34 | import java.lang.reflect.Modifier; |
aoqi@0 | 35 | |
aoqi@0 | 36 | import java.util.Set; |
aoqi@0 | 37 | import java.util.HashSet; |
aoqi@0 | 38 | import java.util.Properties; |
aoqi@0 | 39 | import java.util.Vector; |
aoqi@0 | 40 | import java.util.Hashtable; |
aoqi@0 | 41 | import java.util.Map; |
aoqi@0 | 42 | import java.util.Collections; |
aoqi@0 | 43 | import java.util.Enumeration; |
aoqi@0 | 44 | import java.util.WeakHashMap; |
aoqi@0 | 45 | |
aoqi@0 | 46 | import java.net.InetAddress; |
aoqi@0 | 47 | |
aoqi@0 | 48 | import java.security.PrivilegedAction; |
aefimov@1618 | 49 | import java.security.Security; |
aoqi@0 | 50 | import java.security.AccessController; |
aoqi@0 | 51 | |
aoqi@0 | 52 | import javax.rmi.CORBA.ValueHandler; |
aoqi@0 | 53 | |
aoqi@0 | 54 | import org.omg.CORBA.NVList; |
aoqi@0 | 55 | import org.omg.CORBA.TCKind; |
aoqi@0 | 56 | import org.omg.CORBA.NamedValue; |
aoqi@0 | 57 | import org.omg.CORBA.Request; |
aoqi@0 | 58 | import org.omg.CORBA.SystemException; |
aoqi@0 | 59 | import org.omg.CORBA.CompletionStatus; |
aoqi@0 | 60 | import org.omg.CORBA.TypeCode; |
aoqi@0 | 61 | import org.omg.CORBA.Any; |
aoqi@0 | 62 | import org.omg.CORBA.StructMember; |
aoqi@0 | 63 | import org.omg.CORBA.UnionMember; |
aoqi@0 | 64 | import org.omg.CORBA.ValueMember; |
aoqi@0 | 65 | import org.omg.CORBA.BAD_PARAM; |
aoqi@0 | 66 | |
aoqi@0 | 67 | import org.omg.CORBA.portable.ValueFactory; |
aoqi@0 | 68 | |
aoqi@0 | 69 | import org.omg.CORBA.ORBPackage.InvalidName; |
aoqi@0 | 70 | |
aoqi@0 | 71 | import com.sun.org.omg.SendingContext.CodeBase; |
aoqi@0 | 72 | |
aoqi@0 | 73 | import com.sun.corba.se.pept.protocol.ClientInvocationInfo; |
aoqi@0 | 74 | import com.sun.corba.se.pept.transport.TransportManager; |
aoqi@0 | 75 | |
aoqi@0 | 76 | import com.sun.corba.se.spi.ior.IOR; |
aoqi@0 | 77 | import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder; |
aoqi@0 | 78 | import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder; |
aoqi@0 | 79 | import com.sun.corba.se.spi.ior.IORFactories; |
aoqi@0 | 80 | import com.sun.corba.se.spi.ior.ObjectKey; |
aoqi@0 | 81 | import com.sun.corba.se.spi.ior.ObjectKeyFactory; |
aoqi@0 | 82 | import com.sun.corba.se.spi.oa.OAInvocationInfo; |
aoqi@0 | 83 | import com.sun.corba.se.spi.oa.ObjectAdapterFactory; |
aoqi@0 | 84 | import com.sun.corba.se.spi.orb.DataCollector; |
aoqi@0 | 85 | import com.sun.corba.se.spi.orb.Operation; |
aoqi@0 | 86 | import com.sun.corba.se.spi.orb.ORBData; |
aoqi@0 | 87 | import com.sun.corba.se.spi.orb.ORBConfigurator; |
aoqi@0 | 88 | import com.sun.corba.se.spi.orb.ParserImplBase; |
aoqi@0 | 89 | import com.sun.corba.se.spi.orb.PropertyParser; |
aoqi@0 | 90 | import com.sun.corba.se.spi.orb.OperationFactory; |
aoqi@0 | 91 | import com.sun.corba.se.spi.orb.ORBVersion; |
aoqi@0 | 92 | import com.sun.corba.se.spi.orb.ORBVersionFactory; |
aoqi@0 | 93 | import com.sun.corba.se.spi.orbutil.closure.ClosureFactory; |
aoqi@0 | 94 | import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager; |
aoqi@0 | 95 | import com.sun.corba.se.spi.protocol.ClientDelegateFactory; |
aoqi@0 | 96 | import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry; |
aoqi@0 | 97 | import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher; |
aoqi@0 | 98 | import com.sun.corba.se.spi.protocol.PIHandler; |
aoqi@0 | 99 | import com.sun.corba.se.spi.resolver.Resolver; |
aoqi@0 | 100 | import com.sun.corba.se.spi.resolver.LocalResolver; |
aoqi@0 | 101 | import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory; |
aoqi@0 | 102 | import com.sun.corba.se.spi.transport.CorbaTransportManager; |
aefimov@1618 | 103 | import com.sun.corba.se.spi.ior.IORTypeCheckRegistry; |
aoqi@0 | 104 | import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager; |
aefimov@1618 | 105 | import com.sun.corba.se.spi.logging.CORBALogDomains; |
aoqi@0 | 106 | import com.sun.corba.se.spi.copyobject.CopierManager; |
aoqi@0 | 107 | import com.sun.corba.se.spi.presentation.rmi.StubAdapter; |
aoqi@0 | 108 | import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry; |
aoqi@0 | 109 | |
aoqi@0 | 110 | import com.sun.corba.se.impl.corba.TypeCodeImpl; |
aoqi@0 | 111 | import com.sun.corba.se.impl.corba.NVListImpl; |
aoqi@0 | 112 | import com.sun.corba.se.impl.corba.ExceptionListImpl; |
aoqi@0 | 113 | import com.sun.corba.se.impl.corba.ContextListImpl; |
aoqi@0 | 114 | import com.sun.corba.se.impl.corba.NamedValueImpl; |
aoqi@0 | 115 | import com.sun.corba.se.impl.corba.EnvironmentImpl; |
aoqi@0 | 116 | import com.sun.corba.se.impl.corba.AsynchInvoke; |
aoqi@0 | 117 | import com.sun.corba.se.impl.corba.AnyImpl; |
aoqi@0 | 118 | import com.sun.corba.se.impl.encoding.CachedCodeBase; |
aoqi@0 | 119 | import com.sun.corba.se.impl.interceptors.PIHandlerImpl; |
aoqi@0 | 120 | import com.sun.corba.se.impl.interceptors.PINoOpHandlerImpl; |
aoqi@0 | 121 | import com.sun.corba.se.impl.ior.TaggedComponentFactoryFinderImpl; |
aoqi@0 | 122 | import com.sun.corba.se.impl.ior.TaggedProfileFactoryFinderImpl; |
aoqi@0 | 123 | import com.sun.corba.se.impl.ior.TaggedProfileTemplateFactoryFinderImpl; |
aoqi@0 | 124 | import com.sun.corba.se.impl.oa.toa.TOAFactory; |
aoqi@0 | 125 | import com.sun.corba.se.impl.oa.poa.BadServerIdHandler; |
aoqi@0 | 126 | import com.sun.corba.se.impl.oa.poa.POAFactory; |
aoqi@0 | 127 | import com.sun.corba.se.impl.orbutil.ORBConstants; |
aoqi@0 | 128 | import com.sun.corba.se.impl.orbutil.ORBUtility; |
aoqi@0 | 129 | import com.sun.corba.se.impl.orbutil.StackImpl; |
aoqi@0 | 130 | import com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolManagerImpl; |
aoqi@0 | 131 | import com.sun.corba.se.impl.protocol.RequestDispatcherRegistryImpl; |
aoqi@0 | 132 | import com.sun.corba.se.impl.protocol.CorbaInvocationInfo; |
aoqi@0 | 133 | import com.sun.corba.se.impl.transport.CorbaTransportManagerImpl; |
aoqi@0 | 134 | import com.sun.corba.se.impl.legacy.connection.LegacyServerSocketManagerImpl; |
aoqi@0 | 135 | import com.sun.corba.se.impl.util.Utility; |
aoqi@0 | 136 | import com.sun.corba.se.impl.logging.ORBUtilSystemException; |
aoqi@0 | 137 | import com.sun.corba.se.impl.copyobject.CopierManagerImpl; |
aefimov@1618 | 138 | import com.sun.corba.se.impl.ior.IORTypeCheckRegistryImpl; |
aoqi@0 | 139 | |
aoqi@0 | 140 | /** |
aoqi@0 | 141 | * The JavaIDL ORB implementation. |
aoqi@0 | 142 | */ |
aoqi@0 | 143 | public class ORBImpl extends com.sun.corba.se.spi.orb.ORB |
aoqi@0 | 144 | { |
aoqi@0 | 145 | protected TransportManager transportManager; |
aoqi@0 | 146 | protected LegacyServerSocketManager legacyServerSocketManager; |
aoqi@0 | 147 | |
aoqi@0 | 148 | private ThreadLocal OAInvocationInfoStack ; |
aoqi@0 | 149 | |
aoqi@0 | 150 | private ThreadLocal clientInvocationInfoStack ; |
aoqi@0 | 151 | |
aoqi@0 | 152 | // pure java orb, caching the servant IOR per ORB |
aoqi@0 | 153 | private static IOR codeBaseIOR ; |
aoqi@0 | 154 | |
aoqi@0 | 155 | // Vector holding deferred Requests |
aoqi@0 | 156 | private Vector dynamicRequests ; |
aoqi@0 | 157 | private SynchVariable svResponseReceived ; |
aoqi@0 | 158 | |
aoqi@0 | 159 | private java.lang.Object runObj = new java.lang.Object(); |
aoqi@0 | 160 | private java.lang.Object shutdownObj = new java.lang.Object(); |
aoqi@0 | 161 | private java.lang.Object waitForCompletionObj = new java.lang.Object(); |
aoqi@0 | 162 | private static final byte STATUS_OPERATING = 1; |
aoqi@0 | 163 | private static final byte STATUS_SHUTTING_DOWN = 2; |
aoqi@0 | 164 | private static final byte STATUS_SHUTDOWN = 3; |
aoqi@0 | 165 | private static final byte STATUS_DESTROYED = 4; |
aoqi@0 | 166 | private byte status = STATUS_OPERATING; |
aoqi@0 | 167 | |
aoqi@0 | 168 | // XXX Should we move invocation tracking to the first level server dispatcher? |
aoqi@0 | 169 | private java.lang.Object invocationObj = new java.lang.Object(); |
aoqi@0 | 170 | private int numInvocations = 0; |
aoqi@0 | 171 | |
aoqi@0 | 172 | // thread local variable to store a boolean to detect deadlock in |
aoqi@0 | 173 | // ORB.shutdown(true). |
aoqi@0 | 174 | private ThreadLocal isProcessingInvocation = new ThreadLocal () { |
aoqi@0 | 175 | protected java.lang.Object initialValue() { |
aoqi@0 | 176 | return Boolean.FALSE; |
aoqi@0 | 177 | } |
aoqi@0 | 178 | }; |
aoqi@0 | 179 | |
aoqi@0 | 180 | // This map is caching TypeCodes created for a certain class (key) |
aoqi@0 | 181 | // and is used in Util.writeAny() |
aoqi@0 | 182 | private Map typeCodeForClassMap ; |
aoqi@0 | 183 | |
aoqi@0 | 184 | // Cache to hold ValueFactories (Helper classes) keyed on repository ids |
aoqi@0 | 185 | private Hashtable valueFactoryCache = new Hashtable(); |
aoqi@0 | 186 | |
aoqi@0 | 187 | // thread local variable to store the current ORB version. |
aoqi@0 | 188 | // default ORB version is the version of ORB with correct Rep-id |
aoqi@0 | 189 | // changes |
aoqi@0 | 190 | private ThreadLocal orbVersionThreadLocal ; |
aoqi@0 | 191 | |
aoqi@0 | 192 | private RequestDispatcherRegistry requestDispatcherRegistry ; |
aoqi@0 | 193 | |
aoqi@0 | 194 | private CopierManager copierManager ; |
aoqi@0 | 195 | |
aoqi@0 | 196 | private int transientServerId ; |
aoqi@0 | 197 | |
aoqi@0 | 198 | private ServiceContextRegistry serviceContextRegistry ; |
aoqi@0 | 199 | |
aefimov@1618 | 200 | private IORTypeCheckRegistry iorTypeCheckRegistry; |
aefimov@1618 | 201 | |
aoqi@0 | 202 | // Needed here to implement connect/disconnect |
aoqi@0 | 203 | private TOAFactory toaFactory ; |
aoqi@0 | 204 | |
aoqi@0 | 205 | // Needed here for set_delegate |
aoqi@0 | 206 | private POAFactory poaFactory ; |
aoqi@0 | 207 | |
aoqi@0 | 208 | // The interceptor handler, which provides portable interceptor services for |
aoqi@0 | 209 | // subcontracts and object adapters. |
aoqi@0 | 210 | private PIHandler pihandler ; |
aoqi@0 | 211 | |
aoqi@0 | 212 | private ORBData configData ; |
aoqi@0 | 213 | |
aoqi@0 | 214 | private BadServerIdHandler badServerIdHandler ; |
aoqi@0 | 215 | |
aoqi@0 | 216 | private ClientDelegateFactory clientDelegateFactory ; |
aoqi@0 | 217 | |
aoqi@0 | 218 | private CorbaContactInfoListFactory corbaContactInfoListFactory ; |
aoqi@0 | 219 | |
aoqi@0 | 220 | // All access to resolver, localResolver, and urlOperation must be protected using |
aoqi@0 | 221 | // resolverLock. Do not hold the ORBImpl lock while accessing |
aoqi@0 | 222 | // resolver, or deadlocks may occur. |
aoqi@0 | 223 | // Note that we now have separate locks for each resolver type. This is due |
aoqi@0 | 224 | // to bug 6980681 and 6238477, which was caused by a deadlock while resolving a |
aoqi@0 | 225 | // corbaname: URL that contained a reference to the same ORB as the |
aoqi@0 | 226 | // ORB making the call to string_to_object. This caused a deadlock between the |
aoqi@0 | 227 | // client thread holding the single lock for access to the urlOperation, |
aoqi@0 | 228 | // and the server thread handling the client is_a request waiting on the |
aoqi@0 | 229 | // same lock to access the localResolver. |
aoqi@0 | 230 | |
aoqi@0 | 231 | |
aoqi@0 | 232 | // Used for resolver_initial_references and list_initial_services |
aoqi@0 | 233 | private Resolver resolver ; |
aoqi@0 | 234 | |
aoqi@0 | 235 | // Used for register_initial_references |
aoqi@0 | 236 | private LocalResolver localResolver ; |
aoqi@0 | 237 | |
aoqi@0 | 238 | // Converts strings to object references for resolvers and string_to_object |
aoqi@0 | 239 | private Operation urlOperation ; |
aoqi@0 | 240 | private final Object urlOperationLock = new java.lang.Object() ; |
aoqi@0 | 241 | |
aoqi@0 | 242 | private CorbaServerRequestDispatcher insNamingDelegate ; |
aoqi@0 | 243 | |
aoqi@0 | 244 | // resolverLock must be used for all access to either resolver or |
aoqi@0 | 245 | // localResolver, since it is possible for the resolver to indirectly |
aoqi@0 | 246 | // refer to the localResolver. Also used to protect access to |
aoqi@0 | 247 | // insNamingDelegate. |
aoqi@0 | 248 | private final Object resolverLock = new Object() ; |
aoqi@0 | 249 | |
aefimov@1618 | 250 | private static final String IORTYPECHECKREGISTRY_FILTER_PROPNAME = "com.sun.CORBA.ORBIorTypeCheckRegistryFilter"; |
aefimov@1618 | 251 | |
aoqi@0 | 252 | private TaggedComponentFactoryFinder taggedComponentFactoryFinder ; |
aoqi@0 | 253 | |
aoqi@0 | 254 | private IdentifiableFactoryFinder taggedProfileFactoryFinder ; |
aoqi@0 | 255 | |
aoqi@0 | 256 | private IdentifiableFactoryFinder taggedProfileTemplateFactoryFinder ; |
aoqi@0 | 257 | |
aoqi@0 | 258 | private ObjectKeyFactory objectKeyFactory ; |
aoqi@0 | 259 | |
aoqi@0 | 260 | private boolean orbOwnsThreadPoolManager = false ; |
aoqi@0 | 261 | |
aoqi@0 | 262 | private ThreadPoolManager threadpoolMgr; |
aoqi@0 | 263 | |
aoqi@0 | 264 | private void dprint( String msg ) |
aoqi@0 | 265 | { |
aoqi@0 | 266 | ORBUtility.dprint( this, msg ) ; |
aoqi@0 | 267 | } |
aoqi@0 | 268 | |
aoqi@0 | 269 | //////////////////////////////////////////////////// |
aoqi@0 | 270 | // |
aoqi@0 | 271 | // NOTE: |
aoqi@0 | 272 | // |
aoqi@0 | 273 | // Methods that are synchronized MUST stay synchronized. |
aoqi@0 | 274 | // |
aoqi@0 | 275 | // Methods that are NOT synchronized must stay that way to avoid deadlock. |
aoqi@0 | 276 | // |
aoqi@0 | 277 | // |
aoqi@0 | 278 | // REVISIT: |
aoqi@0 | 279 | // |
aoqi@0 | 280 | // checkShutDownState - lock on different object - and normalize usage. |
aoqi@0 | 281 | // starting/FinishDispatch and Shutdown |
aoqi@0 | 282 | // |
aoqi@0 | 283 | |
aoqi@0 | 284 | public ORBData getORBData() |
aoqi@0 | 285 | { |
aoqi@0 | 286 | return configData ; |
aoqi@0 | 287 | } |
aoqi@0 | 288 | |
aoqi@0 | 289 | public PIHandler getPIHandler() |
aoqi@0 | 290 | { |
aoqi@0 | 291 | return pihandler ; |
aoqi@0 | 292 | } |
aoqi@0 | 293 | |
aoqi@0 | 294 | /** |
aoqi@0 | 295 | * Create a new ORB. Should be followed by the appropriate |
aoqi@0 | 296 | * set_parameters() call. |
aoqi@0 | 297 | */ |
aoqi@0 | 298 | public ORBImpl() |
aoqi@0 | 299 | { |
aoqi@0 | 300 | // All initialization is done through set_parameters(). |
aoqi@0 | 301 | } |
aoqi@0 | 302 | |
aoqi@0 | 303 | public ORBVersion getORBVersion() |
aoqi@0 | 304 | { |
aoqi@0 | 305 | synchronized (this) { |
aoqi@0 | 306 | checkShutdownState(); |
aoqi@0 | 307 | } |
aoqi@0 | 308 | return (ORBVersion)(orbVersionThreadLocal.get()) ; |
aoqi@0 | 309 | } |
aoqi@0 | 310 | |
aoqi@0 | 311 | public void setORBVersion(ORBVersion verObj) |
aoqi@0 | 312 | { |
aoqi@0 | 313 | synchronized (this) { |
aoqi@0 | 314 | checkShutdownState(); |
aoqi@0 | 315 | } |
aoqi@0 | 316 | orbVersionThreadLocal.set(verObj); |
aoqi@0 | 317 | } |
aoqi@0 | 318 | |
aoqi@0 | 319 | /**************************************************************************** |
aoqi@0 | 320 | * The following methods are ORB initialization |
aoqi@0 | 321 | ****************************************************************************/ |
aoqi@0 | 322 | |
aoqi@0 | 323 | // preInit initializes all non-pluggable ORB data that is independent |
aoqi@0 | 324 | // of the property parsing. |
aoqi@0 | 325 | private void preInit( String[] params, Properties props ) |
aoqi@0 | 326 | { |
aoqi@0 | 327 | // Before ORBConfiguration we need to set a PINoOpHandlerImpl, |
aoqi@0 | 328 | // because PersisentServer Initialization inside configurator will |
aoqi@0 | 329 | // invoke orb.resolve_initial_references( ) which will result in a |
aoqi@0 | 330 | // check on piHandler to invoke Interceptors. We do not want any |
aoqi@0 | 331 | // Interceptors to be invoked before the complete ORB initialization. |
aoqi@0 | 332 | // piHandler will be replaced by a real PIHandler implementation at the |
aoqi@0 | 333 | // end of this method. |
aoqi@0 | 334 | pihandler = new PINoOpHandlerImpl( ); |
aoqi@0 | 335 | |
aoqi@0 | 336 | // This is the unique id of this server (JVM). Multiple incarnations |
aoqi@0 | 337 | // of this server will get different ids. |
aoqi@0 | 338 | // Compute transientServerId = milliseconds since Jan 1, 1970 |
aoqi@0 | 339 | // Note: transientServerId will wrap in about 2^32 / 86400000 = 49.7 days. |
aoqi@0 | 340 | // If two ORBS are started at the same time then there is a possibility |
aoqi@0 | 341 | // of having the same transientServerId. This may result in collision |
aoqi@0 | 342 | // and may be a problem in ior.isLocal() check to see if the object |
aoqi@0 | 343 | // belongs to the current ORB. This problem is taken care of by checking |
aoqi@0 | 344 | // to see if the IOR port matches ORB server port in legacyIsLocalServerPort() |
aoqi@0 | 345 | // method. |
aoqi@0 | 346 | // |
aoqi@0 | 347 | // XXX need to move server ID to a string for CORBA 3.0. At that point, |
aoqi@0 | 348 | // make this more unique (possibly use java.rmi.server.UID). |
aoqi@0 | 349 | transientServerId = (int)System.currentTimeMillis(); |
aoqi@0 | 350 | |
aoqi@0 | 351 | orbVersionThreadLocal = new ThreadLocal () { |
aoqi@0 | 352 | protected java.lang.Object initialValue() { |
aoqi@0 | 353 | // set default to version of the ORB with correct Rep-ids |
aoqi@0 | 354 | return ORBVersionFactory.getORBVersion() ; |
aoqi@0 | 355 | } |
aoqi@0 | 356 | }; |
aoqi@0 | 357 | |
aoqi@0 | 358 | |
aoqi@0 | 359 | requestDispatcherRegistry = new RequestDispatcherRegistryImpl( |
aoqi@0 | 360 | this, ORBConstants.DEFAULT_SCID); |
aoqi@0 | 361 | copierManager = new CopierManagerImpl( this ) ; |
aoqi@0 | 362 | |
aoqi@0 | 363 | taggedComponentFactoryFinder = |
aoqi@0 | 364 | new TaggedComponentFactoryFinderImpl(this) ; |
aoqi@0 | 365 | taggedProfileFactoryFinder = |
aoqi@0 | 366 | new TaggedProfileFactoryFinderImpl(this) ; |
aoqi@0 | 367 | taggedProfileTemplateFactoryFinder = |
aoqi@0 | 368 | new TaggedProfileTemplateFactoryFinderImpl(this) ; |
aoqi@0 | 369 | |
aoqi@0 | 370 | dynamicRequests = new Vector(); |
aoqi@0 | 371 | svResponseReceived = new SynchVariable(); |
aoqi@0 | 372 | |
aoqi@0 | 373 | OAInvocationInfoStack = |
aoqi@0 | 374 | new ThreadLocal () { |
aoqi@0 | 375 | protected java.lang.Object initialValue() |
aoqi@0 | 376 | { |
aoqi@0 | 377 | return new StackImpl(); |
aoqi@0 | 378 | } |
aoqi@0 | 379 | }; |
aoqi@0 | 380 | |
aoqi@0 | 381 | clientInvocationInfoStack = |
aoqi@0 | 382 | new ThreadLocal() { |
aoqi@0 | 383 | protected java.lang.Object initialValue() { |
aoqi@0 | 384 | return new StackImpl(); |
aoqi@0 | 385 | } |
aoqi@0 | 386 | }; |
aoqi@0 | 387 | |
aoqi@0 | 388 | serviceContextRegistry = new ServiceContextRegistry( this ) ; |
aoqi@0 | 389 | } |
aoqi@0 | 390 | |
aefimov@1618 | 391 | private void initIORTypeCheckRegistry() { |
aefimov@1618 | 392 | String filterProps = AccessController |
aefimov@1618 | 393 | .doPrivileged(new PrivilegedAction<String>() { |
aefimov@1618 | 394 | public String run() { |
aefimov@1618 | 395 | String props = System |
aefimov@1618 | 396 | .getProperty(IORTYPECHECKREGISTRY_FILTER_PROPNAME); |
aefimov@1618 | 397 | if (props == null) { |
aefimov@1618 | 398 | props = Security |
aefimov@1618 | 399 | .getProperty(IORTYPECHECKREGISTRY_FILTER_PROPNAME); |
aefimov@1618 | 400 | } |
aefimov@1618 | 401 | return props; |
aefimov@1618 | 402 | } |
aefimov@1618 | 403 | }); |
aefimov@1618 | 404 | if (filterProps != null) { |
aefimov@1618 | 405 | try { |
aefimov@1618 | 406 | iorTypeCheckRegistry = new IORTypeCheckRegistryImpl(filterProps, this); |
aefimov@1618 | 407 | } catch (Exception ex) { |
aefimov@1618 | 408 | throw wrapper.bootstrapException(ex); |
aefimov@1618 | 409 | } |
aefimov@1618 | 410 | |
aefimov@1618 | 411 | if (this.orbInitDebugFlag) { |
aefimov@1618 | 412 | dprint(".initIORTypeCheckRegistry, IORTypeCheckRegistryImpl created for properties == " |
aefimov@1618 | 413 | + filterProps); |
aefimov@1618 | 414 | } |
aefimov@1618 | 415 | } else { |
aefimov@1618 | 416 | if (this.orbInitDebugFlag) { |
aefimov@1618 | 417 | dprint(".initIORTypeCheckRegistry, IORTypeCheckRegistryImpl NOT created for properties == "); |
aefimov@1618 | 418 | } |
aefimov@1618 | 419 | } |
aefimov@1618 | 420 | } |
aefimov@1618 | 421 | |
aoqi@0 | 422 | protected void setDebugFlags( String[] args ) |
aoqi@0 | 423 | { |
aoqi@0 | 424 | for (int ctr=0; ctr<args.length; ctr++ ) { |
aoqi@0 | 425 | String token = args[ctr] ; |
aoqi@0 | 426 | |
aoqi@0 | 427 | // If there is a public boolean data member in this class |
aoqi@0 | 428 | // named token + "DebugFlag", set it to true. |
aoqi@0 | 429 | try { |
aoqi@0 | 430 | Field fld = this.getClass().getField( token + "DebugFlag" ) ; |
aoqi@0 | 431 | int mod = fld.getModifiers() ; |
aoqi@0 | 432 | if (Modifier.isPublic( mod ) && !Modifier.isStatic( mod )) |
aoqi@0 | 433 | if (fld.getType() == boolean.class) |
aoqi@0 | 434 | fld.setBoolean( this, true ) ; |
aoqi@0 | 435 | } catch (Exception exc) { |
aoqi@0 | 436 | // ignore it XXX log this as info |
aoqi@0 | 437 | } |
aoqi@0 | 438 | } |
aoqi@0 | 439 | } |
aoqi@0 | 440 | |
aoqi@0 | 441 | // Class that defines a parser that gets the name of the |
aoqi@0 | 442 | // ORBConfigurator class. |
aoqi@0 | 443 | private static class ConfigParser extends ParserImplBase { |
aoqi@0 | 444 | // The default here is the ORBConfiguratorImpl that we define, |
aoqi@0 | 445 | // but this can be replaced. |
aoqi@0 | 446 | public Class configurator = ORBConfiguratorImpl.class ; |
aoqi@0 | 447 | |
aoqi@0 | 448 | public PropertyParser makeParser() |
aoqi@0 | 449 | { |
aoqi@0 | 450 | PropertyParser parser = new PropertyParser() ; |
aoqi@0 | 451 | parser.add( ORBConstants.SUN_PREFIX + "ORBConfigurator", |
aoqi@0 | 452 | OperationFactory.classAction(), "configurator" ) ; |
aoqi@0 | 453 | return parser ; |
aoqi@0 | 454 | } |
aoqi@0 | 455 | } |
aoqi@0 | 456 | |
aoqi@0 | 457 | private void postInit( String[] params, DataCollector dataCollector ) |
aoqi@0 | 458 | { |
aoqi@0 | 459 | // First, create the standard ORB config data. |
aoqi@0 | 460 | // This must be initialized before the ORBConfigurator |
aoqi@0 | 461 | // is executed. |
aoqi@0 | 462 | configData = new ORBDataParserImpl( this, dataCollector) ; |
aoqi@0 | 463 | |
aoqi@0 | 464 | // Set the debug flags early so they can be used by other |
aoqi@0 | 465 | // parts of the initialization. |
aoqi@0 | 466 | setDebugFlags( configData.getORBDebugFlags() ) ; |
aoqi@0 | 467 | |
aoqi@0 | 468 | // REVISIT: this should go away after more transport init cleanup |
aoqi@0 | 469 | // and going to ORT based ORBD. |
aoqi@0 | 470 | getTransportManager(); |
aoqi@0 | 471 | getLegacyServerSocketManager(); |
aoqi@0 | 472 | |
aoqi@0 | 473 | // Create a parser to get the configured ORBConfigurator. |
aoqi@0 | 474 | ConfigParser parser = new ConfigParser() ; |
aoqi@0 | 475 | parser.init( dataCollector ) ; |
aoqi@0 | 476 | |
aoqi@0 | 477 | ORBConfigurator configurator = null ; |
aoqi@0 | 478 | try { |
aoqi@0 | 479 | configurator = |
aoqi@0 | 480 | (ORBConfigurator)(parser.configurator.newInstance()) ; |
aoqi@0 | 481 | } catch (Exception iexc) { |
aoqi@0 | 482 | throw wrapper.badOrbConfigurator( iexc, parser.configurator.getName() ) ; |
aoqi@0 | 483 | } |
aoqi@0 | 484 | |
aoqi@0 | 485 | // Finally, run the configurator. Note that the default implementation allows |
aoqi@0 | 486 | // other configurators with their own parsers to run, |
aoqi@0 | 487 | // using the same DataCollector. |
aoqi@0 | 488 | try { |
aoqi@0 | 489 | configurator.configure( dataCollector, this ) ; |
aoqi@0 | 490 | } catch (Exception exc) { |
aoqi@0 | 491 | throw wrapper.orbConfiguratorError( exc ) ; |
aoqi@0 | 492 | } |
aoqi@0 | 493 | |
aoqi@0 | 494 | // Last of all, create the PIHandler and run the ORB initializers. |
aoqi@0 | 495 | pihandler = new PIHandlerImpl( this, params) ; |
aoqi@0 | 496 | pihandler.initialize() ; |
aoqi@0 | 497 | |
aoqi@0 | 498 | // Initialize the thread manager pool and byte buffer pool |
aoqi@0 | 499 | // so they may be initialized & accessed without synchronization |
aoqi@0 | 500 | getThreadPoolManager(); |
aoqi@0 | 501 | |
aoqi@0 | 502 | super.getByteBufferPool(); |
aefimov@1618 | 503 | |
aefimov@1618 | 504 | initIORTypeCheckRegistry(); |
aoqi@0 | 505 | } |
aoqi@0 | 506 | |
aoqi@0 | 507 | private synchronized POAFactory getPOAFactory() |
aoqi@0 | 508 | { |
aoqi@0 | 509 | if (poaFactory == null) { |
aoqi@0 | 510 | poaFactory = (POAFactory)requestDispatcherRegistry.getObjectAdapterFactory( |
aoqi@0 | 511 | ORBConstants.TRANSIENT_SCID ) ; |
aoqi@0 | 512 | } |
aoqi@0 | 513 | |
aoqi@0 | 514 | return poaFactory ; |
aoqi@0 | 515 | } |
aoqi@0 | 516 | |
aoqi@0 | 517 | private synchronized TOAFactory getTOAFactory() |
aoqi@0 | 518 | { |
aoqi@0 | 519 | if (toaFactory == null) { |
aoqi@0 | 520 | toaFactory = (TOAFactory)requestDispatcherRegistry.getObjectAdapterFactory( |
aoqi@0 | 521 | ORBConstants.TOA_SCID ) ; |
aoqi@0 | 522 | } |
aoqi@0 | 523 | |
aoqi@0 | 524 | return toaFactory ; |
aoqi@0 | 525 | } |
aoqi@0 | 526 | |
aoqi@0 | 527 | public void set_parameters( Properties props ) |
aoqi@0 | 528 | { |
aoqi@0 | 529 | synchronized (this) { |
aoqi@0 | 530 | checkShutdownState(); |
aoqi@0 | 531 | } |
aoqi@0 | 532 | preInit( null, props ) ; |
aoqi@0 | 533 | DataCollector dataCollector = |
aoqi@0 | 534 | DataCollectorFactory.create( props, getLocalHostName() ) ; |
aoqi@0 | 535 | postInit( null, dataCollector ) ; |
aoqi@0 | 536 | } |
aoqi@0 | 537 | |
aoqi@0 | 538 | protected void set_parameters(Applet app, Properties props) |
aoqi@0 | 539 | { |
aoqi@0 | 540 | preInit( null, props ) ; |
aoqi@0 | 541 | DataCollector dataCollector = |
aoqi@0 | 542 | DataCollectorFactory.create( app, props, getLocalHostName() ) ; |
aoqi@0 | 543 | postInit( null, dataCollector ) ; |
aoqi@0 | 544 | } |
aoqi@0 | 545 | |
aoqi@0 | 546 | protected void set_parameters (String[] params, Properties props) |
aoqi@0 | 547 | { |
aoqi@0 | 548 | preInit( params, props ) ; |
aoqi@0 | 549 | DataCollector dataCollector = |
aoqi@0 | 550 | DataCollectorFactory.create( params, props, getLocalHostName() ) ; |
aoqi@0 | 551 | postInit( params, dataCollector ) ; |
aoqi@0 | 552 | } |
aoqi@0 | 553 | |
aoqi@0 | 554 | /**************************************************************************** |
aoqi@0 | 555 | * The following methods are standard public CORBA ORB APIs |
aoqi@0 | 556 | ****************************************************************************/ |
aoqi@0 | 557 | |
aoqi@0 | 558 | public synchronized org.omg.CORBA.portable.OutputStream create_output_stream() |
aoqi@0 | 559 | { |
aoqi@0 | 560 | checkShutdownState(); |
aoqi@0 | 561 | return sun.corba.OutputStreamFactory.newEncapsOutputStream(this); |
aoqi@0 | 562 | } |
aoqi@0 | 563 | |
aoqi@0 | 564 | /** |
aoqi@0 | 565 | * Get a Current pseudo-object. |
aoqi@0 | 566 | * The Current interface is used to manage thread-specific |
aoqi@0 | 567 | * information for use by the transactions, security and other |
aoqi@0 | 568 | * services. This method is deprecated, |
aoqi@0 | 569 | * and replaced by ORB.resolve_initial_references("NameOfCurrentObject"); |
aoqi@0 | 570 | * |
aoqi@0 | 571 | * @return a Current pseudo-object. |
aoqi@0 | 572 | * @deprecated |
aoqi@0 | 573 | */ |
aoqi@0 | 574 | public synchronized org.omg.CORBA.Current get_current() |
aoqi@0 | 575 | { |
aoqi@0 | 576 | checkShutdownState(); |
aoqi@0 | 577 | |
aoqi@0 | 578 | /* _REVISIT_ |
aoqi@0 | 579 | The implementation of get_current is not clear. How would |
aoqi@0 | 580 | ORB know whether the caller wants a Current for transactions |
aoqi@0 | 581 | or security ?? Or is it assumed that there is just one |
aoqi@0 | 582 | implementation for both ? If Current is thread-specific, |
aoqi@0 | 583 | then it should not be instantiated; so where does the |
aoqi@0 | 584 | ORB get a Current ? |
aoqi@0 | 585 | |
aoqi@0 | 586 | This should probably be deprecated. */ |
aoqi@0 | 587 | |
aoqi@0 | 588 | throw wrapper.genericNoImpl() ; |
aoqi@0 | 589 | } |
aoqi@0 | 590 | |
aoqi@0 | 591 | /** |
aoqi@0 | 592 | * Create an NVList |
aoqi@0 | 593 | * |
aoqi@0 | 594 | * @param count size of list to create |
aoqi@0 | 595 | * @result NVList created |
aoqi@0 | 596 | * |
aoqi@0 | 597 | * @see NVList |
aoqi@0 | 598 | */ |
aoqi@0 | 599 | public synchronized NVList create_list(int count) |
aoqi@0 | 600 | { |
aoqi@0 | 601 | checkShutdownState(); |
aoqi@0 | 602 | return new NVListImpl(this, count); |
aoqi@0 | 603 | } |
aoqi@0 | 604 | |
aoqi@0 | 605 | /** |
aoqi@0 | 606 | * Create an NVList corresponding to an OperationDef |
aoqi@0 | 607 | * |
aoqi@0 | 608 | * @param oper operation def to use to create list |
aoqi@0 | 609 | * @result NVList created |
aoqi@0 | 610 | * |
aoqi@0 | 611 | * @see NVList |
aoqi@0 | 612 | */ |
aoqi@0 | 613 | public synchronized NVList create_operation_list(org.omg.CORBA.Object oper) |
aoqi@0 | 614 | { |
aoqi@0 | 615 | checkShutdownState(); |
aoqi@0 | 616 | throw wrapper.genericNoImpl() ; |
aoqi@0 | 617 | } |
aoqi@0 | 618 | |
aoqi@0 | 619 | /** |
aoqi@0 | 620 | * Create a NamedValue |
aoqi@0 | 621 | * |
aoqi@0 | 622 | * @result NamedValue created |
aoqi@0 | 623 | */ |
aoqi@0 | 624 | public synchronized NamedValue create_named_value(String s, Any any, int flags) |
aoqi@0 | 625 | { |
aoqi@0 | 626 | checkShutdownState(); |
aoqi@0 | 627 | return new NamedValueImpl(this, s, any, flags); |
aoqi@0 | 628 | } |
aoqi@0 | 629 | |
aoqi@0 | 630 | /** |
aoqi@0 | 631 | * Create an ExceptionList |
aoqi@0 | 632 | * |
aoqi@0 | 633 | * @result ExceptionList created |
aoqi@0 | 634 | */ |
aoqi@0 | 635 | public synchronized org.omg.CORBA.ExceptionList create_exception_list() |
aoqi@0 | 636 | { |
aoqi@0 | 637 | checkShutdownState(); |
aoqi@0 | 638 | return new ExceptionListImpl(); |
aoqi@0 | 639 | } |
aoqi@0 | 640 | |
aoqi@0 | 641 | /** |
aoqi@0 | 642 | * Create a ContextList |
aoqi@0 | 643 | * |
aoqi@0 | 644 | * @result ContextList created |
aoqi@0 | 645 | */ |
aoqi@0 | 646 | public synchronized org.omg.CORBA.ContextList create_context_list() |
aoqi@0 | 647 | { |
aoqi@0 | 648 | checkShutdownState(); |
aoqi@0 | 649 | return new ContextListImpl(this); |
aoqi@0 | 650 | } |
aoqi@0 | 651 | |
aoqi@0 | 652 | /** |
aoqi@0 | 653 | * Get the default Context object |
aoqi@0 | 654 | * |
aoqi@0 | 655 | * @result the default Context object |
aoqi@0 | 656 | */ |
aoqi@0 | 657 | public synchronized org.omg.CORBA.Context get_default_context() |
aoqi@0 | 658 | { |
aoqi@0 | 659 | checkShutdownState(); |
aoqi@0 | 660 | throw wrapper.genericNoImpl() ; |
aoqi@0 | 661 | } |
aoqi@0 | 662 | |
aoqi@0 | 663 | /** |
aoqi@0 | 664 | * Create an Environment |
aoqi@0 | 665 | * |
aoqi@0 | 666 | * @result Environment created |
aoqi@0 | 667 | */ |
aoqi@0 | 668 | public synchronized org.omg.CORBA.Environment create_environment() |
aoqi@0 | 669 | { |
aoqi@0 | 670 | checkShutdownState(); |
aoqi@0 | 671 | return new EnvironmentImpl(); |
aoqi@0 | 672 | } |
aoqi@0 | 673 | |
aoqi@0 | 674 | public synchronized void send_multiple_requests_oneway(Request[] req) |
aoqi@0 | 675 | { |
aoqi@0 | 676 | checkShutdownState(); |
aoqi@0 | 677 | |
aoqi@0 | 678 | // Invoke the send_oneway on each new Request |
aoqi@0 | 679 | for (int i = 0; i < req.length; i++) { |
aoqi@0 | 680 | req[i].send_oneway(); |
aoqi@0 | 681 | } |
aoqi@0 | 682 | } |
aoqi@0 | 683 | |
aoqi@0 | 684 | /** |
aoqi@0 | 685 | * Send multiple dynamic requests asynchronously. |
aoqi@0 | 686 | * |
aoqi@0 | 687 | * @param req an array of request objects. |
aoqi@0 | 688 | */ |
aoqi@0 | 689 | public synchronized void send_multiple_requests_deferred(Request[] req) |
aoqi@0 | 690 | { |
aoqi@0 | 691 | checkShutdownState(); |
aoqi@0 | 692 | |
aoqi@0 | 693 | // add the new Requests to pending dynamic Requests |
aoqi@0 | 694 | for (int i = 0; i < req.length; i++) { |
aoqi@0 | 695 | dynamicRequests.addElement(req[i]); |
aoqi@0 | 696 | } |
aoqi@0 | 697 | |
aoqi@0 | 698 | // Invoke the send_deferred on each new Request |
aoqi@0 | 699 | for (int i = 0; i < req.length; i++) { |
aoqi@0 | 700 | AsynchInvoke invokeObject = new AsynchInvoke( this, |
aoqi@0 | 701 | (com.sun.corba.se.impl.corba.RequestImpl)req[i], true); |
aoqi@0 | 702 | new Thread(invokeObject).start(); |
aoqi@0 | 703 | } |
aoqi@0 | 704 | } |
aoqi@0 | 705 | |
aoqi@0 | 706 | /** |
aoqi@0 | 707 | * Find out if any of the deferred invocations have a response yet. |
aoqi@0 | 708 | */ |
aoqi@0 | 709 | public synchronized boolean poll_next_response() |
aoqi@0 | 710 | { |
aoqi@0 | 711 | checkShutdownState(); |
aoqi@0 | 712 | |
aoqi@0 | 713 | Request currRequest; |
aoqi@0 | 714 | |
aoqi@0 | 715 | // poll on each pending request |
aoqi@0 | 716 | Enumeration ve = dynamicRequests.elements(); |
aoqi@0 | 717 | while (ve.hasMoreElements() == true) { |
aoqi@0 | 718 | currRequest = (Request)ve.nextElement(); |
aoqi@0 | 719 | if (currRequest.poll_response() == true) { |
aoqi@0 | 720 | return true; |
aoqi@0 | 721 | } |
aoqi@0 | 722 | } |
aoqi@0 | 723 | return false; |
aoqi@0 | 724 | } |
aoqi@0 | 725 | |
aoqi@0 | 726 | /** |
aoqi@0 | 727 | * Get the next request that has gotten a response. |
aoqi@0 | 728 | * |
aoqi@0 | 729 | * @result the next request ready with a response. |
aoqi@0 | 730 | */ |
aoqi@0 | 731 | public org.omg.CORBA.Request get_next_response() |
aoqi@0 | 732 | throws org.omg.CORBA.WrongTransaction |
aoqi@0 | 733 | { |
aoqi@0 | 734 | synchronized( this ) { |
aoqi@0 | 735 | checkShutdownState(); |
aoqi@0 | 736 | } |
aoqi@0 | 737 | |
aoqi@0 | 738 | while (true) { |
aoqi@0 | 739 | // check if there already is a response |
aoqi@0 | 740 | synchronized ( dynamicRequests ) { |
aoqi@0 | 741 | Enumeration elems = dynamicRequests.elements(); |
aoqi@0 | 742 | while ( elems.hasMoreElements() ) { |
aoqi@0 | 743 | Request currRequest = (Request)elems.nextElement(); |
aoqi@0 | 744 | if ( currRequest.poll_response() ) { |
aoqi@0 | 745 | // get the response for this successfully polled Request |
aoqi@0 | 746 | currRequest.get_response(); |
aoqi@0 | 747 | dynamicRequests.removeElement(currRequest); |
aoqi@0 | 748 | return currRequest; |
aoqi@0 | 749 | } |
aoqi@0 | 750 | } |
aoqi@0 | 751 | } |
aoqi@0 | 752 | |
aoqi@0 | 753 | // wait for a response |
aoqi@0 | 754 | synchronized(this.svResponseReceived) { |
aoqi@0 | 755 | while (!this.svResponseReceived.value()) { |
aoqi@0 | 756 | try { |
aoqi@0 | 757 | this.svResponseReceived.wait(); |
aoqi@0 | 758 | } catch(java.lang.InterruptedException ex) { |
aoqi@0 | 759 | // NO-OP |
aoqi@0 | 760 | } |
aoqi@0 | 761 | } |
aoqi@0 | 762 | // reinitialize the response flag |
aoqi@0 | 763 | this.svResponseReceived.reset(); |
aoqi@0 | 764 | } |
aoqi@0 | 765 | } |
aoqi@0 | 766 | } |
aoqi@0 | 767 | |
aoqi@0 | 768 | /** |
aoqi@0 | 769 | * Notify response to ORB for get_next_response |
aoqi@0 | 770 | */ |
aoqi@0 | 771 | public void notifyORB() |
aoqi@0 | 772 | { |
aoqi@0 | 773 | synchronized (this) { |
aoqi@0 | 774 | checkShutdownState(); |
aoqi@0 | 775 | } |
aoqi@0 | 776 | synchronized (this.svResponseReceived) { |
aoqi@0 | 777 | this.svResponseReceived.set(); |
aoqi@0 | 778 | this.svResponseReceived.notify(); |
aoqi@0 | 779 | } |
aoqi@0 | 780 | } |
aoqi@0 | 781 | |
aoqi@0 | 782 | /** |
aoqi@0 | 783 | * Convert an object ref to a string. |
aoqi@0 | 784 | * @param obj The object to stringify. |
aoqi@0 | 785 | * @return A stringified object reference. |
aoqi@0 | 786 | */ |
aoqi@0 | 787 | public synchronized String object_to_string(org.omg.CORBA.Object obj) |
aoqi@0 | 788 | { |
aoqi@0 | 789 | checkShutdownState(); |
aoqi@0 | 790 | |
aoqi@0 | 791 | // Handle the null objref case |
aoqi@0 | 792 | if (obj == null) { |
aoqi@0 | 793 | IOR nullIOR = IORFactories.makeIOR( this ) ; |
aoqi@0 | 794 | return nullIOR.stringify(); |
aoqi@0 | 795 | } |
aoqi@0 | 796 | |
aoqi@0 | 797 | IOR ior = null ; |
aoqi@0 | 798 | |
aoqi@0 | 799 | try { |
aoqi@0 | 800 | ior = ORBUtility.connectAndGetIOR( this, obj ) ; |
aoqi@0 | 801 | } catch (BAD_PARAM bp) { |
aoqi@0 | 802 | // Throw MARSHAL instead if this is a LOCAL_OBJECT_NOT_ALLOWED error. |
aoqi@0 | 803 | if (bp.minor == ORBUtilSystemException.LOCAL_OBJECT_NOT_ALLOWED) { |
aoqi@0 | 804 | throw omgWrapper.notAnObjectImpl( bp ) ; |
aoqi@0 | 805 | } else |
aoqi@0 | 806 | // Not a local object problem: just rethrow the exception. |
aoqi@0 | 807 | // Do not wrap and log this, since it was already logged at its |
aoqi@0 | 808 | // point of origin. |
aoqi@0 | 809 | throw bp ; |
aoqi@0 | 810 | } |
aoqi@0 | 811 | |
aoqi@0 | 812 | return ior.stringify() ; |
aoqi@0 | 813 | } |
aoqi@0 | 814 | |
aoqi@0 | 815 | /** |
aoqi@0 | 816 | * Convert a stringified object reference to the object it represents. |
aoqi@0 | 817 | * @param str The stringified object reference. |
aoqi@0 | 818 | * @return The unstringified object reference. |
aoqi@0 | 819 | */ |
aoqi@0 | 820 | public org.omg.CORBA.Object string_to_object(String str) |
aoqi@0 | 821 | { |
aoqi@0 | 822 | Operation op ; |
aoqi@0 | 823 | |
aoqi@0 | 824 | synchronized (this) { |
aoqi@0 | 825 | checkShutdownState(); |
aoqi@0 | 826 | op = urlOperation ; |
aoqi@0 | 827 | } |
aoqi@0 | 828 | |
aoqi@0 | 829 | if (str == null) |
aoqi@0 | 830 | throw wrapper.nullParam() ; |
aoqi@0 | 831 | |
aoqi@0 | 832 | synchronized (urlOperationLock) { |
aoqi@0 | 833 | org.omg.CORBA.Object obj = (org.omg.CORBA.Object)op.operate( str ) ; |
aoqi@0 | 834 | return obj ; |
aoqi@0 | 835 | } |
aoqi@0 | 836 | } |
aoqi@0 | 837 | |
aoqi@0 | 838 | // pure java orb support, moved this method from FVDCodeBaseImpl. |
aoqi@0 | 839 | // Note that we connect this if we have not already done so. |
aoqi@0 | 840 | public synchronized IOR getFVDCodeBaseIOR() |
aoqi@0 | 841 | { |
aoqi@0 | 842 | checkShutdownState(); |
aoqi@0 | 843 | |
aoqi@0 | 844 | if (codeBaseIOR != null) // i.e. We are already connected to it |
aoqi@0 | 845 | return codeBaseIOR; |
aoqi@0 | 846 | |
aoqi@0 | 847 | // backward compatability 4365188 |
aoqi@0 | 848 | CodeBase cb; |
aoqi@0 | 849 | |
aoqi@0 | 850 | ValueHandler vh = ORBUtility.createValueHandler(); |
aoqi@0 | 851 | |
aoqi@0 | 852 | cb = (CodeBase)vh.getRunTimeCodeBase(); |
aoqi@0 | 853 | return ORBUtility.connectAndGetIOR( this, cb ) ; |
aoqi@0 | 854 | } |
aoqi@0 | 855 | |
aoqi@0 | 856 | /** |
aoqi@0 | 857 | * Get the TypeCode for a primitive type. |
aoqi@0 | 858 | * |
aoqi@0 | 859 | * @param tcKind the integer kind for the primitive type |
aoqi@0 | 860 | * @return the requested TypeCode |
aoqi@0 | 861 | */ |
aoqi@0 | 862 | public synchronized TypeCode get_primitive_tc(TCKind tcKind) |
aoqi@0 | 863 | { |
aoqi@0 | 864 | checkShutdownState(); |
aoqi@0 | 865 | return get_primitive_tc( tcKind.value() ) ; |
aoqi@0 | 866 | } |
aoqi@0 | 867 | |
aoqi@0 | 868 | /** |
aoqi@0 | 869 | * Create a TypeCode for a structure. |
aoqi@0 | 870 | * |
aoqi@0 | 871 | * @param id the logical id for the typecode. |
aoqi@0 | 872 | * @param name the name for the typecode. |
aoqi@0 | 873 | * @param members an array describing the members of the TypeCode. |
aoqi@0 | 874 | * @return the requested TypeCode. |
aoqi@0 | 875 | */ |
aoqi@0 | 876 | public synchronized TypeCode create_struct_tc(String id, |
aoqi@0 | 877 | String name, |
aoqi@0 | 878 | StructMember[] members) |
aoqi@0 | 879 | { |
aoqi@0 | 880 | checkShutdownState(); |
aoqi@0 | 881 | return new TypeCodeImpl(this, TCKind._tk_struct, id, name, members); |
aoqi@0 | 882 | } |
aoqi@0 | 883 | |
aoqi@0 | 884 | /** |
aoqi@0 | 885 | * Create a TypeCode for a union. |
aoqi@0 | 886 | * |
aoqi@0 | 887 | * @param id the logical id for the typecode. |
aoqi@0 | 888 | * @param name the name for the typecode. |
aoqi@0 | 889 | * @param discriminator_type |
aoqi@0 | 890 | * the type of the union discriminator. |
aoqi@0 | 891 | * @param members an array describing the members of the TypeCode. |
aoqi@0 | 892 | * @return the requested TypeCode. |
aoqi@0 | 893 | */ |
aoqi@0 | 894 | public synchronized TypeCode create_union_tc(String id, |
aoqi@0 | 895 | String name, |
aoqi@0 | 896 | TypeCode discriminator_type, |
aoqi@0 | 897 | UnionMember[] members) |
aoqi@0 | 898 | { |
aoqi@0 | 899 | checkShutdownState(); |
aoqi@0 | 900 | return new TypeCodeImpl(this, |
aoqi@0 | 901 | TCKind._tk_union, |
aoqi@0 | 902 | id, |
aoqi@0 | 903 | name, |
aoqi@0 | 904 | discriminator_type, |
aoqi@0 | 905 | members); |
aoqi@0 | 906 | } |
aoqi@0 | 907 | |
aoqi@0 | 908 | /** |
aoqi@0 | 909 | * Create a TypeCode for an enum. |
aoqi@0 | 910 | * |
aoqi@0 | 911 | * @param id the logical id for the typecode. |
aoqi@0 | 912 | * @param name the name for the typecode. |
aoqi@0 | 913 | * @param members an array describing the members of the TypeCode. |
aoqi@0 | 914 | * @return the requested TypeCode. |
aoqi@0 | 915 | */ |
aoqi@0 | 916 | public synchronized TypeCode create_enum_tc(String id, |
aoqi@0 | 917 | String name, |
aoqi@0 | 918 | String[] members) |
aoqi@0 | 919 | { |
aoqi@0 | 920 | checkShutdownState(); |
aoqi@0 | 921 | return new TypeCodeImpl(this, TCKind._tk_enum, id, name, members); |
aoqi@0 | 922 | } |
aoqi@0 | 923 | |
aoqi@0 | 924 | /** |
aoqi@0 | 925 | * Create a TypeCode for an alias. |
aoqi@0 | 926 | * |
aoqi@0 | 927 | * @param id the logical id for the typecode. |
aoqi@0 | 928 | * @param name the name for the typecode. |
aoqi@0 | 929 | * @param original_type |
aoqi@0 | 930 | * the type this is an alias for. |
aoqi@0 | 931 | * @return the requested TypeCode. |
aoqi@0 | 932 | */ |
aoqi@0 | 933 | public synchronized TypeCode create_alias_tc(String id, |
aoqi@0 | 934 | String name, |
aoqi@0 | 935 | TypeCode original_type) |
aoqi@0 | 936 | { |
aoqi@0 | 937 | checkShutdownState(); |
aoqi@0 | 938 | return new TypeCodeImpl(this, TCKind._tk_alias, id, name, original_type); |
aoqi@0 | 939 | } |
aoqi@0 | 940 | |
aoqi@0 | 941 | /** |
aoqi@0 | 942 | * Create a TypeCode for an exception. |
aoqi@0 | 943 | * |
aoqi@0 | 944 | * @param id the logical id for the typecode. |
aoqi@0 | 945 | * @param name the name for the typecode. |
aoqi@0 | 946 | * @param members an array describing the members of the TypeCode. |
aoqi@0 | 947 | * @return the requested TypeCode. |
aoqi@0 | 948 | */ |
aoqi@0 | 949 | public synchronized TypeCode create_exception_tc(String id, |
aoqi@0 | 950 | String name, |
aoqi@0 | 951 | StructMember[] members) |
aoqi@0 | 952 | { |
aoqi@0 | 953 | checkShutdownState(); |
aoqi@0 | 954 | return new TypeCodeImpl(this, TCKind._tk_except, id, name, members); |
aoqi@0 | 955 | } |
aoqi@0 | 956 | |
aoqi@0 | 957 | /** |
aoqi@0 | 958 | * Create a TypeCode for an interface. |
aoqi@0 | 959 | * |
aoqi@0 | 960 | * @param id the logical id for the typecode. |
aoqi@0 | 961 | * @param name the name for the typecode. |
aoqi@0 | 962 | * @return the requested TypeCode. |
aoqi@0 | 963 | */ |
aoqi@0 | 964 | public synchronized TypeCode create_interface_tc(String id, |
aoqi@0 | 965 | String name) |
aoqi@0 | 966 | { |
aoqi@0 | 967 | checkShutdownState(); |
aoqi@0 | 968 | return new TypeCodeImpl(this, TCKind._tk_objref, id, name); |
aoqi@0 | 969 | } |
aoqi@0 | 970 | |
aoqi@0 | 971 | /** |
aoqi@0 | 972 | * Create a TypeCode for a string. |
aoqi@0 | 973 | * |
aoqi@0 | 974 | * @param bound the bound for the string. |
aoqi@0 | 975 | * @return the requested TypeCode. |
aoqi@0 | 976 | */ |
aoqi@0 | 977 | public synchronized TypeCode create_string_tc(int bound) |
aoqi@0 | 978 | { |
aoqi@0 | 979 | checkShutdownState(); |
aoqi@0 | 980 | return new TypeCodeImpl(this, TCKind._tk_string, bound); |
aoqi@0 | 981 | } |
aoqi@0 | 982 | |
aoqi@0 | 983 | /** |
aoqi@0 | 984 | * Create a TypeCode for a wide string. |
aoqi@0 | 985 | * |
aoqi@0 | 986 | * @param bound the bound for the string. |
aoqi@0 | 987 | * @return the requested TypeCode. |
aoqi@0 | 988 | */ |
aoqi@0 | 989 | public synchronized TypeCode create_wstring_tc(int bound) |
aoqi@0 | 990 | { |
aoqi@0 | 991 | checkShutdownState(); |
aoqi@0 | 992 | return new TypeCodeImpl(this, TCKind._tk_wstring, bound); |
aoqi@0 | 993 | } |
aoqi@0 | 994 | |
aoqi@0 | 995 | /** |
aoqi@0 | 996 | * Create a TypeCode for a sequence. |
aoqi@0 | 997 | * |
aoqi@0 | 998 | * @param bound the bound for the sequence. |
aoqi@0 | 999 | * @param element_type |
aoqi@0 | 1000 | * the type of elements of the sequence. |
aoqi@0 | 1001 | * @return the requested TypeCode. |
aoqi@0 | 1002 | */ |
aoqi@0 | 1003 | public synchronized TypeCode create_sequence_tc(int bound, |
aoqi@0 | 1004 | TypeCode element_type) |
aoqi@0 | 1005 | { |
aoqi@0 | 1006 | checkShutdownState(); |
aoqi@0 | 1007 | return new TypeCodeImpl(this, TCKind._tk_sequence, bound, element_type); |
aoqi@0 | 1008 | } |
aoqi@0 | 1009 | |
aoqi@0 | 1010 | |
aoqi@0 | 1011 | /** |
aoqi@0 | 1012 | * Create a recursive TypeCode in a sequence. |
aoqi@0 | 1013 | * |
aoqi@0 | 1014 | * @param bound the bound for the sequence. |
aoqi@0 | 1015 | * @param offset the index to the enclosing TypeCode that is |
aoqi@0 | 1016 | * being referenced. |
aoqi@0 | 1017 | * @return the requested TypeCode. |
aoqi@0 | 1018 | */ |
aoqi@0 | 1019 | public synchronized TypeCode create_recursive_sequence_tc(int bound, |
aoqi@0 | 1020 | int offset) |
aoqi@0 | 1021 | { |
aoqi@0 | 1022 | checkShutdownState(); |
aoqi@0 | 1023 | return new TypeCodeImpl(this, TCKind._tk_sequence, bound, offset); |
aoqi@0 | 1024 | } |
aoqi@0 | 1025 | |
aoqi@0 | 1026 | |
aoqi@0 | 1027 | /** |
aoqi@0 | 1028 | * Create a TypeCode for an array. |
aoqi@0 | 1029 | * |
aoqi@0 | 1030 | * @param length the length of the array. |
aoqi@0 | 1031 | * @param element_type |
aoqi@0 | 1032 | * the type of elements of the array. |
aoqi@0 | 1033 | * @return the requested TypeCode. |
aoqi@0 | 1034 | */ |
aoqi@0 | 1035 | public synchronized TypeCode create_array_tc(int length, |
aoqi@0 | 1036 | TypeCode element_type) |
aoqi@0 | 1037 | { |
aoqi@0 | 1038 | checkShutdownState(); |
aoqi@0 | 1039 | return new TypeCodeImpl(this, TCKind._tk_array, length, element_type); |
aoqi@0 | 1040 | } |
aoqi@0 | 1041 | |
aoqi@0 | 1042 | |
aoqi@0 | 1043 | public synchronized org.omg.CORBA.TypeCode create_native_tc(String id, |
aoqi@0 | 1044 | String name) |
aoqi@0 | 1045 | { |
aoqi@0 | 1046 | checkShutdownState(); |
aoqi@0 | 1047 | return new TypeCodeImpl(this, TCKind._tk_native, id, name); |
aoqi@0 | 1048 | } |
aoqi@0 | 1049 | |
aoqi@0 | 1050 | public synchronized org.omg.CORBA.TypeCode create_abstract_interface_tc( |
aoqi@0 | 1051 | String id, |
aoqi@0 | 1052 | String name) |
aoqi@0 | 1053 | { |
aoqi@0 | 1054 | checkShutdownState(); |
aoqi@0 | 1055 | return new TypeCodeImpl(this, TCKind._tk_abstract_interface, id, name); |
aoqi@0 | 1056 | } |
aoqi@0 | 1057 | |
aoqi@0 | 1058 | public synchronized org.omg.CORBA.TypeCode create_fixed_tc(short digits, short scale) |
aoqi@0 | 1059 | { |
aoqi@0 | 1060 | checkShutdownState(); |
aoqi@0 | 1061 | return new TypeCodeImpl(this, TCKind._tk_fixed, digits, scale); |
aoqi@0 | 1062 | } |
aoqi@0 | 1063 | |
aoqi@0 | 1064 | public synchronized org.omg.CORBA.TypeCode create_value_tc(String id, |
aoqi@0 | 1065 | String name, |
aoqi@0 | 1066 | short type_modifier, |
aoqi@0 | 1067 | TypeCode concrete_base, |
aoqi@0 | 1068 | ValueMember[] members) |
aoqi@0 | 1069 | { |
aoqi@0 | 1070 | checkShutdownState(); |
aoqi@0 | 1071 | return new TypeCodeImpl(this, TCKind._tk_value, id, name, |
aoqi@0 | 1072 | type_modifier, concrete_base, members); |
aoqi@0 | 1073 | } |
aoqi@0 | 1074 | |
aoqi@0 | 1075 | public synchronized org.omg.CORBA.TypeCode create_recursive_tc(String id) { |
aoqi@0 | 1076 | checkShutdownState(); |
aoqi@0 | 1077 | return new TypeCodeImpl(this, id); |
aoqi@0 | 1078 | } |
aoqi@0 | 1079 | |
aoqi@0 | 1080 | public synchronized org.omg.CORBA.TypeCode create_value_box_tc(String id, |
aoqi@0 | 1081 | String name, |
aoqi@0 | 1082 | TypeCode boxed_type) |
aoqi@0 | 1083 | { |
aoqi@0 | 1084 | checkShutdownState(); |
aoqi@0 | 1085 | return new TypeCodeImpl(this, TCKind._tk_value_box, id, name, |
aoqi@0 | 1086 | boxed_type); |
aoqi@0 | 1087 | } |
aoqi@0 | 1088 | |
aoqi@0 | 1089 | /** |
aoqi@0 | 1090 | * Create a new Any |
aoqi@0 | 1091 | * |
aoqi@0 | 1092 | * @return the new Any created. |
aoqi@0 | 1093 | */ |
aoqi@0 | 1094 | public synchronized Any create_any() |
aoqi@0 | 1095 | { |
aoqi@0 | 1096 | checkShutdownState(); |
aoqi@0 | 1097 | return new AnyImpl(this); |
aoqi@0 | 1098 | } |
aoqi@0 | 1099 | |
aoqi@0 | 1100 | // TypeCodeFactory interface methods. |
aoqi@0 | 1101 | // Keeping track of type codes by repository id. |
aoqi@0 | 1102 | |
aoqi@0 | 1103 | // Keeping a cache of TypeCodes associated with the class |
aoqi@0 | 1104 | // they got created from in Util.writeAny(). |
aoqi@0 | 1105 | |
aoqi@0 | 1106 | public synchronized void setTypeCodeForClass(Class c, TypeCodeImpl tci) |
aoqi@0 | 1107 | { |
aoqi@0 | 1108 | checkShutdownState(); |
aoqi@0 | 1109 | |
aoqi@0 | 1110 | if (typeCodeForClassMap == null) |
aoqi@0 | 1111 | typeCodeForClassMap = Collections.synchronizedMap( |
aoqi@0 | 1112 | new WeakHashMap(64)); |
aoqi@0 | 1113 | // Store only one TypeCode per class. |
aoqi@0 | 1114 | if ( ! typeCodeForClassMap.containsKey(c)) |
aoqi@0 | 1115 | typeCodeForClassMap.put(c, tci); |
aoqi@0 | 1116 | } |
aoqi@0 | 1117 | |
aoqi@0 | 1118 | public synchronized TypeCodeImpl getTypeCodeForClass(Class c) |
aoqi@0 | 1119 | { |
aoqi@0 | 1120 | checkShutdownState(); |
aoqi@0 | 1121 | |
aoqi@0 | 1122 | if (typeCodeForClassMap == null) |
aoqi@0 | 1123 | return null; |
aoqi@0 | 1124 | return (TypeCodeImpl)typeCodeForClassMap.get(c); |
aoqi@0 | 1125 | } |
aoqi@0 | 1126 | |
aoqi@0 | 1127 | /**************************************************************************** |
aoqi@0 | 1128 | * The following methods deal with listing and resolving the initial |
aoqi@0 | 1129 | * (bootstrap) object references such as "NameService". |
aoqi@0 | 1130 | ****************************************************************************/ |
aoqi@0 | 1131 | |
aoqi@0 | 1132 | /** |
aoqi@0 | 1133 | * Get a list of the initially available CORBA services. |
aoqi@0 | 1134 | * This does not work unless an ORBInitialHost is specified during |
aoqi@0 | 1135 | * initialization (or unless there is an ORB running on the AppletHost) |
aoqi@0 | 1136 | * since the localhostname |
aoqi@0 | 1137 | * is inaccessible to applets. If a service properties URL was specified, |
aoqi@0 | 1138 | * then it is used, otherwise the bootstrapping protocol is used. |
aoqi@0 | 1139 | * @return A list of the initial services available. |
aoqi@0 | 1140 | */ |
aoqi@0 | 1141 | public String[] list_initial_services() |
aoqi@0 | 1142 | { |
aoqi@0 | 1143 | Resolver res ; |
aoqi@0 | 1144 | |
aoqi@0 | 1145 | synchronized( this ) { |
aoqi@0 | 1146 | checkShutdownState(); |
aoqi@0 | 1147 | res = resolver ; |
aoqi@0 | 1148 | } |
aoqi@0 | 1149 | |
aoqi@0 | 1150 | synchronized (resolverLock) { |
aoqi@0 | 1151 | java.util.Set keys = res.list() ; |
aoqi@0 | 1152 | return (String[])keys.toArray( new String[keys.size()] ) ; |
aoqi@0 | 1153 | } |
aoqi@0 | 1154 | } |
aoqi@0 | 1155 | |
aoqi@0 | 1156 | /** |
aoqi@0 | 1157 | * Resolve the stringified reference of one of the initially |
aoqi@0 | 1158 | * available CORBA services. |
aoqi@0 | 1159 | * @param identifier The stringified object reference of the |
aoqi@0 | 1160 | * desired service. |
aoqi@0 | 1161 | * @return An object reference for the desired service. |
aoqi@0 | 1162 | * @exception InvalidName The supplied identifier is not associated |
aoqi@0 | 1163 | * with a known service. |
aoqi@0 | 1164 | * @exception SystemException One of a fixed set of Corba system exceptions. |
aoqi@0 | 1165 | */ |
aoqi@0 | 1166 | public org.omg.CORBA.Object resolve_initial_references( |
aoqi@0 | 1167 | String identifier) throws InvalidName |
aoqi@0 | 1168 | { |
aoqi@0 | 1169 | Resolver res ; |
aoqi@0 | 1170 | |
aoqi@0 | 1171 | synchronized( this ) { |
aoqi@0 | 1172 | checkShutdownState(); |
aoqi@0 | 1173 | res = resolver ; |
aoqi@0 | 1174 | } |
aoqi@0 | 1175 | |
aoqi@0 | 1176 | synchronized (resolverLock) { |
aoqi@0 | 1177 | org.omg.CORBA.Object result = res.resolve( identifier ) ; |
aoqi@0 | 1178 | |
aoqi@0 | 1179 | if (result == null) |
aoqi@0 | 1180 | throw new InvalidName() ; |
aoqi@0 | 1181 | else |
aoqi@0 | 1182 | return result ; |
aoqi@0 | 1183 | } |
aoqi@0 | 1184 | } |
aoqi@0 | 1185 | |
aoqi@0 | 1186 | /** |
aoqi@0 | 1187 | * If this operation is called with an id, <code>"Y"</code>, and an |
aoqi@0 | 1188 | * object, <code>YY</code>, then a subsequent call to |
aoqi@0 | 1189 | * <code>ORB.resolve_initial_references( "Y" )</code> will |
aoqi@0 | 1190 | * return object <code>YY</code>. |
aoqi@0 | 1191 | * |
aoqi@0 | 1192 | * @param id The ID by which the initial reference will be known. |
aoqi@0 | 1193 | * @param obj The initial reference itself. |
aoqi@0 | 1194 | * @throws InvalidName if this operation is called with an empty string id |
aoqi@0 | 1195 | * or this operation is called with an id that is already registered, |
aoqi@0 | 1196 | * including the default names defined by OMG. |
aoqi@0 | 1197 | * @throws BAD_PARAM if the obj parameter is null. |
aoqi@0 | 1198 | */ |
aoqi@0 | 1199 | public void register_initial_reference( |
aoqi@0 | 1200 | String id, org.omg.CORBA.Object obj ) throws InvalidName |
aoqi@0 | 1201 | { |
aoqi@0 | 1202 | CorbaServerRequestDispatcher insnd ; |
aoqi@0 | 1203 | |
aoqi@0 | 1204 | synchronized (this) { |
aoqi@0 | 1205 | checkShutdownState(); |
aoqi@0 | 1206 | } |
aoqi@0 | 1207 | |
aoqi@0 | 1208 | if ((id == null) || (id.length() == 0)) |
aoqi@0 | 1209 | throw new InvalidName() ; |
aoqi@0 | 1210 | |
aoqi@0 | 1211 | synchronized (this) { |
aoqi@0 | 1212 | checkShutdownState(); |
aoqi@0 | 1213 | } |
aoqi@0 | 1214 | |
aoqi@0 | 1215 | synchronized (resolverLock) { |
aoqi@0 | 1216 | insnd = insNamingDelegate ; |
aoqi@0 | 1217 | |
aoqi@0 | 1218 | java.lang.Object obj2 = localResolver.resolve( id ) ; |
aoqi@0 | 1219 | if (obj2 != null) |
aoqi@0 | 1220 | throw new InvalidName(id + " already registered") ; |
aoqi@0 | 1221 | |
aoqi@0 | 1222 | localResolver.register( id, ClosureFactory.makeConstant( obj )) ; |
aoqi@0 | 1223 | } |
aoqi@0 | 1224 | |
aoqi@0 | 1225 | synchronized (this) { |
aoqi@0 | 1226 | if (StubAdapter.isStub(obj)) |
aoqi@0 | 1227 | // Make all remote object references available for INS. |
aoqi@0 | 1228 | requestDispatcherRegistry.registerServerRequestDispatcher( |
aoqi@0 | 1229 | insnd, id ) ; |
aoqi@0 | 1230 | } |
aoqi@0 | 1231 | } |
aoqi@0 | 1232 | |
aoqi@0 | 1233 | /**************************************************************************** |
aoqi@0 | 1234 | * The following methods (introduced in POA / CORBA2.1) deal with |
aoqi@0 | 1235 | * shutdown / single threading. |
aoqi@0 | 1236 | ****************************************************************************/ |
aoqi@0 | 1237 | |
aoqi@0 | 1238 | public void run() |
aoqi@0 | 1239 | { |
aoqi@0 | 1240 | synchronized (this) { |
aoqi@0 | 1241 | checkShutdownState(); |
aoqi@0 | 1242 | } |
aoqi@0 | 1243 | |
aoqi@0 | 1244 | synchronized (runObj) { |
aoqi@0 | 1245 | try { |
aoqi@0 | 1246 | runObj.wait(); |
aoqi@0 | 1247 | } catch ( InterruptedException ex ) {} |
aoqi@0 | 1248 | } |
aoqi@0 | 1249 | } |
aoqi@0 | 1250 | |
aoqi@0 | 1251 | public void shutdown(boolean wait_for_completion) { |
aoqi@0 | 1252 | boolean wait = false; |
aoqi@0 | 1253 | |
aoqi@0 | 1254 | synchronized (this) { |
aoqi@0 | 1255 | checkShutdownState(); |
aoqi@0 | 1256 | |
aoqi@0 | 1257 | // This is to avoid deadlock: don't allow a thread that is |
aoqi@0 | 1258 | // processing a request to call shutdown( true ), because |
aoqi@0 | 1259 | // the shutdown would block waiting for the request to complete, |
aoqi@0 | 1260 | // while the request would block waiting for shutdown to complete. |
aoqi@0 | 1261 | if (wait_for_completion && |
aoqi@0 | 1262 | isProcessingInvocation.get() == Boolean.TRUE) { |
aoqi@0 | 1263 | throw omgWrapper.shutdownWaitForCompletionDeadlock(); |
aoqi@0 | 1264 | } |
aoqi@0 | 1265 | |
aoqi@0 | 1266 | if (status == STATUS_SHUTTING_DOWN) { |
aoqi@0 | 1267 | if (wait_for_completion) { |
aoqi@0 | 1268 | wait = true; |
aoqi@0 | 1269 | } else { |
aoqi@0 | 1270 | return; |
aoqi@0 | 1271 | } |
aoqi@0 | 1272 | } |
aoqi@0 | 1273 | |
aoqi@0 | 1274 | status = STATUS_SHUTTING_DOWN; |
aoqi@0 | 1275 | } |
aoqi@0 | 1276 | |
aoqi@0 | 1277 | // Avoid more than one thread performing shutdown at a time. |
aoqi@0 | 1278 | synchronized (shutdownObj) { |
aoqi@0 | 1279 | // At this point, the ORB status is certainly STATUS_SHUTTING_DOWN. |
aoqi@0 | 1280 | // If wait is true, another thread already called shutdown( true ), |
aoqi@0 | 1281 | // and so we wait for completion |
aoqi@0 | 1282 | if (wait) { |
aoqi@0 | 1283 | while (true) { |
aoqi@0 | 1284 | synchronized (this) { |
aoqi@0 | 1285 | if (status == STATUS_SHUTDOWN) |
aoqi@0 | 1286 | break; |
aoqi@0 | 1287 | } |
aoqi@0 | 1288 | |
aoqi@0 | 1289 | try { |
aoqi@0 | 1290 | shutdownObj.wait(); |
aoqi@0 | 1291 | } catch (InterruptedException exc) { |
aoqi@0 | 1292 | // NOP: just loop and wait until state is changed |
aoqi@0 | 1293 | } |
aoqi@0 | 1294 | } |
aoqi@0 | 1295 | } else { |
aoqi@0 | 1296 | // perform the actual shutdown |
aoqi@0 | 1297 | shutdownServants(wait_for_completion); |
aoqi@0 | 1298 | |
aoqi@0 | 1299 | if (wait_for_completion) { |
aoqi@0 | 1300 | synchronized ( waitForCompletionObj ) { |
aoqi@0 | 1301 | while (numInvocations > 0) { |
aoqi@0 | 1302 | try { |
aoqi@0 | 1303 | waitForCompletionObj.wait(); |
aoqi@0 | 1304 | } catch (InterruptedException ex) {} |
aoqi@0 | 1305 | } |
aoqi@0 | 1306 | } |
aoqi@0 | 1307 | } |
aoqi@0 | 1308 | |
aoqi@0 | 1309 | synchronized (runObj) { |
aoqi@0 | 1310 | runObj.notifyAll(); |
aoqi@0 | 1311 | } |
aoqi@0 | 1312 | |
aoqi@0 | 1313 | status = STATUS_SHUTDOWN; |
aoqi@0 | 1314 | |
aoqi@0 | 1315 | shutdownObj.notifyAll(); |
aoqi@0 | 1316 | } |
aoqi@0 | 1317 | } |
aoqi@0 | 1318 | } |
aoqi@0 | 1319 | |
aoqi@0 | 1320 | // Cause all ObjectAdapaterFactories to clean up all of their internal state, which |
aoqi@0 | 1321 | // may include activated objects that have associated state and callbacks that must |
aoqi@0 | 1322 | // complete in order to shutdown. This will cause new request to be rejected. |
aoqi@0 | 1323 | protected void shutdownServants(boolean wait_for_completion) { |
aoqi@0 | 1324 | Set<ObjectAdapterFactory> oaset; |
aoqi@0 | 1325 | synchronized (this) { |
aoqi@0 | 1326 | oaset = new HashSet<>(requestDispatcherRegistry.getObjectAdapterFactories()); |
aoqi@0 | 1327 | } |
aoqi@0 | 1328 | |
aoqi@0 | 1329 | for (ObjectAdapterFactory oaf : oaset) |
aoqi@0 | 1330 | oaf.shutdown(wait_for_completion); |
aoqi@0 | 1331 | } |
aoqi@0 | 1332 | |
aoqi@0 | 1333 | // Note that the caller must hold the ORBImpl lock. |
aoqi@0 | 1334 | public void checkShutdownState() |
aoqi@0 | 1335 | { |
aoqi@0 | 1336 | if (status == STATUS_DESTROYED) { |
aoqi@0 | 1337 | throw wrapper.orbDestroyed() ; |
aoqi@0 | 1338 | } |
aoqi@0 | 1339 | |
aoqi@0 | 1340 | if (status == STATUS_SHUTDOWN) { |
aoqi@0 | 1341 | throw omgWrapper.badOperationAfterShutdown() ; |
aoqi@0 | 1342 | } |
aoqi@0 | 1343 | } |
aoqi@0 | 1344 | |
aoqi@0 | 1345 | public boolean isDuringDispatch() |
aoqi@0 | 1346 | { |
aoqi@0 | 1347 | synchronized (this) { |
aoqi@0 | 1348 | checkShutdownState(); |
aoqi@0 | 1349 | } |
aoqi@0 | 1350 | Boolean value = (Boolean)(isProcessingInvocation.get()) ; |
aoqi@0 | 1351 | return value.booleanValue() ; |
aoqi@0 | 1352 | } |
aoqi@0 | 1353 | |
aoqi@0 | 1354 | public void startingDispatch() |
aoqi@0 | 1355 | { |
aoqi@0 | 1356 | synchronized (this) { |
aoqi@0 | 1357 | checkShutdownState(); |
aoqi@0 | 1358 | } |
aoqi@0 | 1359 | synchronized (invocationObj) { |
aoqi@0 | 1360 | isProcessingInvocation.set(Boolean.TRUE); |
aoqi@0 | 1361 | numInvocations++; |
aoqi@0 | 1362 | } |
aoqi@0 | 1363 | } |
aoqi@0 | 1364 | |
aoqi@0 | 1365 | public void finishedDispatch() |
aoqi@0 | 1366 | { |
aoqi@0 | 1367 | synchronized (this) { |
aoqi@0 | 1368 | checkShutdownState(); |
aoqi@0 | 1369 | } |
aoqi@0 | 1370 | synchronized (invocationObj) { |
aoqi@0 | 1371 | numInvocations--; |
aoqi@0 | 1372 | isProcessingInvocation.set(false); |
aoqi@0 | 1373 | if (numInvocations == 0) { |
aoqi@0 | 1374 | synchronized (waitForCompletionObj) { |
aoqi@0 | 1375 | waitForCompletionObj.notifyAll(); |
aoqi@0 | 1376 | } |
aoqi@0 | 1377 | } else if (numInvocations < 0) { |
aoqi@0 | 1378 | throw wrapper.numInvocationsAlreadyZero( |
aoqi@0 | 1379 | CompletionStatus.COMPLETED_YES); |
aoqi@0 | 1380 | } |
aoqi@0 | 1381 | } |
aoqi@0 | 1382 | } |
aoqi@0 | 1383 | |
aoqi@0 | 1384 | /** |
aoqi@0 | 1385 | * formal/99-10-07 p 159: "If destroy is called on an ORB that has |
aoqi@0 | 1386 | * not been shut down, it will start the shutdown process and block until |
aoqi@0 | 1387 | * the ORB has shut down before it destroys the ORB." |
aoqi@0 | 1388 | */ |
aoqi@0 | 1389 | public void destroy() |
aoqi@0 | 1390 | { |
aoqi@0 | 1391 | boolean shutdownFirst = false; |
aoqi@0 | 1392 | |
aoqi@0 | 1393 | synchronized (this) { |
aoqi@0 | 1394 | shutdownFirst = (status == STATUS_OPERATING); |
aoqi@0 | 1395 | } |
aoqi@0 | 1396 | |
aoqi@0 | 1397 | if (shutdownFirst) { |
aoqi@0 | 1398 | shutdown(true); |
aoqi@0 | 1399 | } |
aoqi@0 | 1400 | |
aoqi@0 | 1401 | synchronized (this) { |
aoqi@0 | 1402 | if (status < STATUS_DESTROYED) { |
aoqi@0 | 1403 | getCorbaTransportManager().close(); |
aoqi@0 | 1404 | getPIHandler().destroyInterceptors(); |
aoqi@0 | 1405 | status = STATUS_DESTROYED; |
aoqi@0 | 1406 | } |
aoqi@0 | 1407 | } |
aoqi@0 | 1408 | synchronized (threadPoolManagerAccessLock) { |
aoqi@0 | 1409 | if (orbOwnsThreadPoolManager) { |
aoqi@0 | 1410 | try { |
aoqi@0 | 1411 | threadpoolMgr.close(); |
aoqi@0 | 1412 | threadpoolMgr = null; |
aoqi@0 | 1413 | } catch (IOException exc) { |
aoqi@0 | 1414 | wrapper.ioExceptionOnClose(exc); |
aoqi@0 | 1415 | } |
aoqi@0 | 1416 | } |
aoqi@0 | 1417 | } |
aoqi@0 | 1418 | |
aoqi@0 | 1419 | try { |
aoqi@0 | 1420 | monitoringManager.close(); |
aoqi@0 | 1421 | monitoringManager = null; |
aoqi@0 | 1422 | } catch (IOException exc) { |
aoqi@0 | 1423 | wrapper.ioExceptionOnClose(exc); |
aoqi@0 | 1424 | } |
aoqi@0 | 1425 | |
aoqi@0 | 1426 | CachedCodeBase.cleanCache(this); |
aoqi@0 | 1427 | try { |
aoqi@0 | 1428 | pihandler.close(); |
aoqi@0 | 1429 | } catch (IOException exc) { |
aoqi@0 | 1430 | wrapper.ioExceptionOnClose(exc); |
aoqi@0 | 1431 | } |
aoqi@0 | 1432 | |
aoqi@0 | 1433 | super.destroy(); |
aoqi@0 | 1434 | |
aoqi@0 | 1435 | badServerIdHandlerAccessLock = null; |
aoqi@0 | 1436 | clientDelegateFactoryAccessorLock = null; |
aoqi@0 | 1437 | corbaContactInfoListFactoryAccessLock = null; |
aoqi@0 | 1438 | |
aoqi@0 | 1439 | objectKeyFactoryAccessLock = null; |
aoqi@0 | 1440 | legacyServerSocketManagerAccessLock = null; |
aoqi@0 | 1441 | threadPoolManagerAccessLock = null; |
aoqi@0 | 1442 | transportManager = null; |
aoqi@0 | 1443 | legacyServerSocketManager = null; |
aoqi@0 | 1444 | OAInvocationInfoStack = null; |
aoqi@0 | 1445 | clientInvocationInfoStack = null; |
aoqi@0 | 1446 | codeBaseIOR = null; |
aoqi@0 | 1447 | dynamicRequests = null; |
aoqi@0 | 1448 | svResponseReceived = null; |
aoqi@0 | 1449 | runObj = null; |
aoqi@0 | 1450 | shutdownObj = null; |
aoqi@0 | 1451 | waitForCompletionObj = null; |
aoqi@0 | 1452 | invocationObj = null; |
aoqi@0 | 1453 | isProcessingInvocation = null; |
aoqi@0 | 1454 | typeCodeForClassMap = null; |
aoqi@0 | 1455 | valueFactoryCache = null; |
aoqi@0 | 1456 | orbVersionThreadLocal = null; |
aoqi@0 | 1457 | requestDispatcherRegistry = null; |
aoqi@0 | 1458 | copierManager = null; |
aoqi@0 | 1459 | toaFactory = null; |
aoqi@0 | 1460 | poaFactory = null; |
aoqi@0 | 1461 | pihandler = null; |
aoqi@0 | 1462 | configData = null; |
aoqi@0 | 1463 | badServerIdHandler = null; |
aoqi@0 | 1464 | clientDelegateFactory = null; |
aoqi@0 | 1465 | corbaContactInfoListFactory = null; |
aoqi@0 | 1466 | resolver = null; |
aoqi@0 | 1467 | localResolver = null; |
aoqi@0 | 1468 | insNamingDelegate = null; |
aoqi@0 | 1469 | urlOperation = null; |
aoqi@0 | 1470 | taggedComponentFactoryFinder = null; |
aoqi@0 | 1471 | taggedProfileFactoryFinder = null; |
aoqi@0 | 1472 | taggedProfileTemplateFactoryFinder = null; |
aoqi@0 | 1473 | objectKeyFactory = null; |
aoqi@0 | 1474 | } |
aoqi@0 | 1475 | |
aoqi@0 | 1476 | /** |
aoqi@0 | 1477 | * Registers a value factory for a particular repository ID. |
aoqi@0 | 1478 | * |
aoqi@0 | 1479 | * @param repositoryID the repository ID. |
aoqi@0 | 1480 | * @param factory the factory. |
aoqi@0 | 1481 | * @return the previously registered factory for the given repository ID, |
aoqi@0 | 1482 | * or null if no such factory was previously registered. |
aoqi@0 | 1483 | * @exception org.omg.CORBA.BAD_PARAM if the registration fails. |
aoqi@0 | 1484 | **/ |
aoqi@0 | 1485 | public synchronized ValueFactory register_value_factory(String repositoryID, |
aoqi@0 | 1486 | ValueFactory factory) |
aoqi@0 | 1487 | { |
aoqi@0 | 1488 | checkShutdownState(); |
aoqi@0 | 1489 | |
aoqi@0 | 1490 | if ((repositoryID == null) || (factory == null)) |
aoqi@0 | 1491 | throw omgWrapper.unableRegisterValueFactory() ; |
aoqi@0 | 1492 | |
aoqi@0 | 1493 | return (ValueFactory)valueFactoryCache.put(repositoryID, factory); |
aoqi@0 | 1494 | } |
aoqi@0 | 1495 | |
aoqi@0 | 1496 | /** |
aoqi@0 | 1497 | * Unregisters a value factory for a particular repository ID. |
aoqi@0 | 1498 | * |
aoqi@0 | 1499 | * @param repositoryID the repository ID. |
aoqi@0 | 1500 | **/ |
aoqi@0 | 1501 | public synchronized void unregister_value_factory(String repositoryID) |
aoqi@0 | 1502 | { |
aoqi@0 | 1503 | checkShutdownState(); |
aoqi@0 | 1504 | |
aoqi@0 | 1505 | if (valueFactoryCache.remove(repositoryID) == null) |
aoqi@0 | 1506 | throw wrapper.nullParam() ; |
aoqi@0 | 1507 | } |
aoqi@0 | 1508 | |
aoqi@0 | 1509 | /** |
aoqi@0 | 1510 | * Finds and returns a value factory for the given repository ID. |
aoqi@0 | 1511 | * The value factory returned was previously registered by a call to |
aoqi@0 | 1512 | * {@link #register_value_factory} or is the default factory. |
aoqi@0 | 1513 | * |
aoqi@0 | 1514 | * @param repositoryID the repository ID. |
aoqi@0 | 1515 | * @return the value factory. |
aoqi@0 | 1516 | * @exception org.omg.CORBA.BAD_PARAM if unable to locate a factory. |
aoqi@0 | 1517 | **/ |
aoqi@0 | 1518 | public synchronized ValueFactory lookup_value_factory(String repositoryID) |
aoqi@0 | 1519 | { |
aoqi@0 | 1520 | checkShutdownState(); |
aoqi@0 | 1521 | |
aoqi@0 | 1522 | ValueFactory factory = |
aoqi@0 | 1523 | (ValueFactory)valueFactoryCache.get(repositoryID); |
aoqi@0 | 1524 | |
aoqi@0 | 1525 | if (factory == null) { |
aoqi@0 | 1526 | try { |
aoqi@0 | 1527 | factory = Utility.getFactory(null, null, null, repositoryID); |
aoqi@0 | 1528 | } catch(org.omg.CORBA.MARSHAL ex) { |
aoqi@0 | 1529 | throw wrapper.unableFindValueFactory( ex ) ; |
aoqi@0 | 1530 | } |
aoqi@0 | 1531 | } |
aoqi@0 | 1532 | |
aoqi@0 | 1533 | return factory ; |
aoqi@0 | 1534 | } |
aoqi@0 | 1535 | |
aoqi@0 | 1536 | public OAInvocationInfo peekInvocationInfo() |
aoqi@0 | 1537 | { |
aoqi@0 | 1538 | synchronized (this) { |
aoqi@0 | 1539 | checkShutdownState(); |
aoqi@0 | 1540 | } |
aoqi@0 | 1541 | StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; |
aoqi@0 | 1542 | return (OAInvocationInfo)(stack.peek()) ; |
aoqi@0 | 1543 | } |
aoqi@0 | 1544 | |
aoqi@0 | 1545 | public void pushInvocationInfo( OAInvocationInfo info ) |
aoqi@0 | 1546 | { |
aoqi@0 | 1547 | synchronized (this) { |
aoqi@0 | 1548 | checkShutdownState(); |
aoqi@0 | 1549 | } |
aoqi@0 | 1550 | StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; |
aoqi@0 | 1551 | stack.push( info ) ; |
aoqi@0 | 1552 | } |
aoqi@0 | 1553 | |
aoqi@0 | 1554 | public OAInvocationInfo popInvocationInfo() |
aoqi@0 | 1555 | { |
aoqi@0 | 1556 | synchronized (this) { |
aoqi@0 | 1557 | checkShutdownState(); |
aoqi@0 | 1558 | } |
aoqi@0 | 1559 | StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; |
aoqi@0 | 1560 | return (OAInvocationInfo)(stack.pop()) ; |
aoqi@0 | 1561 | } |
aoqi@0 | 1562 | |
aoqi@0 | 1563 | /** |
aoqi@0 | 1564 | * The bad server id handler is used by the Locator to |
aoqi@0 | 1565 | * send back the location of a persistant server to the client. |
aoqi@0 | 1566 | */ |
aoqi@0 | 1567 | |
aoqi@0 | 1568 | private Object badServerIdHandlerAccessLock = new Object(); |
aoqi@0 | 1569 | |
aoqi@0 | 1570 | public void initBadServerIdHandler() |
aoqi@0 | 1571 | { |
aoqi@0 | 1572 | synchronized (this) { |
aoqi@0 | 1573 | checkShutdownState(); |
aoqi@0 | 1574 | } |
aoqi@0 | 1575 | synchronized (badServerIdHandlerAccessLock) { |
aoqi@0 | 1576 | Class cls = configData.getBadServerIdHandler() ; |
aoqi@0 | 1577 | if (cls != null) { |
aoqi@0 | 1578 | try { |
aoqi@0 | 1579 | Class[] params = new Class[] { org.omg.CORBA.ORB.class }; |
aoqi@0 | 1580 | java.lang.Object[] args = new java.lang.Object[]{this}; |
aoqi@0 | 1581 | Constructor cons = cls.getConstructor(params); |
aoqi@0 | 1582 | badServerIdHandler = |
aoqi@0 | 1583 | (BadServerIdHandler) cons.newInstance(args); |
aoqi@0 | 1584 | } catch (Exception e) { |
aoqi@0 | 1585 | throw wrapper.errorInitBadserveridhandler( e ) ; |
aoqi@0 | 1586 | } |
aoqi@0 | 1587 | } |
aoqi@0 | 1588 | } |
aoqi@0 | 1589 | } |
aoqi@0 | 1590 | |
aoqi@0 | 1591 | public void setBadServerIdHandler( BadServerIdHandler handler ) |
aoqi@0 | 1592 | { |
aoqi@0 | 1593 | synchronized (this) { |
aoqi@0 | 1594 | checkShutdownState(); |
aoqi@0 | 1595 | } |
aoqi@0 | 1596 | synchronized (badServerIdHandlerAccessLock) { |
aoqi@0 | 1597 | badServerIdHandler = handler; |
aoqi@0 | 1598 | } |
aoqi@0 | 1599 | } |
aoqi@0 | 1600 | |
aoqi@0 | 1601 | public void handleBadServerId( ObjectKey okey ) |
aoqi@0 | 1602 | { |
aoqi@0 | 1603 | synchronized (this) { |
aoqi@0 | 1604 | checkShutdownState(); |
aoqi@0 | 1605 | } |
aoqi@0 | 1606 | synchronized (badServerIdHandlerAccessLock) { |
aoqi@0 | 1607 | if (badServerIdHandler == null) |
aoqi@0 | 1608 | throw wrapper.badServerId() ; |
aoqi@0 | 1609 | else |
aoqi@0 | 1610 | badServerIdHandler.handle( okey ) ; |
aoqi@0 | 1611 | } |
aoqi@0 | 1612 | } |
aoqi@0 | 1613 | |
aoqi@0 | 1614 | public synchronized org.omg.CORBA.Policy create_policy( int type, |
aoqi@0 | 1615 | org.omg.CORBA.Any val ) throws org.omg.CORBA.PolicyError |
aoqi@0 | 1616 | { |
aoqi@0 | 1617 | checkShutdownState() ; |
aoqi@0 | 1618 | |
aoqi@0 | 1619 | return pihandler.create_policy( type, val ) ; |
aoqi@0 | 1620 | } |
aoqi@0 | 1621 | |
aoqi@0 | 1622 | /** This is the implementation of the public API used to connect |
aoqi@0 | 1623 | * a servant-skeleton to the ORB. |
aoqi@0 | 1624 | */ |
aoqi@0 | 1625 | public synchronized void connect(org.omg.CORBA.Object servant) |
aoqi@0 | 1626 | { |
aoqi@0 | 1627 | checkShutdownState(); |
aoqi@0 | 1628 | if (getTOAFactory() == null) |
aoqi@0 | 1629 | throw wrapper.noToa() ; |
aoqi@0 | 1630 | |
aoqi@0 | 1631 | try { |
aoqi@0 | 1632 | String codebase = javax.rmi.CORBA.Util.getCodebase( servant.getClass() ) ; |
aoqi@0 | 1633 | getTOAFactory().getTOA( codebase ).connect( servant ) ; |
aoqi@0 | 1634 | } catch ( Exception ex ) { |
aoqi@0 | 1635 | throw wrapper.orbConnectError( ex ) ; |
aoqi@0 | 1636 | } |
aoqi@0 | 1637 | } |
aoqi@0 | 1638 | |
aoqi@0 | 1639 | public synchronized void disconnect(org.omg.CORBA.Object obj) |
aoqi@0 | 1640 | { |
aoqi@0 | 1641 | checkShutdownState(); |
aoqi@0 | 1642 | if (getTOAFactory() == null) |
aoqi@0 | 1643 | throw wrapper.noToa() ; |
aoqi@0 | 1644 | |
aoqi@0 | 1645 | try { |
aoqi@0 | 1646 | getTOAFactory().getTOA().disconnect( obj ) ; |
aoqi@0 | 1647 | } catch ( Exception ex ) { |
aoqi@0 | 1648 | throw wrapper.orbConnectError( ex ) ; |
aoqi@0 | 1649 | } |
aoqi@0 | 1650 | } |
aoqi@0 | 1651 | |
aoqi@0 | 1652 | public int getTransientServerId() |
aoqi@0 | 1653 | { |
aoqi@0 | 1654 | synchronized (this) { |
aoqi@0 | 1655 | checkShutdownState(); |
aoqi@0 | 1656 | } |
aoqi@0 | 1657 | if( configData.getORBServerIdPropertySpecified( ) ) { |
aoqi@0 | 1658 | // ORBServerId is specified then use that value |
aoqi@0 | 1659 | return configData.getPersistentServerId( ); |
aoqi@0 | 1660 | } |
aoqi@0 | 1661 | return transientServerId; |
aoqi@0 | 1662 | } |
aoqi@0 | 1663 | |
aoqi@0 | 1664 | public RequestDispatcherRegistry getRequestDispatcherRegistry() |
aoqi@0 | 1665 | { |
aoqi@0 | 1666 | synchronized (this) { |
aoqi@0 | 1667 | checkShutdownState(); |
aoqi@0 | 1668 | } |
aoqi@0 | 1669 | return requestDispatcherRegistry; |
aoqi@0 | 1670 | } |
aoqi@0 | 1671 | |
aoqi@0 | 1672 | public ServiceContextRegistry getServiceContextRegistry() |
aoqi@0 | 1673 | { |
aoqi@0 | 1674 | synchronized (this) { |
aoqi@0 | 1675 | checkShutdownState(); |
aoqi@0 | 1676 | } |
aoqi@0 | 1677 | return serviceContextRegistry ; |
aoqi@0 | 1678 | } |
aoqi@0 | 1679 | |
aoqi@0 | 1680 | // XXX All of the isLocalXXX checking needs to be revisited. |
aoqi@0 | 1681 | // First of all, all three of these methods are called from |
aoqi@0 | 1682 | // only one place in impl.ior.IORImpl. Second, we have problems |
aoqi@0 | 1683 | // both with multi-homed hosts and with multi-profile IORs. |
aoqi@0 | 1684 | // A possible strategy: like the LocalClientRequestDispatcher, we need |
aoqi@0 | 1685 | // to determine this more abstractly at the ContactInfo level. |
aoqi@0 | 1686 | // This level should probably just get the CorbaContactInfoList from |
aoqi@0 | 1687 | // the IOR, then iterator over ContactInfo. If any ContactInfo is |
aoqi@0 | 1688 | // local, the IOR is local, and we can pick one to create the |
aoqi@0 | 1689 | // LocalClientRequestDispatcher as well. Bottom line: this code needs to move. |
aoqi@0 | 1690 | |
aoqi@0 | 1691 | // XXX What about multi-homed host? |
aoqi@0 | 1692 | public boolean isLocalHost( String hostName ) |
aoqi@0 | 1693 | { |
aoqi@0 | 1694 | synchronized (this) { |
aoqi@0 | 1695 | checkShutdownState(); |
aoqi@0 | 1696 | } |
aoqi@0 | 1697 | return hostName.equals( configData.getORBServerHost() ) || |
aoqi@0 | 1698 | hostName.equals( getLocalHostName() ) ; |
aoqi@0 | 1699 | } |
aoqi@0 | 1700 | |
aoqi@0 | 1701 | public boolean isLocalServerId( int subcontractId, int serverId ) |
aoqi@0 | 1702 | { |
aoqi@0 | 1703 | synchronized (this) { |
aoqi@0 | 1704 | checkShutdownState(); |
aoqi@0 | 1705 | } |
aoqi@0 | 1706 | if ((subcontractId < ORBConstants.FIRST_POA_SCID) || |
aoqi@0 | 1707 | (subcontractId > ORBConstants.MAX_POA_SCID)) |
aoqi@0 | 1708 | return serverId == getTransientServerId( ) ; |
aoqi@0 | 1709 | |
aoqi@0 | 1710 | // XXX isTransient info should be stored in subcontract registry |
aoqi@0 | 1711 | if (ORBConstants.isTransient( subcontractId )) |
aoqi@0 | 1712 | return (serverId == getTransientServerId()) ; |
aoqi@0 | 1713 | else if (configData.getPersistentServerIdInitialized()) |
aoqi@0 | 1714 | return (serverId == configData.getPersistentServerId()) ; |
aoqi@0 | 1715 | else |
aoqi@0 | 1716 | return false ; |
aoqi@0 | 1717 | } |
aoqi@0 | 1718 | |
aoqi@0 | 1719 | /************************************************************************* |
aoqi@0 | 1720 | * The following public methods are for ORB shutdown. |
aoqi@0 | 1721 | *************************************************************************/ |
aoqi@0 | 1722 | |
aoqi@0 | 1723 | private String getHostName(String host) |
aoqi@0 | 1724 | throws java.net.UnknownHostException |
aoqi@0 | 1725 | { |
aoqi@0 | 1726 | return InetAddress.getByName( host ).getHostAddress(); |
aoqi@0 | 1727 | } |
aoqi@0 | 1728 | |
aoqi@0 | 1729 | /* keeping a copy of the getLocalHostName so that it can only be called |
aoqi@0 | 1730 | * internally and the unauthorized clients cannot have access to the |
aoqi@0 | 1731 | * localHost information, originally, the above code was calling |
aoqi@0 | 1732 | * getLocalHostName from Connection.java. If the hostname is cached in |
aoqi@0 | 1733 | * Connection.java, then |
aoqi@0 | 1734 | * it is a security hole, since any unauthorized client has access to |
aoqi@0 | 1735 | * the host information. With this change it is used internally so the |
aoqi@0 | 1736 | * security problem is resolved. Also in Connection.java, the |
aoqi@0 | 1737 | * getLocalHost() implementation has changed to always call the |
aoqi@0 | 1738 | * InetAddress.getLocalHost().getHostAddress() |
aoqi@0 | 1739 | * The above mentioned method has been removed from the connection class |
aoqi@0 | 1740 | */ |
aoqi@0 | 1741 | |
aoqi@0 | 1742 | private static String localHostString = null; |
aoqi@0 | 1743 | |
aoqi@0 | 1744 | private synchronized String getLocalHostName() |
aoqi@0 | 1745 | { |
aoqi@0 | 1746 | if (localHostString == null) { |
aoqi@0 | 1747 | try { |
aoqi@0 | 1748 | localHostString = InetAddress.getLocalHost().getHostAddress(); |
aoqi@0 | 1749 | } catch (Exception ex) { |
aoqi@0 | 1750 | throw wrapper.getLocalHostFailed( ex ) ; |
aoqi@0 | 1751 | } |
aoqi@0 | 1752 | } |
aoqi@0 | 1753 | return localHostString ; |
aoqi@0 | 1754 | } |
aoqi@0 | 1755 | |
aoqi@0 | 1756 | /****************************************************************************** |
aoqi@0 | 1757 | * The following public methods are for ORB shutdown. |
aoqi@0 | 1758 | * |
aoqi@0 | 1759 | ******************************************************************************/ |
aoqi@0 | 1760 | |
aoqi@0 | 1761 | /** This method always returns false because the ORB never needs the |
aoqi@0 | 1762 | * main thread to do work. |
aoqi@0 | 1763 | */ |
aoqi@0 | 1764 | public synchronized boolean work_pending() |
aoqi@0 | 1765 | { |
aoqi@0 | 1766 | checkShutdownState(); |
aoqi@0 | 1767 | throw wrapper.genericNoImpl() ; |
aoqi@0 | 1768 | } |
aoqi@0 | 1769 | |
aoqi@0 | 1770 | /** This method does nothing. It is not required by the spec to do anything! |
aoqi@0 | 1771 | */ |
aoqi@0 | 1772 | public synchronized void perform_work() |
aoqi@0 | 1773 | { |
aoqi@0 | 1774 | checkShutdownState(); |
aoqi@0 | 1775 | throw wrapper.genericNoImpl() ; |
aoqi@0 | 1776 | } |
aoqi@0 | 1777 | |
aoqi@0 | 1778 | public synchronized void set_delegate(java.lang.Object servant){ |
aoqi@0 | 1779 | checkShutdownState(); |
aoqi@0 | 1780 | |
aoqi@0 | 1781 | POAFactory poaFactory = getPOAFactory() ; |
aoqi@0 | 1782 | if (poaFactory != null) |
aoqi@0 | 1783 | ((org.omg.PortableServer.Servant)servant) |
aoqi@0 | 1784 | ._set_delegate( poaFactory.getDelegateImpl() ) ; |
aoqi@0 | 1785 | else |
aoqi@0 | 1786 | throw wrapper.noPoa() ; |
aoqi@0 | 1787 | } |
aoqi@0 | 1788 | |
aoqi@0 | 1789 | //////////////////////////////////////////////////// |
aoqi@0 | 1790 | // |
aoqi@0 | 1791 | // pept.broker.Broker |
aoqi@0 | 1792 | // |
aoqi@0 | 1793 | |
aoqi@0 | 1794 | public ClientInvocationInfo createOrIncrementInvocationInfo() |
aoqi@0 | 1795 | { |
aoqi@0 | 1796 | synchronized (this) { |
aoqi@0 | 1797 | checkShutdownState(); |
aoqi@0 | 1798 | } |
aoqi@0 | 1799 | StackImpl invocationInfoStack = |
aoqi@0 | 1800 | (StackImpl) clientInvocationInfoStack.get(); |
aoqi@0 | 1801 | ClientInvocationInfo clientInvocationInfo = null; |
aoqi@0 | 1802 | if (!invocationInfoStack.empty()) { |
aoqi@0 | 1803 | clientInvocationInfo = |
aoqi@0 | 1804 | (ClientInvocationInfo) invocationInfoStack.peek(); |
aoqi@0 | 1805 | } |
aoqi@0 | 1806 | if ((clientInvocationInfo == null) || |
aoqi@0 | 1807 | (!clientInvocationInfo.isRetryInvocation())) |
aoqi@0 | 1808 | { |
aoqi@0 | 1809 | // This is a new call - not a retry. |
aoqi@0 | 1810 | clientInvocationInfo = new CorbaInvocationInfo(this); |
aoqi@0 | 1811 | startingDispatch(); |
aoqi@0 | 1812 | invocationInfoStack.push(clientInvocationInfo); |
aoqi@0 | 1813 | } |
aoqi@0 | 1814 | // Reset retry so recursive calls will get a new info object. |
aoqi@0 | 1815 | clientInvocationInfo.setIsRetryInvocation(false); |
aoqi@0 | 1816 | clientInvocationInfo.incrementEntryCount(); |
aoqi@0 | 1817 | return clientInvocationInfo; |
aoqi@0 | 1818 | } |
aoqi@0 | 1819 | |
aoqi@0 | 1820 | public void releaseOrDecrementInvocationInfo() |
aoqi@0 | 1821 | { |
aoqi@0 | 1822 | synchronized (this) { |
aoqi@0 | 1823 | checkShutdownState(); |
aoqi@0 | 1824 | } |
aoqi@0 | 1825 | int entryCount = -1; |
aoqi@0 | 1826 | ClientInvocationInfo clientInvocationInfo = null; |
aoqi@0 | 1827 | StackImpl invocationInfoStack = |
aoqi@0 | 1828 | (StackImpl)clientInvocationInfoStack.get(); |
aoqi@0 | 1829 | if (!invocationInfoStack.empty()) { |
aoqi@0 | 1830 | clientInvocationInfo = |
aoqi@0 | 1831 | (ClientInvocationInfo)invocationInfoStack.peek(); |
aoqi@0 | 1832 | } else { |
aoqi@0 | 1833 | throw wrapper.invocationInfoStackEmpty() ; |
aoqi@0 | 1834 | } |
aoqi@0 | 1835 | clientInvocationInfo.decrementEntryCount(); |
aoqi@0 | 1836 | entryCount = clientInvocationInfo.getEntryCount(); |
aoqi@0 | 1837 | if (clientInvocationInfo.getEntryCount() == 0) { |
aoqi@0 | 1838 | // 6763340: don't pop if this is a retry! |
aoqi@0 | 1839 | if (!clientInvocationInfo.isRetryInvocation()) { |
aoqi@0 | 1840 | invocationInfoStack.pop(); |
aoqi@0 | 1841 | } |
aoqi@0 | 1842 | finishedDispatch(); |
aoqi@0 | 1843 | } |
aoqi@0 | 1844 | } |
aoqi@0 | 1845 | |
aoqi@0 | 1846 | public ClientInvocationInfo getInvocationInfo() |
aoqi@0 | 1847 | { |
aoqi@0 | 1848 | synchronized (this) { |
aoqi@0 | 1849 | checkShutdownState(); |
aoqi@0 | 1850 | } |
aoqi@0 | 1851 | StackImpl invocationInfoStack = |
aoqi@0 | 1852 | (StackImpl) clientInvocationInfoStack.get(); |
aoqi@0 | 1853 | return (ClientInvocationInfo) invocationInfoStack.peek(); |
aoqi@0 | 1854 | } |
aoqi@0 | 1855 | |
aoqi@0 | 1856 | //////////////////////////////////////////////////// |
aoqi@0 | 1857 | // |
aoqi@0 | 1858 | // |
aoqi@0 | 1859 | // |
aoqi@0 | 1860 | |
aoqi@0 | 1861 | private Object clientDelegateFactoryAccessorLock = new Object(); |
aoqi@0 | 1862 | |
aoqi@0 | 1863 | public void setClientDelegateFactory( ClientDelegateFactory factory ) |
aoqi@0 | 1864 | { |
aoqi@0 | 1865 | synchronized (this) { |
aoqi@0 | 1866 | checkShutdownState(); |
aoqi@0 | 1867 | } |
aoqi@0 | 1868 | synchronized (clientDelegateFactoryAccessorLock) { |
aoqi@0 | 1869 | clientDelegateFactory = factory ; |
aoqi@0 | 1870 | } |
aoqi@0 | 1871 | } |
aoqi@0 | 1872 | |
aoqi@0 | 1873 | public ClientDelegateFactory getClientDelegateFactory() |
aoqi@0 | 1874 | { |
aoqi@0 | 1875 | synchronized (this) { |
aoqi@0 | 1876 | checkShutdownState(); |
aoqi@0 | 1877 | } |
aoqi@0 | 1878 | synchronized (clientDelegateFactoryAccessorLock) { |
aoqi@0 | 1879 | return clientDelegateFactory ; |
aoqi@0 | 1880 | } |
aoqi@0 | 1881 | } |
aoqi@0 | 1882 | |
aoqi@0 | 1883 | private Object corbaContactInfoListFactoryAccessLock = new Object(); |
aoqi@0 | 1884 | |
aoqi@0 | 1885 | public void setCorbaContactInfoListFactory( CorbaContactInfoListFactory factory ) |
aoqi@0 | 1886 | { |
aoqi@0 | 1887 | synchronized (this) { |
aoqi@0 | 1888 | checkShutdownState(); |
aoqi@0 | 1889 | } |
aoqi@0 | 1890 | synchronized (corbaContactInfoListFactoryAccessLock) { |
aoqi@0 | 1891 | corbaContactInfoListFactory = factory ; |
aoqi@0 | 1892 | } |
aoqi@0 | 1893 | } |
aoqi@0 | 1894 | |
aoqi@0 | 1895 | public synchronized CorbaContactInfoListFactory getCorbaContactInfoListFactory() |
aoqi@0 | 1896 | { |
aoqi@0 | 1897 | checkShutdownState(); |
aoqi@0 | 1898 | return corbaContactInfoListFactory ; |
aoqi@0 | 1899 | } |
aoqi@0 | 1900 | |
aoqi@0 | 1901 | /** Set the resolver used in this ORB. This resolver will be used for list_initial_services |
aoqi@0 | 1902 | * and resolve_initial_references. |
aoqi@0 | 1903 | */ |
aoqi@0 | 1904 | public void setResolver( Resolver resolver ) |
aoqi@0 | 1905 | { |
aoqi@0 | 1906 | synchronized (this) { |
aoqi@0 | 1907 | checkShutdownState(); |
aoqi@0 | 1908 | } |
aoqi@0 | 1909 | synchronized (resolverLock) { |
aoqi@0 | 1910 | this.resolver = resolver ; |
aoqi@0 | 1911 | } |
aoqi@0 | 1912 | } |
aoqi@0 | 1913 | |
aoqi@0 | 1914 | /** Get the resolver used in this ORB. This resolver will be used for list_initial_services |
aoqi@0 | 1915 | * and resolve_initial_references. |
aoqi@0 | 1916 | */ |
aoqi@0 | 1917 | public Resolver getResolver() |
aoqi@0 | 1918 | { |
aoqi@0 | 1919 | synchronized (this) { |
aoqi@0 | 1920 | checkShutdownState(); |
aoqi@0 | 1921 | } |
aoqi@0 | 1922 | synchronized (resolverLock) { |
aoqi@0 | 1923 | return resolver ; |
aoqi@0 | 1924 | } |
aoqi@0 | 1925 | } |
aoqi@0 | 1926 | |
aoqi@0 | 1927 | /** Set the LocalResolver used in this ORB. This LocalResolver is used for |
aoqi@0 | 1928 | * register_initial_reference only. |
aoqi@0 | 1929 | */ |
aoqi@0 | 1930 | public void setLocalResolver( LocalResolver resolver ) |
aoqi@0 | 1931 | { |
aoqi@0 | 1932 | synchronized (this) { |
aoqi@0 | 1933 | checkShutdownState(); |
aoqi@0 | 1934 | } |
aoqi@0 | 1935 | synchronized (resolverLock) { |
aoqi@0 | 1936 | this.localResolver = resolver ; |
aoqi@0 | 1937 | } |
aoqi@0 | 1938 | } |
aoqi@0 | 1939 | |
aoqi@0 | 1940 | /** Get the LocalResolver used in this ORB. This LocalResolver is used for |
aoqi@0 | 1941 | * register_initial_reference only. |
aoqi@0 | 1942 | */ |
aoqi@0 | 1943 | public LocalResolver getLocalResolver() |
aoqi@0 | 1944 | { |
aoqi@0 | 1945 | synchronized (this) { |
aoqi@0 | 1946 | checkShutdownState(); |
aoqi@0 | 1947 | } |
aoqi@0 | 1948 | synchronized (resolverLock) { |
aoqi@0 | 1949 | return localResolver ; |
aoqi@0 | 1950 | } |
aoqi@0 | 1951 | } |
aoqi@0 | 1952 | |
aoqi@0 | 1953 | /** Set the operation used in string_to_object calls. The Operation must expect a |
aoqi@0 | 1954 | * String and return an org.omg.CORBA.Object. |
aoqi@0 | 1955 | */ |
aoqi@0 | 1956 | public void setURLOperation( Operation stringToObject ) |
aoqi@0 | 1957 | { |
aoqi@0 | 1958 | synchronized (this) { |
aoqi@0 | 1959 | checkShutdownState(); |
aoqi@0 | 1960 | } |
aoqi@0 | 1961 | synchronized (urlOperationLock) { |
aoqi@0 | 1962 | urlOperation = stringToObject ; |
aoqi@0 | 1963 | } |
aoqi@0 | 1964 | } |
aoqi@0 | 1965 | |
aoqi@0 | 1966 | /** Get the operation used in string_to_object calls. The Operation must expect a |
aoqi@0 | 1967 | * String and return an org.omg.CORBA.Object. |
aoqi@0 | 1968 | */ |
aoqi@0 | 1969 | public Operation getURLOperation() |
aoqi@0 | 1970 | { |
aoqi@0 | 1971 | synchronized (this) { |
aoqi@0 | 1972 | checkShutdownState(); |
aoqi@0 | 1973 | } |
aoqi@0 | 1974 | synchronized (urlOperationLock) { |
aoqi@0 | 1975 | return urlOperation ; |
aoqi@0 | 1976 | } |
aoqi@0 | 1977 | } |
aoqi@0 | 1978 | |
aoqi@0 | 1979 | public void setINSDelegate( CorbaServerRequestDispatcher sdel ) |
aoqi@0 | 1980 | { |
aoqi@0 | 1981 | synchronized (this) { |
aoqi@0 | 1982 | checkShutdownState(); |
aoqi@0 | 1983 | } |
aoqi@0 | 1984 | synchronized (resolverLock) { |
aoqi@0 | 1985 | insNamingDelegate = sdel ; |
aoqi@0 | 1986 | } |
aoqi@0 | 1987 | } |
aoqi@0 | 1988 | |
aoqi@0 | 1989 | public TaggedComponentFactoryFinder getTaggedComponentFactoryFinder() |
aoqi@0 | 1990 | { |
aoqi@0 | 1991 | synchronized (this) { |
aoqi@0 | 1992 | checkShutdownState(); |
aoqi@0 | 1993 | } |
aoqi@0 | 1994 | return taggedComponentFactoryFinder ; |
aoqi@0 | 1995 | } |
aoqi@0 | 1996 | |
aoqi@0 | 1997 | public IdentifiableFactoryFinder getTaggedProfileFactoryFinder() |
aoqi@0 | 1998 | { |
aoqi@0 | 1999 | synchronized (this) { |
aoqi@0 | 2000 | checkShutdownState(); |
aoqi@0 | 2001 | } |
aoqi@0 | 2002 | return taggedProfileFactoryFinder ; |
aoqi@0 | 2003 | } |
aoqi@0 | 2004 | |
aoqi@0 | 2005 | public IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder() |
aoqi@0 | 2006 | { |
aoqi@0 | 2007 | synchronized (this) { |
aoqi@0 | 2008 | checkShutdownState(); |
aoqi@0 | 2009 | } |
aoqi@0 | 2010 | return taggedProfileTemplateFactoryFinder ; |
aoqi@0 | 2011 | } |
aoqi@0 | 2012 | |
aoqi@0 | 2013 | private Object objectKeyFactoryAccessLock = new Object(); |
aoqi@0 | 2014 | |
aoqi@0 | 2015 | public ObjectKeyFactory getObjectKeyFactory() |
aoqi@0 | 2016 | { |
aoqi@0 | 2017 | synchronized (this) { |
aoqi@0 | 2018 | checkShutdownState(); |
aoqi@0 | 2019 | } |
aoqi@0 | 2020 | synchronized (objectKeyFactoryAccessLock) { |
aoqi@0 | 2021 | return objectKeyFactory ; |
aoqi@0 | 2022 | } |
aoqi@0 | 2023 | } |
aoqi@0 | 2024 | |
aoqi@0 | 2025 | public void setObjectKeyFactory( ObjectKeyFactory factory ) |
aoqi@0 | 2026 | { |
aoqi@0 | 2027 | synchronized (this) { |
aoqi@0 | 2028 | checkShutdownState(); |
aoqi@0 | 2029 | } |
aoqi@0 | 2030 | synchronized (objectKeyFactoryAccessLock) { |
aoqi@0 | 2031 | objectKeyFactory = factory ; |
aoqi@0 | 2032 | } |
aoqi@0 | 2033 | } |
aoqi@0 | 2034 | |
aoqi@0 | 2035 | private Object transportManagerAccessorLock = new Object(); |
aoqi@0 | 2036 | |
aoqi@0 | 2037 | public TransportManager getTransportManager() |
aoqi@0 | 2038 | { |
aoqi@0 | 2039 | synchronized (transportManagerAccessorLock) { |
aoqi@0 | 2040 | if (transportManager == null) { |
aoqi@0 | 2041 | transportManager = new CorbaTransportManagerImpl(this); |
aoqi@0 | 2042 | } |
aoqi@0 | 2043 | return transportManager; |
aoqi@0 | 2044 | } |
aoqi@0 | 2045 | } |
aoqi@0 | 2046 | |
aoqi@0 | 2047 | public CorbaTransportManager getCorbaTransportManager() |
aoqi@0 | 2048 | { |
aoqi@0 | 2049 | return (CorbaTransportManager) getTransportManager(); |
aoqi@0 | 2050 | } |
aoqi@0 | 2051 | |
aoqi@0 | 2052 | private Object legacyServerSocketManagerAccessLock = new Object(); |
aoqi@0 | 2053 | |
aoqi@0 | 2054 | public LegacyServerSocketManager getLegacyServerSocketManager() |
aoqi@0 | 2055 | { |
aoqi@0 | 2056 | synchronized (this) { |
aoqi@0 | 2057 | checkShutdownState(); |
aoqi@0 | 2058 | } |
aoqi@0 | 2059 | synchronized (legacyServerSocketManagerAccessLock) { |
aoqi@0 | 2060 | if (legacyServerSocketManager == null) { |
aoqi@0 | 2061 | legacyServerSocketManager = new LegacyServerSocketManagerImpl(this); |
aoqi@0 | 2062 | } |
aoqi@0 | 2063 | return legacyServerSocketManager; |
aoqi@0 | 2064 | } |
aoqi@0 | 2065 | } |
aoqi@0 | 2066 | |
aoqi@0 | 2067 | private Object threadPoolManagerAccessLock = new Object(); |
aoqi@0 | 2068 | |
aoqi@0 | 2069 | public void setThreadPoolManager(ThreadPoolManager mgr) |
aoqi@0 | 2070 | { |
aoqi@0 | 2071 | synchronized (this) { |
aoqi@0 | 2072 | checkShutdownState(); |
aoqi@0 | 2073 | } |
aoqi@0 | 2074 | synchronized (threadPoolManagerAccessLock) { |
aoqi@0 | 2075 | threadpoolMgr = mgr; |
aoqi@0 | 2076 | } |
aoqi@0 | 2077 | } |
aoqi@0 | 2078 | |
aoqi@0 | 2079 | public ThreadPoolManager getThreadPoolManager() |
aoqi@0 | 2080 | { |
aoqi@0 | 2081 | synchronized (this) { |
aoqi@0 | 2082 | checkShutdownState(); |
aoqi@0 | 2083 | } |
aoqi@0 | 2084 | synchronized (threadPoolManagerAccessLock) { |
aoqi@0 | 2085 | if (threadpoolMgr == null) { |
aoqi@0 | 2086 | threadpoolMgr = new ThreadPoolManagerImpl(); |
aoqi@0 | 2087 | orbOwnsThreadPoolManager = true; |
aoqi@0 | 2088 | } |
aoqi@0 | 2089 | return threadpoolMgr; |
aoqi@0 | 2090 | } |
aoqi@0 | 2091 | } |
aoqi@0 | 2092 | |
aoqi@0 | 2093 | public CopierManager getCopierManager() |
aoqi@0 | 2094 | { |
aoqi@0 | 2095 | synchronized (this) { |
aoqi@0 | 2096 | checkShutdownState(); |
aoqi@0 | 2097 | } |
aoqi@0 | 2098 | return copierManager ; |
aoqi@0 | 2099 | } |
aefimov@1618 | 2100 | |
aefimov@1618 | 2101 | @Override |
aefimov@1618 | 2102 | public void validateIORClass(String iorClassName) { |
aefimov@1618 | 2103 | if (iorTypeCheckRegistry != null) { |
aefimov@1618 | 2104 | if (!iorTypeCheckRegistry.isValidIORType(iorClassName)) { |
aefimov@1618 | 2105 | throw ORBUtilSystemException.get( this, |
aefimov@1618 | 2106 | CORBALogDomains.OA_IOR ).badStringifiedIor(); |
aefimov@1618 | 2107 | } |
aefimov@1618 | 2108 | } |
aefimov@1618 | 2109 | } |
aefimov@1618 | 2110 | |
aoqi@0 | 2111 | } // Class ORBImpl |
aoqi@0 | 2112 | |
aoqi@0 | 2113 | //////////////////////////////////////////////////////////////////////// |
aoqi@0 | 2114 | /// Helper class for a Synchronization Variable |
aoqi@0 | 2115 | //////////////////////////////////////////////////////////////////////// |
aoqi@0 | 2116 | |
aoqi@0 | 2117 | class SynchVariable |
aoqi@0 | 2118 | { |
aoqi@0 | 2119 | // Synchronization Variable |
aoqi@0 | 2120 | public boolean _flag; |
aoqi@0 | 2121 | |
aoqi@0 | 2122 | // Constructor |
aoqi@0 | 2123 | SynchVariable() |
aoqi@0 | 2124 | { |
aoqi@0 | 2125 | _flag = false; |
aoqi@0 | 2126 | } |
aoqi@0 | 2127 | |
aoqi@0 | 2128 | // set Flag to true |
aoqi@0 | 2129 | public void set() |
aoqi@0 | 2130 | { |
aoqi@0 | 2131 | _flag = true; |
aoqi@0 | 2132 | } |
aoqi@0 | 2133 | |
aoqi@0 | 2134 | // get value |
aoqi@0 | 2135 | public boolean value() |
aoqi@0 | 2136 | { |
aoqi@0 | 2137 | return _flag; |
aoqi@0 | 2138 | } |
aoqi@0 | 2139 | |
aoqi@0 | 2140 | // reset Flag to true |
aoqi@0 | 2141 | public void reset() |
aoqi@0 | 2142 | { |
aoqi@0 | 2143 | _flag = false; |
aoqi@0 | 2144 | } |
aoqi@0 | 2145 | } |
aoqi@0 | 2146 | |
aoqi@0 | 2147 | // End of file. |