| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | #nullable enable |
| | 4 | |
|
| | 5 | | using Ice.Instrumentation; |
| | 6 | | using Ice.Internal; |
| | 7 | | using System.Diagnostics; |
| | 8 | | using System.Net; |
| | 9 | | using System.Net.Security; |
| | 10 | | using System.Text; |
| | 11 | |
|
| | 12 | | namespace Ice; |
| | 13 | |
|
| | 14 | | public sealed class ObjectAdapter |
| | 15 | | { |
| | 16 | | private const int StateUninitialized = 0; // Just constructed. |
| | 17 | | private const int StateHeld = 1; |
| | 18 | | private const int StateActivating = 2; |
| | 19 | | private const int StateActive = 3; |
| | 20 | | private const int StateDeactivating = 4; |
| | 21 | | private const int StateDeactivated = 5; |
| | 22 | | private const int StateDestroying = 6; |
| | 23 | | private const int StateDestroyed = 7; |
| | 24 | |
|
| | 25 | | private int _state = StateUninitialized; |
| | 26 | | private readonly Instance _instance; |
| | 27 | | private readonly Communicator _communicator; |
| | 28 | | private ObjectAdapterFactory? _objectAdapterFactory; |
| | 29 | | private Ice.Internal.ThreadPool? _threadPool; |
| | 30 | | private readonly ServantManager _servantManager; |
| | 31 | | private readonly string _name; |
| | 32 | | private readonly string _id; |
| | 33 | | private readonly string _replicaGroupId; |
| | 34 | | private Reference? _reference; |
| | 35 | | private readonly List<IncomingConnectionFactory> _incomingConnectionFactories; |
| | 36 | | private RouterInfo? _routerInfo; |
| | 37 | | private EndpointI[] _publishedEndpoints; |
| | 38 | | private LocatorInfo? _locatorInfo; |
| | 39 | | private int _directCount; // The number of colloc proxies dispatching on this object adapter. |
| | 40 | | private readonly bool _noConfig; |
| | 41 | | private readonly int _messageSizeMax; |
| | 42 | | private readonly SslServerAuthenticationOptions? _serverAuthenticationOptions; |
| | 43 | |
|
| | 44 | | private readonly Lazy<Object> _dispatchPipeline; |
| 1 | 45 | | private readonly Stack<Func<Object, Object>> _middlewareStack = new(); |
| | 46 | |
|
| 1 | 47 | | private readonly object _mutex = new(); |
| | 48 | |
|
| | 49 | | /// <summary> |
| | 50 | | /// Get the name of this object adapter. |
| | 51 | | /// </summary> |
| | 52 | | /// <returns>This object adapter's name.</returns> |
| 1 | 53 | | public string getName() => _noConfig ? "" : _name; |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Get the communicator this object adapter belongs to. |
| | 57 | | /// </summary> |
| | 58 | | /// <returns>This object adapter's communicator. |
| | 59 | | /// </returns> |
| 1 | 60 | | public Communicator getCommunicator() => _communicator; |
| | 61 | |
|
| | 62 | | /// <summary> |
| | 63 | | /// Activate all endpoints that belong to this object adapter. |
| | 64 | | /// After activation, the object adapter can dispatch |
| | 65 | | /// requests received through its endpoints. |
| | 66 | | /// </summary> |
| | 67 | | public void activate() |
| | 68 | | { |
| 1 | 69 | | LocatorInfo? locatorInfo = null; |
| 1 | 70 | | bool printAdapterReady = false; |
| | 71 | |
|
| 1 | 72 | | lock (_mutex) |
| | 73 | | { |
| 1 | 74 | | checkForDeactivation(); |
| | 75 | |
|
| | 76 | | // |
| | 77 | | // If we've previously been initialized we just need to activate the |
| | 78 | | // incoming connection factories and we're done. |
| | 79 | | // |
| 1 | 80 | | if (_state != StateUninitialized) |
| | 81 | | { |
| 1 | 82 | | foreach (IncomingConnectionFactory icf in _incomingConnectionFactories) |
| | 83 | | { |
| 1 | 84 | | icf.activate(); |
| | 85 | | } |
| 1 | 86 | | _state = StateActive; |
| 1 | 87 | | Monitor.PulseAll(_mutex); |
| 1 | 88 | | return; |
| | 89 | | } |
| | 90 | |
|
| | 91 | | // |
| | 92 | | // One off initializations of the adapter: update the |
| | 93 | | // locator registry and print the "adapter ready" |
| | 94 | | // message. We set set state to StateActivating to prevent |
| | 95 | | // deactivation from other threads while these one off |
| | 96 | | // initializations are done. |
| | 97 | | // |
| 1 | 98 | | _state = StateActivating; |
| | 99 | |
|
| 1 | 100 | | locatorInfo = _locatorInfo; |
| 1 | 101 | | if (!_noConfig) |
| | 102 | | { |
| 1 | 103 | | Properties properties = _instance.initializationData().properties!; |
| 1 | 104 | | printAdapterReady = properties.getIcePropertyAsInt("Ice.PrintAdapterReady") > 0; |
| | 105 | | } |
| 1 | 106 | | } |
| | 107 | |
|
| | 108 | | try |
| | 109 | | { |
| 1 | 110 | | var dummy = new Identity(name: "dummy", ""); |
| 1 | 111 | | updateLocatorRegistry(locatorInfo, createDirectProxy(dummy)); |
| 1 | 112 | | } |
| 0 | 113 | | catch (LocalException) |
| | 114 | | { |
| | 115 | | // |
| | 116 | | // If we couldn't update the locator registry, we let the |
| | 117 | | // exception go through and don't activate the adapter to |
| | 118 | | // allow to user code to retry activating the adapter |
| | 119 | | // later. |
| | 120 | | // |
| 0 | 121 | | lock (_mutex) |
| | 122 | | { |
| 0 | 123 | | _state = StateUninitialized; |
| 0 | 124 | | Monitor.PulseAll(_mutex); |
| 0 | 125 | | } |
| 0 | 126 | | throw; |
| | 127 | | } |
| | 128 | |
|
| 1 | 129 | | if (printAdapterReady) |
| | 130 | | { |
| 1 | 131 | | Console.Out.WriteLine(_name + " ready"); |
| | 132 | | } |
| | 133 | |
|
| 1 | 134 | | lock (_mutex) |
| | 135 | | { |
| | 136 | | Debug.Assert(_state == StateActivating); |
| | 137 | |
|
| 1 | 138 | | foreach (IncomingConnectionFactory icf in _incomingConnectionFactories) |
| | 139 | | { |
| 1 | 140 | | icf.activate(); |
| | 141 | | } |
| | 142 | |
|
| 1 | 143 | | _state = StateActive; |
| 1 | 144 | | Monitor.PulseAll(_mutex); |
| 1 | 145 | | } |
| 1 | 146 | | } |
| | 147 | |
|
| | 148 | | /// <summary> |
| | 149 | | /// Temporarily hold receiving and dispatching requests. |
| | 150 | | /// The object adapter can be reactivated with the |
| | 151 | | /// activate operation. <p class="Note"> Holding is not immediate, i.e., after hold returns, the |
| | 152 | | /// object adapter might still be active for some time. You can use waitForHold to wait until holding is |
| | 153 | | /// complete. |
| | 154 | | /// </summary> |
| | 155 | | public void hold() |
| | 156 | | { |
| 1 | 157 | | lock (_mutex) |
| | 158 | | { |
| 1 | 159 | | checkForDeactivation(); |
| 1 | 160 | | _state = StateHeld; |
| 1 | 161 | | foreach (IncomingConnectionFactory factory in _incomingConnectionFactories) |
| | 162 | | { |
| 1 | 163 | | factory.hold(); |
| | 164 | | } |
| | 165 | | } |
| 1 | 166 | | } |
| | 167 | |
|
| | 168 | | /// <summary> |
| | 169 | | /// Wait until the object adapter holds requests. |
| | 170 | | /// Calling hold initiates holding of requests, and |
| | 171 | | /// waitForHold only returns when holding of requests has been completed. |
| | 172 | | /// </summary> |
| | 173 | | public void waitForHold() |
| | 174 | | { |
| | 175 | | List<IncomingConnectionFactory> incomingConnectionFactories; |
| 1 | 176 | | lock (_mutex) |
| | 177 | | { |
| 1 | 178 | | checkForDeactivation(); |
| 1 | 179 | | incomingConnectionFactories = new List<IncomingConnectionFactory>(_incomingConnectionFactories); |
| 1 | 180 | | } |
| | 181 | |
|
| 1 | 182 | | foreach (IncomingConnectionFactory factory in incomingConnectionFactories) |
| | 183 | | { |
| 1 | 184 | | factory.waitUntilHolding(); |
| | 185 | | } |
| 1 | 186 | | } |
| | 187 | |
|
| | 188 | | /// <summary> |
| | 189 | | /// Deactivates this object adapter: stop accepting new connections from clients and close gracefully all incoming |
| | 190 | | /// connections created by this object adapter once all outstanding dispatches have completed. If this object |
| | 191 | | /// adapter is indirect, this method also unregisters the object adapter from the Locator. |
| | 192 | | /// This method does not cancel outstanding dispatches--it lets them execute until completion. A new incoming |
| | 193 | | /// request on an existing connection will be accepted and can delay the closure of the connection. |
| | 194 | | /// A deactivated object adapter cannot be reactivated again; it can only be destroyed. |
| | 195 | | /// </summary> |
| | 196 | | public void deactivate() |
| | 197 | | { |
| 1 | 198 | | lock (_mutex) |
| | 199 | | { |
| | 200 | | // Wait for activation or a previous deactivation to complete. |
| | 201 | | // This is necessary to avoid out of order locator updates. |
| 1 | 202 | | while (_state == StateActivating || _state == StateDeactivating) |
| | 203 | | { |
| 0 | 204 | | Monitor.Wait(_mutex); |
| | 205 | | } |
| 1 | 206 | | if (_state > StateDeactivating) |
| | 207 | | { |
| 1 | 208 | | return; |
| | 209 | | } |
| 1 | 210 | | _state = StateDeactivating; |
| 1 | 211 | | } |
| | 212 | |
|
| | 213 | | // NOTE: the locator infos and incoming connection factory list are immutable at this point. |
| | 214 | |
|
| | 215 | | try |
| | 216 | | { |
| 1 | 217 | | updateLocatorRegistry(_locatorInfo, null); |
| 1 | 218 | | } |
| 1 | 219 | | catch (LocalException) |
| | 220 | | { |
| | 221 | | // We can't throw exceptions in deactivate so we ignore failures to update the locator registry. |
| 1 | 222 | | } |
| | 223 | |
|
| 1 | 224 | | foreach (IncomingConnectionFactory factory in _incomingConnectionFactories) |
| | 225 | | { |
| 1 | 226 | | factory.destroy(); |
| | 227 | | } |
| | 228 | |
|
| 1 | 229 | | lock (_mutex) |
| | 230 | | { |
| | 231 | | Debug.Assert(_state == StateDeactivating); |
| 1 | 232 | | _state = StateDeactivated; |
| 1 | 233 | | Monitor.PulseAll(_mutex); |
| 1 | 234 | | } |
| 1 | 235 | | } |
| | 236 | |
|
| | 237 | | /// <summary> |
| | 238 | | /// Wait until <see cref="deactivate" /> is called on this object adapter and all connections accepted by this |
| | 239 | | /// object adapter are closed. A connection is closed only after all outstanding dispatches on this connection have |
| | 240 | | /// completed. |
| | 241 | | /// </summary> |
| | 242 | | public void waitForDeactivate() |
| | 243 | | { |
| 1 | 244 | | IncomingConnectionFactory[]? incomingConnectionFactories = null; |
| 1 | 245 | | lock (_mutex) |
| | 246 | | { |
| | 247 | | // Wait for deactivation of the adapter itself. |
| 1 | 248 | | while (_state < StateDeactivated) |
| | 249 | | { |
| 1 | 250 | | Monitor.Wait(_mutex); |
| | 251 | | } |
| 1 | 252 | | if (_state > StateDeactivated) |
| | 253 | | { |
| 1 | 254 | | return; |
| | 255 | | } |
| | 256 | |
|
| 1 | 257 | | incomingConnectionFactories = _incomingConnectionFactories.ToArray(); |
| 1 | 258 | | } |
| | 259 | |
|
| | 260 | | // |
| | 261 | | // Now we wait for until all incoming connection factories are |
| | 262 | | // finished. |
| | 263 | | // |
| 1 | 264 | | foreach (IncomingConnectionFactory factory in incomingConnectionFactories) |
| | 265 | | { |
| 1 | 266 | | factory.waitUntilFinished(); |
| | 267 | | } |
| 1 | 268 | | } |
| | 269 | |
|
| | 270 | | /// <summary> |
| | 271 | | /// Checks if this object adapter has been deactivated. |
| | 272 | | /// </summary> |
| | 273 | | /// <returns><see langword="true" /> if <see cref="deactivate"/> has been called on this object adapter; otherwise, |
| | 274 | | /// <see langword="false" />. |
| | 275 | | /// </returns> |
| | 276 | | public bool isDeactivated() |
| | 277 | | { |
| 1 | 278 | | lock (_mutex) |
| | 279 | | { |
| 1 | 280 | | return _state >= StateDeactivated; |
| | 281 | | } |
| 1 | 282 | | } |
| | 283 | |
|
| | 284 | | /// <summary> |
| | 285 | | /// Destroys this object adapter and cleans up all resources held by this object adapter. |
| | 286 | | /// Once this method has returned, it is possible to create another object adapter with the same name. |
| | 287 | | /// </summary> |
| | 288 | | public void destroy() |
| | 289 | | { |
| | 290 | | // |
| | 291 | | // Deactivate and wait for completion. |
| | 292 | | // |
| 1 | 293 | | deactivate(); |
| 1 | 294 | | waitForDeactivate(); |
| | 295 | |
|
| 1 | 296 | | lock (_mutex) |
| | 297 | | { |
| | 298 | | // |
| | 299 | | // Only a single thread is allowed to destroy the object |
| | 300 | | // adapter. Other threads wait for the destruction to be |
| | 301 | | // completed. |
| | 302 | | // |
| 1 | 303 | | while (_state == StateDestroying) |
| | 304 | | { |
| 0 | 305 | | Monitor.Wait(_mutex); |
| | 306 | | } |
| 1 | 307 | | if (_state == StateDestroyed) |
| | 308 | | { |
| 1 | 309 | | return; |
| | 310 | | } |
| 1 | 311 | | _state = StateDestroying; |
| | 312 | |
|
| 1 | 313 | | while (_directCount > 0) |
| | 314 | | { |
| 1 | 315 | | Monitor.Wait(_mutex); |
| | 316 | | } |
| 1 | 317 | | } |
| | 318 | |
|
| 1 | 319 | | if (_routerInfo is not null) |
| | 320 | | { |
| | 321 | | // Remove entry from the router manager. |
| 1 | 322 | | _instance.routerManager().erase(_routerInfo.getRouter()); |
| | 323 | |
|
| | 324 | | // Clear this object adapter with the router. |
| 1 | 325 | | _routerInfo.setAdapter(null); |
| | 326 | | } |
| | 327 | |
|
| 1 | 328 | | _instance.outgoingConnectionFactory().removeAdapter(this); |
| | 329 | |
|
| | 330 | | // |
| | 331 | | // Now it's also time to clean up our servants and servant |
| | 332 | | // locators. |
| | 333 | | // |
| 1 | 334 | | _servantManager.destroy(); |
| | 335 | |
|
| | 336 | | // |
| | 337 | | // Destroy the thread pool. |
| | 338 | | // |
| 1 | 339 | | if (_threadPool is not null) |
| | 340 | | { |
| 1 | 341 | | _threadPool.destroy(); |
| 1 | 342 | | _threadPool.joinWithAllThreads(); |
| | 343 | | } |
| | 344 | |
|
| 1 | 345 | | _objectAdapterFactory?.removeObjectAdapter(this); |
| | 346 | |
|
| 1 | 347 | | lock (_mutex) |
| | 348 | | { |
| | 349 | | // |
| | 350 | | // We're done, now we can throw away all incoming connection |
| | 351 | | // factories. |
| | 352 | | // |
| 1 | 353 | | _incomingConnectionFactories.Clear(); |
| | 354 | |
|
| | 355 | | // |
| | 356 | | // Remove object references (some of them cyclic). |
| | 357 | | // |
| 1 | 358 | | _threadPool = null; |
| 1 | 359 | | _routerInfo = null; |
| 1 | 360 | | _publishedEndpoints = []; |
| 1 | 361 | | _locatorInfo = null; |
| 1 | 362 | | _reference = null; |
| 1 | 363 | | _objectAdapterFactory = null; |
| | 364 | |
|
| 1 | 365 | | _state = StateDestroyed; |
| 1 | 366 | | Monitor.PulseAll(_mutex); |
| 1 | 367 | | } |
| 1 | 368 | | } |
| | 369 | |
|
| | 370 | | /// <summary> |
| | 371 | | /// Install a middleware in this object adapter. |
| | 372 | | /// </summary> |
| | 373 | | /// <param name="middleware">The middleware to install.</param> |
| | 374 | | /// <returns>This object adapter.</returns> |
| | 375 | | /// <exception cref="InvalidOperationException">Thrown if the object adapter's dispatch pipeline has already been |
| | 376 | | /// created. This creation typically occurs the first time the object adapter dispatches an incoming request. |
| | 377 | | /// </exception> |
| | 378 | | public ObjectAdapter use(Func<Object, Object> middleware) |
| | 379 | | { |
| 1 | 380 | | if (_dispatchPipeline.IsValueCreated) |
| | 381 | | { |
| 0 | 382 | | throw new InvalidOperationException("All middleware must be installed before the first dispatch."); |
| | 383 | | } |
| 1 | 384 | | _middlewareStack.Push(middleware); |
| 1 | 385 | | return this; |
| | 386 | | } |
| | 387 | |
|
| | 388 | | /// <summary> |
| | 389 | | /// Add a servant to this object adapter's Active Servant Map. |
| | 390 | | /// Note that one servant can implement several Ice |
| | 391 | | /// objects by registering the servant with multiple identities. Adding a servant with an identity that is in the |
| | 392 | | /// map already throws AlreadyRegisteredException. |
| | 393 | | /// </summary> |
| | 394 | | /// <param name="servant">The servant to add.</param> |
| | 395 | | /// <param name="id">The identity of the Ice object that is implemented by the servant.</param> |
| | 396 | | /// <returns>A proxy that matches the given identity and this object adapter.</returns> |
| 1 | 397 | | public ObjectPrx add(Object servant, Identity id) => addFacet(servant, id, ""); |
| | 398 | |
|
| | 399 | | /// <summary> |
| | 400 | | /// Like add, but with a facet. |
| | 401 | | /// Calling add(servant, id) is equivalent to calling |
| | 402 | | /// addFacet with an empty facet. |
| | 403 | | /// </summary> |
| | 404 | | /// <param name="servant">The servant to add.</param> |
| | 405 | | /// <param name="identity">The identity of the Ice object that is implemented by the servant.</param> |
| | 406 | | /// <param name="facet">The facet. An empty facet means the default facet.</param> |
| | 407 | | /// <returns>A proxy that matches the given identity, facet, and this object adapter.</returns> |
| | 408 | | public ObjectPrx addFacet(Object servant, Identity identity, string facet) |
| | 409 | | { |
| 1 | 410 | | lock (_mutex) |
| | 411 | | { |
| 1 | 412 | | checkForDestruction(); |
| 1 | 413 | | checkIdentity(identity); |
| 1 | 414 | | ArgumentNullException.ThrowIfNull(servant); |
| | 415 | |
|
| | 416 | | // Create a copy of the Identity argument, in case the caller reuses it. |
| 1 | 417 | | var id = new Identity(identity.name, identity.category); |
| 1 | 418 | | _servantManager.addServant(servant, id, facet); |
| | 419 | |
|
| 1 | 420 | | return newProxy(id, facet); |
| | 421 | | } |
| 1 | 422 | | } |
| | 423 | |
|
| | 424 | | /// <summary> |
| | 425 | | /// Add a servant to this object adapter's Active Servant Map, using an automatically generated UUID as its |
| | 426 | | /// identity. Note that the generated UUID identity can be accessed using the proxy's ice_getIdentity operation. |
| | 427 | | /// </summary> |
| | 428 | | /// <param name="servant">The servant to add.</param> |
| | 429 | | /// <returns>A proxy that matches the generated UUID identity and this object adapter.</returns> |
| 1 | 430 | | public ObjectPrx addWithUUID(Object servant) => addFacetWithUUID(servant, ""); |
| | 431 | |
|
| | 432 | | /// <summary> |
| | 433 | | /// Like addWithUUID, but with a facet. |
| | 434 | | /// Calling addWithUUID(servant) is equivalent to calling |
| | 435 | | /// addFacetWithUUID with an empty facet. |
| | 436 | | /// </summary> |
| | 437 | | /// <param name="servant">The servant to add.</param> |
| | 438 | | /// <param name="facet">The facet. An empty facet means the default facet.</param> |
| | 439 | | /// <returns>A proxy that matches the generated UUID identity, facet, and this object adapter.</returns> |
| | 440 | | public ObjectPrx addFacetWithUUID(Object servant, string facet) |
| | 441 | | { |
| 1 | 442 | | var ident = new Identity(Guid.NewGuid().ToString(), ""); |
| 1 | 443 | | return addFacet(servant, ident, facet); |
| | 444 | | } |
| | 445 | |
|
| | 446 | | /// <summary> |
| | 447 | | /// Add a default servant to handle requests for a specific category. |
| | 448 | | /// Adding a default servant for a category for |
| | 449 | | /// which a default servant is already registered throws AlreadyRegisteredException. To dispatch operation |
| | 450 | | /// calls on servants, the object adapter tries to find a servant for a given Ice object identity and facet in the |
| | 451 | | /// following order: |
| | 452 | | /// |
| | 453 | | /// The object adapter tries to find a servant for the identity and facet in the Active Servant Map. |
| | 454 | | /// If no servant has been found in the Active Servant Map, the object adapter tries to find a default servant |
| | 455 | | /// for the category component of the identity. |
| | 456 | | /// If no servant has been found by any of the preceding steps, the object adapter tries to find a default |
| | 457 | | /// servant for an empty category, regardless of the category contained in the identity. |
| | 458 | | /// If no servant has been found by any of the preceding steps, the object adapter gives up and the caller |
| | 459 | | /// receives ObjectNotExistException or FacetNotExistException. |
| | 460 | | /// </summary> |
| | 461 | | /// <param name="servant">The default servant.</param> |
| | 462 | | /// <param name="category">The category for which the default servant is registered. An empty category means it |
| | 463 | | /// will handle all categories.</param> |
| | 464 | | public void addDefaultServant(Ice.Object servant, string category) |
| | 465 | | { |
| 1 | 466 | | ArgumentNullException.ThrowIfNull(servant); |
| | 467 | |
|
| 1 | 468 | | lock (_mutex) |
| | 469 | | { |
| 1 | 470 | | checkForDestruction(); |
| 1 | 471 | | _servantManager.addDefaultServant(servant, category); |
| 1 | 472 | | } |
| 1 | 473 | | } |
| | 474 | |
|
| | 475 | | /// <summary> |
| | 476 | | /// Remove a servant (that is, the default facet) from the object adapter's Active Servant Map. |
| | 477 | | /// </summary> |
| | 478 | | /// <param name="id">The identity of the Ice object that is implemented by the servant. If the servant implements mu |
| | 479 | | /// Ice objects, remove has to be called for all those Ice objects. Removing an identity that is not in |
| | 480 | | /// the map throws NotRegisteredException.</param> |
| | 481 | | /// <returns>The removed servant.</returns> |
| 1 | 482 | | public Object remove(Identity id) => removeFacet(id, ""); |
| | 483 | |
|
| | 484 | | /// <summary> |
| | 485 | | /// Like remove, but with a facet. |
| | 486 | | /// Calling remove(id) is equivalent to calling |
| | 487 | | /// removeFacet with an empty facet. |
| | 488 | | /// </summary> |
| | 489 | | /// <param name="id">The identity of the Ice object that is implemented by the servant.</param> |
| | 490 | | /// <param name="facet">The facet. An empty facet means the default facet.</param> |
| | 491 | | /// <returns>The removed servant.</returns> |
| | 492 | | public Object removeFacet(Identity id, string facet) |
| | 493 | | { |
| 1 | 494 | | lock (_mutex) |
| | 495 | | { |
| 1 | 496 | | checkForDestruction(); |
| 1 | 497 | | checkIdentity(id); |
| | 498 | |
|
| 1 | 499 | | return _servantManager.removeServant(id, facet); |
| | 500 | | } |
| 1 | 501 | | } |
| | 502 | |
|
| | 503 | | /// <summary> |
| | 504 | | /// Remove all facets with the given identity from the Active Servant Map. |
| | 505 | | /// The operation completely removes the Ice |
| | 506 | | /// object, including its default facet. Removing an identity that is not in the map throws |
| | 507 | | /// NotRegisteredException. |
| | 508 | | /// </summary> |
| | 509 | | /// <param name="id">The identity of the Ice object to be removed.</param> |
| | 510 | | /// <returns>A collection containing all the facet names and servants of the removed Ice object.</returns> |
| | 511 | | public Dictionary<string, Object> removeAllFacets(Identity id) |
| | 512 | | { |
| 1 | 513 | | lock (_mutex) |
| | 514 | | { |
| 1 | 515 | | checkForDestruction(); |
| 1 | 516 | | checkIdentity(id); |
| | 517 | |
|
| 1 | 518 | | return _servantManager.removeAllFacets(id); |
| | 519 | | } |
| 1 | 520 | | } |
| | 521 | |
|
| | 522 | | /// <summary> |
| | 523 | | /// Remove the default servant for a specific category. |
| | 524 | | /// Attempting to remove a default servant for a category that |
| | 525 | | /// is not registered throws NotRegisteredException. |
| | 526 | | /// </summary> |
| | 527 | | /// <param name="category">The category of the default servant to remove.</param> |
| | 528 | | /// <returns>The default servant.</returns> |
| | 529 | | public Object removeDefaultServant(string category) |
| | 530 | | { |
| 1 | 531 | | lock (_mutex) |
| | 532 | | { |
| 1 | 533 | | checkForDestruction(); |
| 1 | 534 | | return _servantManager.removeDefaultServant(category); |
| | 535 | | } |
| 1 | 536 | | } |
| | 537 | |
|
| | 538 | | /// <summary> |
| | 539 | | /// Look up a servant in this object adapter's Active Servant Map by the identity of the Ice object it implements. |
| | 540 | | /// This operation only tries to look up a servant in the Active Servant Map. It does not attempt to find a servant |
| | 541 | | /// by using any installed ServantLocator. |
| | 542 | | /// </summary> |
| | 543 | | /// <param name="id">The identity of the Ice object for which the servant should be returned.</param> |
| | 544 | | /// <returns>The servant that implements the Ice object with the given identity, or null if no such servant has |
| | 545 | | /// been found.</returns> |
| 0 | 546 | | public Object? find(Identity id) => findFacet(id, ""); |
| | 547 | |
|
| | 548 | | /// <summary> |
| | 549 | | /// Like find, but with a facet. |
| | 550 | | /// Calling find(id) is equivalent to calling findFacet |
| | 551 | | /// with an empty facet. |
| | 552 | | /// </summary> |
| | 553 | | /// <param name="id">The identity of the Ice object for which the servant should be returned.</param> |
| | 554 | | /// <param name="facet">The facet. An empty facet means the default facet.</param> |
| | 555 | | /// <returns>The servant that implements the Ice object with the given identity and facet, or null if no such |
| | 556 | | /// servant has been found.</returns> |
| | 557 | | public Object? findFacet(Identity id, string facet) |
| | 558 | | { |
| 1 | 559 | | lock (_mutex) |
| | 560 | | { |
| 1 | 561 | | checkForDestruction(); |
| 1 | 562 | | checkIdentity(id); |
| | 563 | |
|
| 1 | 564 | | return _servantManager.findServant(id, facet); |
| | 565 | | } |
| 1 | 566 | | } |
| | 567 | |
|
| | 568 | | /// <summary> |
| | 569 | | /// Find all facets with the given identity in the Active Servant Map. |
| | 570 | | /// </summary> |
| | 571 | | /// <param name="id">The identity of the Ice object for which the facets should be returned.</param> |
| | 572 | | /// <returns>A collection containing all the facet names and servants that have been found, or an empty map if there |
| | 573 | | /// is no facet for the given identity.</returns> |
| | 574 | | public Dictionary<string, Object> findAllFacets(Identity id) |
| | 575 | | { |
| 1 | 576 | | lock (_mutex) |
| | 577 | | { |
| 1 | 578 | | checkForDestruction(); |
| 1 | 579 | | checkIdentity(id); |
| | 580 | |
|
| 1 | 581 | | return _servantManager.findAllFacets(id); |
| | 582 | | } |
| 1 | 583 | | } |
| | 584 | |
|
| | 585 | | /// <summary> |
| | 586 | | /// Look up a servant in this object adapter's Active Servant Map, given a proxy. |
| | 587 | | /// This operation only tries to lookup a servant in the Active Servant Map. It does not attempt to find a servant |
| | 588 | | /// by using any installed ServantLocator.</summary> |
| | 589 | | /// <param name="proxy">The proxy for which the servant should be returned.</param> |
| | 590 | | /// <returns>The servant that matches the proxy, or null if no such servant has been found.</returns> |
| | 591 | | public Object? findByProxy(ObjectPrx proxy) |
| | 592 | | { |
| 0 | 593 | | lock (_mutex) |
| | 594 | | { |
| 0 | 595 | | checkForDestruction(); |
| 0 | 596 | | Reference @ref = ((ObjectPrxHelperBase)proxy).iceReference(); |
| 0 | 597 | | return findFacet(@ref.getIdentity(), @ref.getFacet()); |
| | 598 | | } |
| 0 | 599 | | } |
| | 600 | |
|
| | 601 | | /// <summary> |
| | 602 | | /// Add a Servant Locator to this object adapter. |
| | 603 | | /// |
| | 604 | | /// Adding a servant locator for a category for which a servant locator is already registered throws |
| | 605 | | /// <see cref="AlreadyRegisteredException" />. To dispatch operation calls on servants, the object adapter tries to |
| | 606 | | /// find a servant for a given Ice object identity and facet in the following order: |
| | 607 | | /// |
| | 608 | | /// The object adapter tries to find a servant for the identity and facet in the Active Servant Map. |
| | 609 | | /// If no servant has been found in the Active Servant Map, the object adapter tries to find a servant locator |
| | 610 | | /// for the category component of the identity. If a locator is found, the object adapter tries to find a servant |
| | 611 | | /// using this locator. |
| | 612 | | /// If no servant has been found by any of the preceding steps, the object adapter tries to find a locator for |
| | 613 | | /// an empty category, regardless of the category contained in the identity. If a locator is found, the object |
| | 614 | | /// adapter tries to find a servant using this locator. |
| | 615 | | /// If no servant has been found by any of the preceding steps, the object adapter gives up and the caller |
| | 616 | | /// receives <see cref="ObjectNotExistException" /> or <see cref="FacetNotExistException" />. |
| | 617 | | /// </summary> |
| | 618 | | /// <param name="locator">The locator to add.</param> |
| | 619 | | /// <param name="category">The category for which the Servant Locator can locate servants, or an empty string if the |
| | 620 | | /// Servant Locator does not belong to any specific category.</param> |
| | 621 | | public void addServantLocator(ServantLocator locator, string category) |
| | 622 | | { |
| 1 | 623 | | lock (_mutex) |
| | 624 | | { |
| 1 | 625 | | checkForDestruction(); |
| 1 | 626 | | _servantManager.addServantLocator(locator, category); |
| 1 | 627 | | } |
| 1 | 628 | | } |
| | 629 | |
|
| | 630 | | /// <summary> |
| | 631 | | /// Remove a Servant Locator from this object adapter. |
| | 632 | | /// </summary> |
| | 633 | | /// <param name="category">The category for which the Servant Locator can locate servants, or an empty string if the |
| | 634 | | /// servant locator does not belong to any specific category.</param> |
| | 635 | | /// <returns>The Servant Locator, or throws <see cref="NotRegisteredException"/> if no Servant Locator was found |
| | 636 | | /// for the given category.</returns> |
| | 637 | | public ServantLocator removeServantLocator(string category) |
| | 638 | | { |
| 1 | 639 | | lock (_mutex) |
| | 640 | | { |
| 1 | 641 | | checkForDestruction(); |
| 1 | 642 | | return _servantManager.removeServantLocator(category); |
| | 643 | | } |
| 1 | 644 | | } |
| | 645 | |
|
| | 646 | | /// <summary> |
| | 647 | | /// Find a Servant Locator installed with this object adapter. |
| | 648 | | /// </summary> |
| | 649 | | /// <param name="category">The category for which the Servant Locator can locate servants, or an empty string if the |
| | 650 | | /// Servant Locator does not belong to any specific category. |
| | 651 | | /// </param> |
| | 652 | | /// <returns>The servant locator, or null if no servant locator was found for the given category.</returns> |
| | 653 | | public ServantLocator? findServantLocator(string category) |
| | 654 | | { |
| 0 | 655 | | lock (_mutex) |
| | 656 | | { |
| 0 | 657 | | checkForDestruction(); |
| 0 | 658 | | return _servantManager.findServantLocator(category); |
| | 659 | | } |
| 0 | 660 | | } |
| | 661 | |
|
| | 662 | | /// <summary> |
| | 663 | | /// Find the default servant for a specific category. |
| | 664 | | /// </summary> |
| | 665 | | /// <param name="category">The category of the default servant to find.</param> |
| | 666 | | /// <returns>The default servant or null if no default servant was registered for the category.</returns> |
| | 667 | | public Object? findDefaultServant(string category) |
| | 668 | | { |
| 1 | 669 | | lock (_mutex) |
| | 670 | | { |
| 1 | 671 | | checkForDestruction(); |
| 1 | 672 | | return _servantManager.findDefaultServant(category); |
| | 673 | | } |
| 1 | 674 | | } |
| | 675 | |
|
| | 676 | | /// <summary> |
| | 677 | | /// Gets the dispatch pipeline of this object adapter. |
| | 678 | | /// </summary> |
| | 679 | | /// <value>The dispatch pipeline.</value> |
| 1 | 680 | | public Object dispatchPipeline => _dispatchPipeline.Value; |
| | 681 | |
|
| | 682 | | /// <summary> |
| | 683 | | /// Create a proxy for the object with the given identity. |
| | 684 | | /// If this object adapter is configured with an adapter id, |
| | 685 | | /// the return value is an indirect proxy that refers to the adapter id. If a replica group id is also defined, the |
| | 686 | | /// return value is an indirect proxy that refers to the replica group id. Otherwise, if no adapter id is defined, |
| | 687 | | /// the return value is a direct proxy containing this object adapter's published endpoints. |
| | 688 | | /// </summary> |
| | 689 | | /// <param name="id">The object's identity.</param> |
| | 690 | | /// <returns>A proxy for the object with the given identity.</returns> |
| | 691 | | public ObjectPrx createProxy(Identity id) |
| | 692 | | { |
| 1 | 693 | | lock (_mutex) |
| | 694 | | { |
| 1 | 695 | | checkForDestruction(); |
| 1 | 696 | | checkIdentity(id); |
| | 697 | |
|
| 1 | 698 | | return newProxy(id, ""); |
| | 699 | | } |
| 1 | 700 | | } |
| | 701 | |
|
| | 702 | | /// <summary> |
| | 703 | | /// Create a direct proxy for the object with the given identity. |
| | 704 | | /// The returned proxy contains this object adapter's |
| | 705 | | /// published endpoints. |
| | 706 | | /// </summary> |
| | 707 | | /// <param name="id">The object's identity.</param> |
| | 708 | | /// <returns>A proxy for the object with the given identity.</returns> |
| | 709 | | public ObjectPrx createDirectProxy(Identity id) |
| | 710 | | { |
| 1 | 711 | | lock (_mutex) |
| | 712 | | { |
| 1 | 713 | | checkForDestruction(); |
| 1 | 714 | | checkIdentity(id); |
| | 715 | |
|
| 1 | 716 | | return newDirectProxy(id, ""); |
| | 717 | | } |
| 1 | 718 | | } |
| | 719 | |
|
| | 720 | | /// <summary> |
| | 721 | | /// Create an indirect proxy for the object with the given identity. |
| | 722 | | /// If this object adapter is configured with an |
| | 723 | | /// adapter id, the return value refers to the adapter id. Otherwise, the return value contains only the object |
| | 724 | | /// identity. |
| | 725 | | /// </summary> |
| | 726 | | /// <param name="id">The object's identity.</param> |
| | 727 | | /// <returns>A proxy for the object with the given identity.</returns> |
| | 728 | | public ObjectPrx createIndirectProxy(Identity id) |
| | 729 | | { |
| 1 | 730 | | lock (_mutex) |
| | 731 | | { |
| 1 | 732 | | checkForDestruction(); |
| 1 | 733 | | checkIdentity(id); |
| | 734 | |
|
| 1 | 735 | | return newIndirectProxy(id, "", _id); |
| | 736 | | } |
| 1 | 737 | | } |
| | 738 | |
|
| | 739 | | /// <summary> |
| | 740 | | /// Set an Ice locator for this object adapter. |
| | 741 | | /// By doing so, the object adapter will register itself with the |
| | 742 | | /// locator registry when it is activated for the first time. Furthermore, the proxies created by this object |
| | 743 | | /// adapter will contain the adapter identifier instead of its endpoints. The adapter identifier must be configured |
| | 744 | | /// using the AdapterId property. |
| | 745 | | /// </summary> |
| | 746 | | /// <param name="locator">The locator used by this object adapter.</param> |
| | 747 | | public void setLocator(LocatorPrx? locator) |
| | 748 | | { |
| 1 | 749 | | lock (_mutex) |
| | 750 | | { |
| 1 | 751 | | checkForDeactivation(); |
| 1 | 752 | | _locatorInfo = _instance.locatorManager().get(locator); |
| 1 | 753 | | } |
| 1 | 754 | | } |
| | 755 | |
|
| | 756 | | /// <summary> |
| | 757 | | /// Get the Ice locator used by this object adapter. |
| | 758 | | /// </summary> |
| | 759 | | /// <returns>The locator used by this object adapter, or null if no locator is used by this object adapter. |
| | 760 | | /// </returns> |
| | 761 | | public LocatorPrx? getLocator() |
| | 762 | | { |
| 1 | 763 | | lock (_mutex) |
| | 764 | | { |
| 1 | 765 | | return _locatorInfo?.getLocator(); |
| | 766 | | } |
| 1 | 767 | | } |
| | 768 | |
|
| | 769 | | /// <summary> |
| | 770 | | /// Get the set of endpoints configured with this object adapter. |
| | 771 | | /// </summary> |
| | 772 | | /// <returns>The set of endpoints.</returns> |
| | 773 | | public Endpoint[] getEndpoints() |
| | 774 | | { |
| 1 | 775 | | lock (_mutex) |
| | 776 | | { |
| 1 | 777 | | var endpoints = new List<Endpoint>(); |
| 1 | 778 | | foreach (IncomingConnectionFactory factory in _incomingConnectionFactories) |
| | 779 | | { |
| 1 | 780 | | endpoints.Add(factory.endpoint()); |
| | 781 | | } |
| 1 | 782 | | return endpoints.ToArray(); |
| | 783 | | } |
| 1 | 784 | | } |
| | 785 | |
|
| | 786 | | /// <summary> |
| | 787 | | /// Get the set of endpoints that proxies created by this object adapter will contain. |
| | 788 | | /// </summary> |
| | 789 | | /// <returns>The set of published endpoints. |
| | 790 | | /// </returns> |
| | 791 | | public Endpoint[] getPublishedEndpoints() |
| | 792 | | { |
| 1 | 793 | | lock (_mutex) |
| | 794 | | { |
| 1 | 795 | | return (Endpoint[])_publishedEndpoints.Clone(); |
| | 796 | | } |
| 1 | 797 | | } |
| | 798 | |
|
| | 799 | | /// <summary> |
| | 800 | | /// Set of the endpoints that proxies created by this object adapter will contain. |
| | 801 | | /// </summary> |
| | 802 | | /// <param name="newEndpoints">The new set of endpoints that the object adapter will embed in proxies. |
| | 803 | | /// </param> |
| | 804 | | public void setPublishedEndpoints(Endpoint[] newEndpoints) |
| | 805 | | { |
| 1 | 806 | | LocatorInfo? locatorInfo = null; |
| | 807 | | EndpointI[] oldPublishedEndpoints; |
| | 808 | |
|
| 1 | 809 | | lock (_mutex) |
| | 810 | | { |
| 1 | 811 | | checkForDeactivation(); |
| 1 | 812 | | if (_routerInfo is not null) |
| | 813 | | { |
| 1 | 814 | | throw new ArgumentException( |
| 1 | 815 | | "can't set published endpoints on object adapter associated with a router"); |
| | 816 | | } |
| | 817 | |
|
| 1 | 818 | | oldPublishedEndpoints = _publishedEndpoints; |
| 1 | 819 | | _publishedEndpoints = Array.ConvertAll(newEndpoints, endpt => (EndpointI)endpt); |
| 1 | 820 | | locatorInfo = _locatorInfo; |
| 1 | 821 | | } |
| | 822 | |
|
| | 823 | | try |
| | 824 | | { |
| 1 | 825 | | var dummy = new Identity("dummy", ""); |
| 1 | 826 | | updateLocatorRegistry(locatorInfo, createDirectProxy(dummy)); |
| 1 | 827 | | } |
| 0 | 828 | | catch (LocalException) |
| | 829 | | { |
| 0 | 830 | | lock (_mutex) |
| | 831 | | { |
| | 832 | | // |
| | 833 | | // Restore the old published endpoints. |
| | 834 | | // |
| 0 | 835 | | _publishedEndpoints = oldPublishedEndpoints; |
| 0 | 836 | | throw; |
| | 837 | | } |
| | 838 | | } |
| 1 | 839 | | } |
| | 840 | |
|
| | 841 | | internal bool isLocal(Reference r) |
| | 842 | | { |
| | 843 | | // |
| | 844 | | // NOTE: it's important that isLocal() doesn't perform any blocking operations as |
| | 845 | | // it can be called for AMI invocations if the proxy has no delegate set yet. |
| | 846 | | // |
| | 847 | |
|
| 1 | 848 | | if (r.isWellKnown()) |
| | 849 | | { |
| | 850 | | // |
| | 851 | | // Check the active servant map to see if the well-known |
| | 852 | | // proxy is for a local object. |
| | 853 | | // |
| 1 | 854 | | return _servantManager.hasServant(r.getIdentity()); |
| | 855 | | } |
| 1 | 856 | | else if (r.isIndirect()) |
| | 857 | | { |
| | 858 | | // |
| | 859 | | // Proxy is local if the reference adapter id matches this |
| | 860 | | // adapter id or replica group id. |
| | 861 | | // |
| 1 | 862 | | return r.getAdapterId().Equals(_id, StringComparison.Ordinal) || |
| 1 | 863 | | r.getAdapterId().Equals(_replicaGroupId, StringComparison.Ordinal); |
| | 864 | | } |
| | 865 | | else |
| | 866 | | { |
| | 867 | | // Proxies which have at least one endpoint in common with the published endpoints are considered local. |
| | 868 | | // This check doesn't take datagram endpoints into account; this effectively disables colloc optimization |
| | 869 | | // for UDP. |
| 1 | 870 | | lock (_mutex) |
| | 871 | | { |
| 1 | 872 | | checkForDestruction(); |
| 1 | 873 | | IEnumerable<EndpointI> endpoints = r.getEndpoints().Where(e => !e.datagram()); |
| 1 | 874 | | return _publishedEndpoints.Any(e => endpoints.Any(e.equivalent)); |
| | 875 | | } |
| | 876 | | } |
| 1 | 877 | | } |
| | 878 | |
|
| | 879 | | internal void flushAsyncBatchRequests(Ice.CompressBatch compressBatch, CommunicatorFlushBatchAsync outAsync) |
| | 880 | | { |
| | 881 | | List<IncomingConnectionFactory> f; |
| 1 | 882 | | lock (_mutex) |
| | 883 | | { |
| 1 | 884 | | f = new List<IncomingConnectionFactory>(_incomingConnectionFactories); |
| 1 | 885 | | } |
| | 886 | |
|
| 1 | 887 | | foreach (IncomingConnectionFactory factory in f) |
| | 888 | | { |
| 1 | 889 | | factory.flushAsyncBatchRequests(compressBatch, outAsync); |
| | 890 | | } |
| 1 | 891 | | } |
| | 892 | |
|
| | 893 | | internal void updateConnectionObservers() |
| | 894 | | { |
| | 895 | | List<IncomingConnectionFactory> f; |
| 1 | 896 | | lock (_mutex) |
| | 897 | | { |
| 1 | 898 | | f = new List<IncomingConnectionFactory>(_incomingConnectionFactories); |
| 1 | 899 | | } |
| | 900 | |
|
| 1 | 901 | | foreach (IncomingConnectionFactory p in f) |
| | 902 | | { |
| 1 | 903 | | p.updateConnectionObservers(); |
| | 904 | | } |
| 1 | 905 | | } |
| | 906 | |
|
| | 907 | | internal void updateThreadObservers() |
| | 908 | | { |
| | 909 | | Ice.Internal.ThreadPool? threadPool; |
| 1 | 910 | | lock (_mutex) |
| | 911 | | { |
| 1 | 912 | | threadPool = _threadPool; |
| 1 | 913 | | } |
| | 914 | |
|
| 1 | 915 | | threadPool?.updateObservers(); |
| 1 | 916 | | } |
| | 917 | |
|
| | 918 | | internal void incDirectCount() |
| | 919 | | { |
| 1 | 920 | | lock (_mutex) |
| | 921 | | { |
| 1 | 922 | | checkForDestruction(); |
| | 923 | |
|
| | 924 | | Debug.Assert(_directCount >= 0); |
| 1 | 925 | | ++_directCount; |
| 1 | 926 | | } |
| 1 | 927 | | } |
| | 928 | |
|
| | 929 | | internal void decDirectCount() |
| | 930 | | { |
| 1 | 931 | | lock (_mutex) |
| | 932 | | { |
| | 933 | | // Not check for destruction here! |
| | 934 | |
|
| | 935 | | Debug.Assert(_instance is not null); // destroy waits for _directCount to reach 0 |
| | 936 | |
|
| | 937 | | Debug.Assert(_directCount > 0); |
| 1 | 938 | | if (--_directCount == 0) |
| | 939 | | { |
| 1 | 940 | | Monitor.PulseAll(_mutex); |
| | 941 | | } |
| 1 | 942 | | } |
| 1 | 943 | | } |
| | 944 | |
|
| | 945 | | internal Ice.Internal.ThreadPool getThreadPool() |
| | 946 | | { |
| | 947 | | // No mutex lock necessary, _threadPool and _instance are |
| | 948 | | // immutable after creation until they are removed in |
| | 949 | | // destroy(). |
| | 950 | |
|
| | 951 | | // Not check for deactivation here! |
| | 952 | |
|
| | 953 | | Debug.Assert(_instance is not null); // Must not be called after destroy(). |
| | 954 | |
|
| 1 | 955 | | if (_threadPool is not null) |
| | 956 | | { |
| 1 | 957 | | return _threadPool; |
| | 958 | | } |
| | 959 | | else |
| | 960 | | { |
| 1 | 961 | | return _instance.serverThreadPool(); |
| | 962 | | } |
| | 963 | | } |
| | 964 | |
|
| | 965 | | internal void setAdapterOnConnection(Ice.ConnectionI connection) |
| | 966 | | { |
| 1 | 967 | | lock (_mutex) |
| | 968 | | { |
| 1 | 969 | | checkForDestruction(); |
| 1 | 970 | | connection.setAdapterFromAdapter(this); |
| 1 | 971 | | } |
| 1 | 972 | | } |
| | 973 | |
|
| 1 | 974 | | internal int messageSizeMax() => _messageSizeMax; |
| | 975 | |
|
| | 976 | | // |
| | 977 | | // Only for use by ObjectAdapterFactory |
| | 978 | | // |
| 1 | 979 | | internal ObjectAdapter( |
| 1 | 980 | | Instance instance, |
| 1 | 981 | | Communicator communicator, |
| 1 | 982 | | ObjectAdapterFactory objectAdapterFactory, |
| 1 | 983 | | string name, |
| 1 | 984 | | RouterPrx? router, |
| 1 | 985 | | bool noConfig, |
| 1 | 986 | | SslServerAuthenticationOptions? serverAuthenticationOptions) |
| | 987 | | { |
| 1 | 988 | | _instance = instance; |
| 1 | 989 | | _communicator = communicator; |
| 1 | 990 | | _objectAdapterFactory = objectAdapterFactory; |
| 1 | 991 | | _servantManager = new ServantManager(instance, name); |
| | 992 | |
|
| 1 | 993 | | _dispatchPipeline = new Lazy<Object>(createDispatchPipeline); |
| 1 | 994 | | _name = name; |
| 1 | 995 | | _incomingConnectionFactories = []; |
| 1 | 996 | | _publishedEndpoints = []; |
| 1 | 997 | | _routerInfo = null; |
| 1 | 998 | | _directCount = 0; |
| 1 | 999 | | _noConfig = noConfig; |
| 1 | 1000 | | _serverAuthenticationOptions = serverAuthenticationOptions; |
| | 1001 | |
|
| | 1002 | | // Install default middleware depending on the communicator's configuration. |
| 1 | 1003 | | if (_instance.initializationData().logger is Logger logger) |
| | 1004 | | { |
| 1 | 1005 | | int warningLevel = _instance.initializationData().properties!.getIcePropertyAsInt("Ice.Warn.Dispatch"); |
| 1 | 1006 | | if (_instance.traceLevels().dispatch > 0 || warningLevel > 0) |
| | 1007 | | { |
| 1 | 1008 | | use(next => |
| 1 | 1009 | | new LoggerMiddleware( |
| 1 | 1010 | | next, |
| 1 | 1011 | | logger, |
| 1 | 1012 | | _instance.traceLevels().dispatch, |
| 1 | 1013 | | _instance.traceLevels().dispatchCat, |
| 1 | 1014 | | warningLevel, |
| 1 | 1015 | | _instance.toStringMode())); |
| | 1016 | | } |
| | 1017 | | } |
| 1 | 1018 | | if (_instance.initializationData().observer is CommunicatorObserver observer) |
| | 1019 | | { |
| 1 | 1020 | | use(next => new ObserverMiddleware(next, observer)); |
| | 1021 | | } |
| | 1022 | |
|
| 1 | 1023 | | if (_noConfig) |
| | 1024 | | { |
| 1 | 1025 | | _id = ""; |
| 1 | 1026 | | _replicaGroupId = ""; |
| 1 | 1027 | | _reference = _instance.referenceFactory().create("dummy -t", ""); |
| 1 | 1028 | | return; |
| | 1029 | | } |
| | 1030 | |
|
| 1 | 1031 | | Properties properties = _instance.initializationData().properties!; |
| 1 | 1032 | | Properties.validatePropertiesWithPrefix(_name, properties, PropertyNames.ObjectAdapterProps); |
| | 1033 | |
|
| | 1034 | | // |
| | 1035 | | // Make sure named adapter has configuration. |
| | 1036 | | // |
| 1 | 1037 | | if (router is null && properties.getPropertiesForPrefix($"{_name}.").Count == 0) |
| | 1038 | | { |
| | 1039 | | // |
| | 1040 | | // These need to be set to prevent warnings/asserts in the destructor. |
| | 1041 | | // |
| 1 | 1042 | | _state = StateDestroyed; |
| 1 | 1043 | | _incomingConnectionFactories = []; |
| | 1044 | |
|
| 1 | 1045 | | throw new InitializationException($"Object adapter '{name}' requires configuration."); |
| | 1046 | | } |
| | 1047 | |
|
| 1 | 1048 | | _id = properties.getProperty(_name + ".AdapterId"); |
| 1 | 1049 | | _replicaGroupId = properties.getProperty(_name + ".ReplicaGroupId"); |
| | 1050 | |
|
| | 1051 | | // |
| | 1052 | | // Setup a reference to be used to get the default proxy options |
| | 1053 | | // when creating new proxies. By default, create twoway proxies. |
| | 1054 | | // |
| 1 | 1055 | | string proxyOptions = properties.getPropertyWithDefault(_name + ".ProxyOptions", "-t"); |
| | 1056 | | try |
| | 1057 | | { |
| 1 | 1058 | | _reference = _instance.referenceFactory().create("dummy " + proxyOptions, ""); |
| 1 | 1059 | | } |
| 0 | 1060 | | catch (ParseException ex) |
| | 1061 | | { |
| 0 | 1062 | | throw new InitializationException( |
| 0 | 1063 | | $"Invalid proxy options '{proxyOptions}' for object adapter '{_name}'.", |
| 0 | 1064 | | ex); |
| | 1065 | | } |
| | 1066 | |
|
| | 1067 | | // The maximum size of an Ice protocol message in bytes. This is limited to 0x7fffffff, which corresponds to |
| | 1068 | | // the maximum value of a 32-bit signed integer (int). |
| | 1069 | | const int messageSizeMaxUpperLimit = int.MaxValue; |
| 1 | 1070 | | int defaultMessageSizeMax = instance.messageSizeMax() / 1024; |
| 1 | 1071 | | int messageSizeMax = properties.getPropertyAsIntWithDefault($"{_name}.MessageSizeMax", defaultMessageSizeMax); |
| 1 | 1072 | | if (messageSizeMax > messageSizeMaxUpperLimit / 1024) |
| | 1073 | | { |
| 0 | 1074 | | throw new Ice.InitializationException( |
| 0 | 1075 | | $"{_name}.MessageSizeMax '{messageSizeMax}' is too large, it must be less than or equal to '{messageSize |
| | 1076 | | } |
| 1 | 1077 | | else if (messageSizeMax < 1) |
| | 1078 | | { |
| 1 | 1079 | | _messageSizeMax = messageSizeMaxUpperLimit; |
| | 1080 | | } |
| | 1081 | | else |
| | 1082 | | { |
| | 1083 | | // The property is specified in kibibytes (KiB); _messageSizeMax is stored in bytes. |
| 1 | 1084 | | _messageSizeMax = messageSizeMax * 1024; |
| | 1085 | | } |
| | 1086 | |
|
| | 1087 | | try |
| | 1088 | | { |
| 1 | 1089 | | int threadPoolSize = properties.getPropertyAsInt(_name + ".ThreadPool.Size"); |
| 1 | 1090 | | int threadPoolSizeMax = properties.getPropertyAsInt(_name + ".ThreadPool.SizeMax"); |
| 1 | 1091 | | if (threadPoolSize > 0 || threadPoolSizeMax > 0) |
| | 1092 | | { |
| 1 | 1093 | | _threadPool = new Ice.Internal.ThreadPool(_instance, _name + ".ThreadPool", 0); |
| | 1094 | | } |
| | 1095 | |
|
| 1 | 1096 | | router ??= RouterPrxHelper.uncheckedCast(communicator.propertyToProxy(_name + ".Router")); |
| 1 | 1097 | | if (router is not null) |
| | 1098 | | { |
| 1 | 1099 | | _routerInfo = _instance.routerManager().get(router); |
| | 1100 | | Debug.Assert(_routerInfo is not null); |
| | 1101 | |
|
| 1 | 1102 | | if (properties.getProperty($"{_name}.Endpoints").Length > 0) |
| | 1103 | | { |
| 1 | 1104 | | throw new InitializationException( |
| 1 | 1105 | | "An object adapter with a router cannot accept incoming connections."); |
| | 1106 | | } |
| | 1107 | |
|
| | 1108 | | // |
| | 1109 | | // Make sure this router is not already registered with another adapter. |
| | 1110 | | // |
| 1 | 1111 | | if (_routerInfo.getAdapter() is not null) |
| | 1112 | | { |
| 0 | 1113 | | throw new AlreadyRegisteredException( |
| 0 | 1114 | | "object adapter with router", |
| 0 | 1115 | | Util.identityToString(router.ice_getIdentity(), _instance.toStringMode())); |
| | 1116 | | } |
| | 1117 | |
|
| | 1118 | | // |
| | 1119 | | // Associate this object adapter with the router. This way, |
| | 1120 | | // new outgoing connections to the router's client proxy will |
| | 1121 | | // use this object adapter for callbacks. |
| | 1122 | | // |
| 1 | 1123 | | _routerInfo.setAdapter(this); |
| | 1124 | |
|
| | 1125 | | // |
| | 1126 | | // Also modify all existing outgoing connections to the |
| | 1127 | | // router's client proxy to use this object adapter for |
| | 1128 | | // callbacks. |
| | 1129 | | // |
| 1 | 1130 | | _instance.outgoingConnectionFactory().setRouterInfo(_routerInfo); |
| | 1131 | | } |
| | 1132 | | else |
| | 1133 | | { |
| | 1134 | | // |
| | 1135 | | // Parse the endpoints, but don't store them in the adapter. The connection |
| | 1136 | | // factory might change it, for example, to fill in the real port number. |
| | 1137 | | // |
| 1 | 1138 | | List<EndpointI> endpoints = parseEndpoints(properties.getProperty(_name + ".Endpoints"), true); |
| 1 | 1139 | | foreach (EndpointI endp in endpoints) |
| | 1140 | | { |
| 1 | 1141 | | foreach (EndpointI expanded in endp.expandHost()) |
| | 1142 | | { |
| 1 | 1143 | | var factory = new IncomingConnectionFactory(instance, expanded, this); |
| 1 | 1144 | | _incomingConnectionFactories.Add(factory); |
| | 1145 | | } |
| | 1146 | | } |
| 1 | 1147 | | if (endpoints.Count == 0) |
| | 1148 | | { |
| 1 | 1149 | | TraceLevels tl = _instance.traceLevels(); |
| 1 | 1150 | | if (tl.network >= 2) |
| | 1151 | | { |
| 1 | 1152 | | _instance.initializationData().logger!.trace( |
| 1 | 1153 | | tl.networkCat, |
| 1 | 1154 | | $"created adapter '{_name}' without endpoints"); |
| | 1155 | | } |
| | 1156 | | } |
| | 1157 | | } |
| | 1158 | |
|
| | 1159 | | // |
| | 1160 | | // Parse published endpoints. |
| | 1161 | | // |
| 1 | 1162 | | _publishedEndpoints = computePublishedEndpoints(); |
| | 1163 | |
|
| 1 | 1164 | | if (properties.getProperty(_name + ".Locator").Length > 0) |
| | 1165 | | { |
| 0 | 1166 | | setLocator(LocatorPrxHelper.uncheckedCast(communicator.propertyToProxy(_name + ".Locator"))); |
| | 1167 | | } |
| | 1168 | | else |
| | 1169 | | { |
| 1 | 1170 | | setLocator(_instance.referenceFactory().getDefaultLocator()); |
| | 1171 | | } |
| 1 | 1172 | | } |
| 1 | 1173 | | catch (LocalException) |
| | 1174 | | { |
| 1 | 1175 | | destroy(); |
| 1 | 1176 | | throw; |
| | 1177 | | } |
| 1 | 1178 | | } |
| | 1179 | |
|
| | 1180 | | internal static void checkIdentity(Identity ident) |
| | 1181 | | { |
| 1 | 1182 | | if (ident.name.Length == 0) |
| | 1183 | | { |
| 1 | 1184 | | throw new ArgumentException("The name of an Ice object identity cannot be empty.", nameof(ident)); |
| | 1185 | | } |
| 1 | 1186 | | } |
| | 1187 | |
|
| 1 | 1188 | | internal SslServerAuthenticationOptions? getServerAuthenticationOptions() => _serverAuthenticationOptions; |
| | 1189 | |
|
| | 1190 | | private ObjectPrx newProxy(Identity ident, string facet) |
| | 1191 | | { |
| 1 | 1192 | | if (_id.Length == 0) |
| | 1193 | | { |
| 1 | 1194 | | return newDirectProxy(ident, facet); |
| | 1195 | | } |
| 1 | 1196 | | else if (_replicaGroupId.Length == 0) |
| | 1197 | | { |
| 1 | 1198 | | return newIndirectProxy(ident, facet, _id); |
| | 1199 | | } |
| | 1200 | | else |
| | 1201 | | { |
| 1 | 1202 | | return newIndirectProxy(ident, facet, _replicaGroupId); |
| | 1203 | | } |
| | 1204 | | } |
| | 1205 | |
|
| | 1206 | | private ObjectPrx newDirectProxy(Identity ident, string facet) => |
| 1 | 1207 | | new ObjectPrxHelper(_instance.referenceFactory().create(ident, facet, _reference, _publishedEndpoints)); |
| | 1208 | |
|
| | 1209 | | private ObjectPrx newIndirectProxy(Identity ident, string facet, string id) => |
| 1 | 1210 | | new ObjectPrxHelper(_instance.referenceFactory().create(ident, facet, _reference, id)); |
| | 1211 | |
|
| | 1212 | | private void checkForDeactivation() |
| | 1213 | | { |
| 1 | 1214 | | checkForDestruction(); |
| | 1215 | |
|
| 1 | 1216 | | if (_state >= StateDeactivating) |
| | 1217 | | { |
| 0 | 1218 | | throw new ObjectAdapterDeactivatedException(getName()); |
| | 1219 | | } |
| 1 | 1220 | | } |
| | 1221 | |
|
| | 1222 | | private void checkForDestruction() |
| | 1223 | | { |
| 1 | 1224 | | if (_state >= StateDestroying) |
| | 1225 | | { |
| 1 | 1226 | | throw new ObjectAdapterDestroyedException(getName()); |
| | 1227 | | } |
| 1 | 1228 | | } |
| | 1229 | |
|
| | 1230 | | private List<EndpointI> parseEndpoints(string endpts, bool oaEndpoints) |
| | 1231 | | { |
| | 1232 | | int beg; |
| 1 | 1233 | | int end = 0; |
| | 1234 | |
|
| 1 | 1235 | | string delim = " \t\n\r"; |
| | 1236 | |
|
| 1 | 1237 | | var endpoints = new List<EndpointI>(); |
| 1 | 1238 | | while (end < endpts.Length) |
| | 1239 | | { |
| 1 | 1240 | | beg = Ice.UtilInternal.StringUtil.findFirstNotOf(endpts, delim, end); |
| 1 | 1241 | | if (beg == -1) |
| | 1242 | | { |
| 1 | 1243 | | if (endpoints.Count != 0) |
| | 1244 | | { |
| 1 | 1245 | | throw new ParseException("invalid empty object adapter endpoint"); |
| | 1246 | | } |
| | 1247 | | break; |
| | 1248 | | } |
| | 1249 | |
|
| 1 | 1250 | | end = beg; |
| 1 | 1251 | | while (true) |
| | 1252 | | { |
| 1 | 1253 | | end = endpts.IndexOf(':', end); |
| 1 | 1254 | | if (end == -1) |
| | 1255 | | { |
| 1 | 1256 | | end = endpts.Length; |
| 1 | 1257 | | break; |
| | 1258 | | } |
| | 1259 | | else |
| | 1260 | | { |
| 1 | 1261 | | bool quoted = false; |
| 1 | 1262 | | int quote = beg; |
| 1 | 1263 | | while (true) |
| | 1264 | | { |
| 1 | 1265 | | quote = endpts.IndexOf('\"', quote); |
| 1 | 1266 | | if (quote == -1 || end < quote) |
| | 1267 | | { |
| | 1268 | | break; |
| | 1269 | | } |
| | 1270 | | else |
| | 1271 | | { |
| 1 | 1272 | | quote = endpts.IndexOf('\"', ++quote); |
| 1 | 1273 | | if (quote == -1) |
| | 1274 | | { |
| | 1275 | | break; |
| | 1276 | | } |
| 1 | 1277 | | else if (end < quote) |
| | 1278 | | { |
| 1 | 1279 | | quoted = true; |
| 1 | 1280 | | break; |
| | 1281 | | } |
| 1 | 1282 | | ++quote; |
| | 1283 | | } |
| | 1284 | | } |
| 1 | 1285 | | if (!quoted) |
| | 1286 | | { |
| | 1287 | | break; |
| | 1288 | | } |
| 1 | 1289 | | ++end; |
| | 1290 | | } |
| | 1291 | | } |
| | 1292 | |
|
| 1 | 1293 | | if (end == beg) |
| | 1294 | | { |
| 1 | 1295 | | throw new ParseException("invalid empty object adapter endpoint"); |
| | 1296 | | } |
| | 1297 | |
|
| 1 | 1298 | | string s = endpts[beg..end]; |
| 1 | 1299 | | EndpointI endp = _instance.endpointFactoryManager().create(s, oaEndpoints) ?? |
| 1 | 1300 | | throw new ParseException($"invalid object adapter endpoint '{s}'"); |
| 1 | 1301 | | endpoints.Add(endp); |
| | 1302 | |
|
| 1 | 1303 | | ++end; |
| | 1304 | | } |
| | 1305 | |
|
| 1 | 1306 | | return endpoints; |
| | 1307 | | } |
| | 1308 | |
|
| | 1309 | | private EndpointI[] computePublishedEndpoints() |
| | 1310 | | { |
| | 1311 | | IEnumerable<EndpointI> endpoints; |
| 1 | 1312 | | if (_routerInfo is not null) |
| | 1313 | | { |
| | 1314 | | // Get the router's server proxy endpoints and use them as the published endpoints. |
| 1 | 1315 | | endpoints = _routerInfo.getServerEndpoints(); |
| | 1316 | | } |
| | 1317 | | else |
| | 1318 | | { |
| | 1319 | | // Parse published endpoints. If set, these are used instead of the connection factory endpoints. |
| 1 | 1320 | | endpoints = parseEndpoints( |
| 1 | 1321 | | _instance.initializationData().properties!.getProperty($"{_name}.PublishedEndpoints"), |
| 1 | 1322 | | oaEndpoints: false); |
| | 1323 | |
|
| 1 | 1324 | | if (!endpoints.Any()) |
| | 1325 | | { |
| | 1326 | | // If the PublishedEndpoints property isn't set, we compute the published endpoints from the factory |
| | 1327 | | // endpoints. |
| 1 | 1328 | | endpoints = _incomingConnectionFactories.Select(f => f.endpoint()); |
| | 1329 | |
|
| | 1330 | | // Remove all loopback/multicast endpoints. |
| 1 | 1331 | | IEnumerable<EndpointI> endpointsNoLoopback = endpoints.Where(e => !e.isLoopbackOrMulticast()); |
| | 1332 | |
|
| | 1333 | | // Retrieve published host |
| 1 | 1334 | | string publishedHost = _instance.initializationData().properties!.getProperty($"{_name}.PublishedHost"); |
| | 1335 | |
|
| 1 | 1336 | | if (endpointsNoLoopback.Any()) |
| | 1337 | | { |
| 1 | 1338 | | endpoints = endpointsNoLoopback; |
| | 1339 | |
|
| | 1340 | | // For non-loopback & non-multicast endpoints, we use the fully qualified name of the local host as |
| | 1341 | | // default for publishedHost. |
| 1 | 1342 | | if (publishedHost.Length == 0) |
| | 1343 | | { |
| 1 | 1344 | | publishedHost = Dns.GetHostEntry("").HostName; // fully qualified name of local host |
| | 1345 | | } |
| | 1346 | | } |
| | 1347 | |
|
| | 1348 | | // Replace the host in all endpoints by publishedHost (when applicable) and clear all local options. |
| 1 | 1349 | | endpoints = endpoints.Select(e => e.toPublishedEndpoint(publishedHost)).Distinct(); |
| | 1350 | | } |
| | 1351 | | } |
| | 1352 | |
|
| 1 | 1353 | | EndpointI[] endpointsArray = endpoints.ToArray(); |
| | 1354 | |
|
| 1 | 1355 | | if (_instance.traceLevels().network >= 1 && endpointsArray.Length > 0) |
| | 1356 | | { |
| 1 | 1357 | | var s = new StringBuilder("published endpoints for object adapter '"); |
| 1 | 1358 | | s.Append(_name); |
| 1 | 1359 | | s.Append("':\n"); |
| 1 | 1360 | | bool first = true; |
| 1 | 1361 | | foreach (EndpointI endpoint in endpointsArray) |
| | 1362 | | { |
| 1 | 1363 | | if (!first) |
| | 1364 | | { |
| 0 | 1365 | | s.Append(':'); |
| | 1366 | | } |
| 1 | 1367 | | s.Append(endpoint.ToString()); |
| 1 | 1368 | | first = false; |
| | 1369 | | } |
| 1 | 1370 | | _instance.initializationData().logger!.trace(_instance.traceLevels().networkCat, s.ToString()); |
| | 1371 | | } |
| | 1372 | |
|
| 1 | 1373 | | return endpointsArray; |
| | 1374 | | } |
| | 1375 | |
|
| | 1376 | | private void updateLocatorRegistry(LocatorInfo? locatorInfo, ObjectPrx? proxy) |
| | 1377 | | { |
| 1 | 1378 | | if (_id.Length == 0 || locatorInfo is null) |
| | 1379 | | { |
| 1 | 1380 | | return; // Nothing to update. |
| | 1381 | | } |
| | 1382 | |
|
| | 1383 | | // |
| | 1384 | | // Call on the locator registry outside the synchronization to |
| | 1385 | | // blocking other threads that need to lock this OA. |
| | 1386 | | // |
| 1 | 1387 | | LocatorRegistryPrx locatorRegistry = locatorInfo.getLocatorRegistry(); |
| 1 | 1388 | | if (locatorRegistry is null) |
| | 1389 | | { |
| 1 | 1390 | | return; |
| | 1391 | | } |
| | 1392 | |
|
| | 1393 | | try |
| | 1394 | | { |
| 1 | 1395 | | if (_replicaGroupId.Length == 0) |
| | 1396 | | { |
| 1 | 1397 | | locatorRegistry.setAdapterDirectProxy(_id, proxy); |
| | 1398 | | } |
| | 1399 | | else |
| | 1400 | | { |
| 1 | 1401 | | locatorRegistry.setReplicatedAdapterDirectProxy(_id, _replicaGroupId, proxy); |
| | 1402 | | } |
| 1 | 1403 | | } |
| 0 | 1404 | | catch (AdapterNotFoundException) |
| | 1405 | | { |
| 0 | 1406 | | if (_instance!.traceLevels().location >= 1) |
| | 1407 | | { |
| 0 | 1408 | | var s = new StringBuilder(); |
| 0 | 1409 | | s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); |
| 0 | 1410 | | s.Append("the object adapter is not known to the locator registry"); |
| 0 | 1411 | | _instance.initializationData().logger!.trace(_instance.traceLevels().locationCat, s.ToString()); |
| | 1412 | | } |
| | 1413 | |
|
| 0 | 1414 | | throw new NotRegisteredException("object adapter", _id); |
| | 1415 | | } |
| 0 | 1416 | | catch (InvalidReplicaGroupIdException) |
| | 1417 | | { |
| 0 | 1418 | | if (_instance.traceLevels().location >= 1) |
| | 1419 | | { |
| 0 | 1420 | | var s = new StringBuilder(); |
| 0 | 1421 | | s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); |
| 0 | 1422 | | s.Append("the replica group `" + _replicaGroupId + "' is not known to the locator registry"); |
| 0 | 1423 | | _instance.initializationData().logger!.trace(_instance.traceLevels().locationCat, s.ToString()); |
| | 1424 | | } |
| | 1425 | |
|
| 0 | 1426 | | throw new NotRegisteredException("replica group", _replicaGroupId); |
| | 1427 | | } |
| 0 | 1428 | | catch (AdapterAlreadyActiveException) |
| | 1429 | | { |
| 0 | 1430 | | if (_instance.traceLevels().location >= 1) |
| | 1431 | | { |
| 0 | 1432 | | var s = new StringBuilder(); |
| 0 | 1433 | | s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); |
| 0 | 1434 | | s.Append("the object adapter endpoints are already set"); |
| 0 | 1435 | | _instance.initializationData().logger!.trace(_instance.traceLevels().locationCat, s.ToString()); |
| | 1436 | | } |
| | 1437 | |
|
| 0 | 1438 | | throw new ObjectAdapterIdInUseException(_id); |
| | 1439 | | } |
| 0 | 1440 | | catch (ObjectAdapterDeactivatedException) |
| | 1441 | | { |
| | 1442 | | // Expected if collocated call and OA is deactivated, ignore. |
| 0 | 1443 | | } |
| 0 | 1444 | | catch (ObjectAdapterDestroyedException) |
| | 1445 | | { |
| | 1446 | | // Ignore |
| 0 | 1447 | | } |
| 0 | 1448 | | catch (CommunicatorDestroyedException) |
| | 1449 | | { |
| | 1450 | | // Ignore |
| 0 | 1451 | | } |
| 1 | 1452 | | catch (LocalException e) |
| | 1453 | | { |
| 1 | 1454 | | if (_instance.traceLevels().location >= 1) |
| | 1455 | | { |
| 1 | 1456 | | var s = new StringBuilder(); |
| 1 | 1457 | | s.Append("couldn't update object adapter `" + _id + "' endpoints with the locator registry:\n"); |
| 1 | 1458 | | s.Append(e.ToString()); |
| 1 | 1459 | | _instance.initializationData().logger!.trace(_instance.traceLevels().locationCat, s.ToString()); |
| | 1460 | | } |
| 1 | 1461 | | throw; // TODO: Shall we raise a special exception instead of a non obvious local exception? |
| | 1462 | | } |
| | 1463 | |
|
| 1 | 1464 | | if (_instance.traceLevels().location >= 1) |
| | 1465 | | { |
| 1 | 1466 | | var s = new StringBuilder(); |
| 1 | 1467 | | s.Append("updated object adapter `" + _id + "' endpoints with the locator registry\n"); |
| 1 | 1468 | | s.Append("endpoints = "); |
| 1 | 1469 | | if (proxy is not null) |
| | 1470 | | { |
| 1 | 1471 | | Endpoint[] endpoints = proxy.ice_getEndpoints(); |
| 1 | 1472 | | for (int i = 0; i < endpoints.Length; i++) |
| | 1473 | | { |
| 1 | 1474 | | s.Append(endpoints[i].ToString()); |
| 1 | 1475 | | if (i + 1 < endpoints.Length) |
| | 1476 | | { |
| 0 | 1477 | | s.Append(':'); |
| | 1478 | | } |
| | 1479 | | } |
| | 1480 | | } |
| 1 | 1481 | | _instance.initializationData().logger!.trace(_instance.traceLevels().locationCat, s.ToString()); |
| | 1482 | | } |
| 1 | 1483 | | } |
| | 1484 | |
|
| | 1485 | | private Object createDispatchPipeline() |
| | 1486 | | { |
| 1 | 1487 | | Object dispatchPipeline = _servantManager; // the "final" dispatcher |
| 1 | 1488 | | foreach (Func<Object, Object> middleware in _middlewareStack) |
| | 1489 | | { |
| 1 | 1490 | | dispatchPipeline = middleware(dispatchPipeline); |
| | 1491 | | } |
| 1 | 1492 | | _middlewareStack.Clear(); // we no longer need these functions |
| 1 | 1493 | | return dispatchPipeline; |
| | 1494 | | } |
| | 1495 | | } |