Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 75x 75x 75x 75x 75x 41x 41x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 44x 41x 41x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 11x 41x 41x 416x 416x 416x 416x 41x 41x 507x 164x 164x 343x 343x 343x 343x 343x 507x 343x 343x 343x 343x 343x 343x 343x 507x 1x 507x 331x 331x 62x 62x 331x 342x 11x 11x 11x 11x 342x 507x 342x 342x 342x 342x 342x 342x 507x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 2x 339x 339x 339x 339x 339x 339x 339x 449x 402x 402x 109x 109x 293x 402x 227x 227x 66x 66x 256x 34x 34x 66x 402x 66x 66x 402x 1x 1x 65x 65x 65x 65x 65x 65x 65x 65x 272x 32x 32x 31x 31x 31x 2x 31x 24x 24x 5x 5x 24x 29x 5x 5x 5x 5x 31x 32x 63x 63x 63x 63x 63x 63x 339x 10x 10x 10x 10x 10x 10x 10x 10x 402x 402x 29x 29x 29x 29x 402x 402x 1x 1x 1x 1x 402x 402x 1x 1x 1x 1x 402x 402x 1x 1x 1x 1x 402x 402x 1x 1x 1x 1x 402x 402x 1x 1x 1x 1x 402x 402x 14x 14x 14x 14x 14x 14x 14x 402x 402x 5x 5x 5x 5x 5x 5x 5x 402x 402x 402x 402x 336x 507x 109x 109x 227x 227x 227x 341x 181x 181x 181x 181x 187x 187x 187x 187x 191x 191x 180x 180x 191x 11x 11x 11x 11x 11x 7x 11x 4x 4x 4x 4x 4x 4x 11x 11x 7x 7x 4x 4x 191x 187x 187x 187x 187x 173x 187x 1x 1x 187x 181x 1x 1x 181x 167x 167x 167x 167x 507x 46x 46x 46x 46x 46x 46x 46x 44x 44x 42x 42x 44x 46x 2x 2x 2x 2x 46x 46x 2x 2x 44x 44x 44x 46x 46x 44x 44x 507x 41x 41x 537x 537x 537x 537x 537x 537x 50x 50x 487x 487x 487x 487x 487x 487x 537x 537x 487x 487x 487x 487x 537x 487x 487x 487x 487x 487x 494x 477x 477x 477x 477x 537x 10x 10x 10x 487x 487x 487x 487x 487x 487x 437x 437x 438x 438x 537x 50x 50x 487x 487x 537x 41x 41x 4x 4x 4x 4x 4x 4x 4x 41x 41x 1x 1x 41x 41x 4x 4x 4x 4x 4x 4x 4x 41x 41x 3x 3x 41x 41x 851x 851x 851x 851x 851x 851x 851x 143x 3x 143x 140x 140x 143x 851x 851x 851x 851x 851x 851x 851x 851x 851x 851x 851x 18x 18x 18x 18x 18x 18x 18x 2x 2x 2x 2x 2x 17x 17x 17x 17x 1x 1x 1x 1x 1x 17x 17x 18x 18x 18x 18x 2x 2x 1x 1x 1x 1x 2x 17x 17x 17x 17x 2x 2x 2x 17x 17x 17x 17x 1x 1x 1x 17x 17x 17x 17x 2x 2x 3x 3x 2x 18x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 850x 851x 41x | // Copyright (c) ZeroC, Inc. import { EndpointSelectionType } from "./EndpointSelectionType.js"; import { Ice as Ice_Locator } from "./Locator.js"; const { LocatorPrx } = Ice_Locator; import { PropertyNames } from "./PropertyNames.js"; import { ReferenceMode } from "./ReferenceMode.js"; import { Ice as Ice_Router } from "./Router.js"; const { RouterPrx } = Ice_Router; import { Ice as Ice_BuiltinSequences } from "./BuiltinSequences.js"; const { StringSeqHelper } = Ice_BuiltinSequences; import { StringUtil } from "./StringUtil.js"; import { Encoding_1_0, Protocol_1_0, stringToEncodingVersion, stringToProtocolVersion } from "./Protocol.js"; import { ParseException, MarshalException } from "./LocalExceptions.js"; import { Ice as Ice_Version } from "./Version.js"; const { ProtocolVersion, EncodingVersion } = Ice_Version; import { stringToIdentity } from "./StringToIdentity.js"; import { RoutableReference, FixedReference } from "./Reference.js"; import { Properties } from "./Properties.js"; // // Only for use by Instance // export class ReferenceFactory { constructor(instance, communicator) { this._instance = instance; this._communicator = communicator; this._defaultRouter = null; this._defaultLocator = null; } create(ident, facet, template, endpoints) { if (ident.name.length === 0 && ident.category.length === 0) { return null; } return this.createImpl( ident, facet, template.getMode(), template.getProtocol(), template.getEncoding(), endpoints, null, null, ); } createFixed(ident, fixedConnection) { if (ident.name.length === 0 && ident.category.length === 0) { return null; } // // Create new reference // return new FixedReference( this._instance, this._communicator, ident, "", // Facet ReferenceMode.ModeTwoway, Protocol_1_0, this._instance.defaultsAndOverrides().defaultEncoding, fixedConnection, -1, null, ); } copy(r) { const ident = r.getIdentity(); if (ident.name.length === 0 && ident.category.length === 0) { return null; } return r.clone(); } createFromString(s, propertyPrefix) { if (s === undefined || s === null || s.length === 0) { return null; } const delim = " \t\n\r"; let end = 0; let beg = StringUtil.findFirstNotOf(s, delim, end); if (beg == -1) { throw new ParseException(`no non-whitespace characters found in '${s}'`); } // // Extract the identity, which may be enclosed in single // or double quotation marks. // let idstr = null; end = StringUtil.checkQuote(s, beg); if (end === -1) { throw new ParseException(`mismatched quotes around identity in '${s}'`); } else if (end === 0) { end = StringUtil.findFirstOf(s, delim + ":@", beg); if (end === -1) { end = s.length; } idstr = s.substring(beg, end); } else { beg++; // Skip leading quote idstr = s.substring(beg, end); end++; // Skip trailing quote } if (beg === end) { throw new ParseException(`no identity in '${s}'`); } // // Parsing the identity may raise ParseException. // const ident = stringToIdentity(idstr); if (ident.name.length === 0) { // // An identity with an empty name and a non-empty // category is illegal. // if (ident.category.length > 0) { throw new ParseException("The category of a null Ice object identity must be empty."); } // // Treat a stringified proxy containing two double // quotes ("") the same as an empty string, i.e., // a null proxy, but only if nothing follows the // quotes. // else if (StringUtil.findFirstNotOf(s, delim, end) != -1) { throw new ParseException(`invalid characters after identity in '${s}'`); } else { return null; } } let facet = ""; let mode = ReferenceMode.ModeTwoway; let encoding = this._instance.defaultsAndOverrides().defaultEncoding; let protocol = Protocol_1_0; let adapter = ""; while (true) { beg = StringUtil.findFirstNotOf(s, delim, end); if (beg === -1) { break; } if (s.charAt(beg) == ":" || s.charAt(beg) == "@") { break; } end = StringUtil.findFirstOf(s, delim + ":@", beg); if (end == -1) { end = s.length; } if (beg == end) { break; } const option = s.substring(beg, end); if (option.length != 2 || option.charAt(0) != "-") { throw new ParseException(`expected a proxy option but found '${option}' in '${s}'`); } // // Check for the presence of an option argument. The // argument may be enclosed in single or double // quotation marks. // let argument = null; const argumentBeg = StringUtil.findFirstNotOf(s, delim, end); if (argumentBeg != -1) { const ch = s.charAt(argumentBeg); if (ch != "@" && ch != ":" && ch != "-") { beg = argumentBeg; end = StringUtil.checkQuote(s, beg); if (end == -1) { throw new ParseException(`mismatched quotes around value for ${option} option in '${s}'`); } else if (end === 0) { end = StringUtil.findFirstOf(s, delim + ":@", beg); if (end === -1) { end = s.length; } argument = s.substring(beg, end); } else { beg++; // Skip leading quote argument = s.substring(beg, end); end++; // Skip trailing quote } } } // // If any new options are added here, // IceInternal::Reference::toString() and its derived classes must be updated as well. // switch (option.charAt(1)) { case "f": { if (argument === null) { throw new ParseException(`no argument provided for -f option in '${s}'`); } try { facet = StringUtil.unescapeString(argument, 0, argument.length); } catch (ex) { throw new ParseException(`invalid facet in ${s}': `, ex); } break; } case "t": { if (argument !== null) { throw new ParseException(`unexpected argument '${argument}' provided for -t option in '${s}'`); } mode = ReferenceMode.ModeTwoway; break; } case "o": { if (argument !== null) { throw new ParseException(`unexpected argument '${argument}' provided for -o option in '${s}'`); } mode = ReferenceMode.ModeOneway; break; } case "O": { if (argument !== null) { throw new ParseException(`unexpected argument '${argument}' provided for -O option in '${s}'`); } mode = ReferenceMode.ModeBatchOneway; break; } case "d": { if (argument !== null) { throw new ParseException(`unexpected argument '${argument}' provided for -d option in '${s}'`); } mode = ReferenceMode.ModeDatagram; break; } case "D": { if (argument !== null) { throw new ParseException(`unexpected argument '${argument}' provided for -D option in '${s}'`); } mode = ReferenceMode.ModeBatchDatagram; break; } case "s": { if (argument !== null) { throw new ParseException(`unexpected argument '${argument}' provided for -s option in '${s}'`); } // Ignored. Kept for backwards compatibility. break; } case "e": { if (argument === null) { throw new ParseException(`no argument provided for -e option in '${s}'`); } try { encoding = stringToEncodingVersion(argument); } catch (e) { throw new ParseException(`invalid encoding version '${argument}' in '${s}'`, e); } break; } case "p": { if (argument === null) { throw new ParseException(`no argument provided for -p option in '${s}'`); } try { protocol = stringToProtocolVersion(argument); } catch ( e // ParseException ) { throw new ParseException(`invalid protocol version '${argument}' in '${s}'`, e); } break; } default: { throw new ParseException(`unknown option '${option}' in '${s}'`); } } } if (beg === -1) { return this.createImpl(ident, facet, mode, protocol, encoding, null, null, propertyPrefix); } const endpoints = []; if (s.charAt(beg) == ":") { const unknownEndpoints = []; end = beg; while (end < s.length && s.charAt(end) == ":") { beg = end + 1; end = beg; while (true) { end = s.indexOf(":", end); if (end == -1) { end = s.length; break; } else { let quoted = false; let quote = beg; while (true) { quote = s.indexOf('"', quote); if (quote == -1 || end < quote) { break; } else { quote = s.indexOf('"', ++quote); if (quote == -1) { break; } else if (end < quote) { quoted = true; break; } ++quote; } } if (!quoted) { break; } ++end; } } const es = s.substring(beg, end); const endp = this._instance.endpointFactoryManager().create(es, false); if (endp !== null) { endpoints.push(endp); } else { unknownEndpoints.push(es); } } if (endpoints.length === 0) { console.assert(unknownEndpoints.length > 0); throw new ParseException(`invalid endpoint '${unknownEndpoints[0]}' in '${s}'`); } else if ( unknownEndpoints.length !== 0 && this._instance.initializationData().properties.getIcePropertyAsInt("Ice.Warn.Endpoints") > 0 ) { const msg = []; msg.push("Proxy contains unknown endpoints:"); unknownEndpoints.forEach(unknownEndpoint => { msg.push(" `"); msg.push(unknownEndpoint); msg.push("'"); }); this._instance.initializationData().logger.warning(msg.join("")); } return this.createImpl(ident, facet, mode, protocol, encoding, endpoints, null, propertyPrefix); } else if (s.charAt(beg) == "@") { beg = StringUtil.findFirstNotOf(s, delim, beg + 1); if (beg == -1) { throw new ParseException(`missing adapter id in '${s}'`); } let adapterstr = null; end = StringUtil.checkQuote(s, beg); if (end === -1) { throw new ParseException(`mismatched quotes around adapter id in '${s}'`); } else if (end === 0) { end = StringUtil.findFirstOf(s, delim, beg); if (end === -1) { end = s.length; } adapterstr = s.substring(beg, end); } else { beg++; // Skip leading quote adapterstr = s.substring(beg, end); end++; // Skip trailing quote } if (end !== s.length && StringUtil.findFirstNotOf(s, delim, end) !== -1) { throw new ParseException(`invalid trailing characters after ${s.substring(0, end + 1)}' in '${s}'`); } try { adapter = StringUtil.unescapeString(adapterstr, 0, adapterstr.length); } catch (ex) { throw new ParseException(`invalid adapter id in '${s}'`, ex); } if (adapter.length === 0) { throw new ParseException(`empty adapter id in '${s}'`); } return this.createImpl(ident, facet, mode, protocol, encoding, null, adapter, propertyPrefix); } throw new ParseException(`malformed proxy '${s}'`); } createFromStream(ident, s) { // // Don't read the identity here. Operations calling this // constructor read the identity, and pass it as a parameter. // if (ident.name.length === 0 && ident.category.length === 0) { return null; } // // For compatibility with the old FacetPath. // const facetPath = StringSeqHelper.read(s); // String[] let facet; if (facetPath.length > 0) { if (facetPath.length > 1) { throw new MarshalException(`Received invalid facet path with ${facetPath.length} elements.`); } facet = facetPath[0]; } else { facet = ""; } const mode = s.readByte(); if (mode < 0 || mode > ReferenceMode.ModeLast) { throw new MarshalException(`Received invalid proxy mode ${mode}`); } s.readBool(); // ignore secure field (unused) let protocol = null; let encoding = null; if (!s.getEncoding().equals(Encoding_1_0)) { protocol = new ProtocolVersion(); protocol._read(s); encoding = new EncodingVersion(); encoding._read(s); } else { protocol = Protocol_1_0; encoding = Encoding_1_0; } let endpoints = null; // EndpointI[] let adapterId = null; const sz = s.readSize(); if (sz > 0) { endpoints = []; for (let i = 0; i < sz; i++) { endpoints[i] = this._instance.endpointFactoryManager().read(s); } } else { adapterId = s.readString(); } return this.createImpl(ident, facet, mode, protocol, encoding, endpoints, adapterId, null); } setDefaultRouter(defaultRouter) { if (this._defaultRouter === null ? defaultRouter === null : this._defaultRouter.equals(defaultRouter)) { return this; } const factory = new ReferenceFactory(this._instance, this._communicator); factory._defaultLocator = this._defaultLocator; factory._defaultRouter = defaultRouter; return factory; } getDefaultRouter() { return this._defaultRouter; } setDefaultLocator(defaultLocator) { if (this._defaultLocator === null ? defaultLocator === null : this._defaultLocator.equals(defaultLocator)) { return this; } const factory = new ReferenceFactory(this._instance, this._communicator); factory._defaultRouter = this._defaultRouter; factory._defaultLocator = defaultLocator; return factory; } getDefaultLocator() { return this._defaultLocator; } createImpl(ident, facet, mode, protocol, encoding, endpoints, adapterId, propertyPrefix) { const defaultsAndOverrides = this._instance.defaultsAndOverrides(); // // Default local proxy options. // let locatorInfo = null; if (this._defaultLocator !== null) { if (!this._defaultLocator._getReference().getEncoding().equals(encoding)) { locatorInfo = this._instance.locatorManager().find(this._defaultLocator.ice_encodingVersion(encoding)); } else { locatorInfo = this._instance.locatorManager().find(this._defaultLocator); } } let routerInfo = this._instance.routerManager().find(this._defaultRouter); let cacheConnection = true; let endpointSelection = defaultsAndOverrides.defaultEndpointSelection; let locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout; let invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout; let context = null; // // Override the defaults with the proxy properties if a property prefix is defined. // if (propertyPrefix !== null && propertyPrefix.length > 0) { const properties = this._instance.initializationData().properties; Properties.validatePropertiesWithPrefix(propertyPrefix, properties, PropertyNames.ProxyProps); let property = propertyPrefix + ".Locator"; const locator = LocatorPrx.uncheckedCast(this._communicator.propertyToProxy(property)); if (locator !== null) { if (!locator._getReference().getEncoding().equals(encoding)) { locatorInfo = this._instance.locatorManager().find(locator.ice_encodingVersion(encoding)); } else { locatorInfo = this._instance.locatorManager().find(locator); } } property = propertyPrefix + ".Router"; const router = RouterPrx.uncheckedCast(this._communicator.propertyToProxy(property)); if (router !== null) { if (propertyPrefix.endsWith("Router")) { this._instance .initializationData() .logger.warning( "`" + property + "=" + properties.getProperty(property) + "': cannot set a router on a router; setting ignored", ); } else { routerInfo = this._instance.routerManager().find(router); } } property = propertyPrefix + ".ConnectionCached"; cacheConnection = properties.getPropertyAsIntWithDefault(property, cacheConnection ? 1 : 0) > 0; property = propertyPrefix + ".EndpointSelection"; if (properties.getProperty(property).length > 0) { const type = properties.getProperty(property); if (type == "Random") { endpointSelection = EndpointSelectionType.Random; } else if (type == "Ordered") { endpointSelection = EndpointSelectionType.Ordered; } else { throw new ParseException(`illegal value '${type}'; expected 'Random' or 'Ordered'`); } } property = propertyPrefix + ".LocatorCacheTimeout"; let value = properties.getProperty(property); if (value.length !== 0) { locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout); if (locatorCacheTimeout < -1) { locatorCacheTimeout = -1; this._instance .initializationData() .logger.warning( "invalid value for" + property + "`" + properties.getProperty(property) + "': defaulting to -1", ); } } property = propertyPrefix + ".InvocationTimeout"; value = properties.getProperty(property); if (value.length !== 0) { invocationTimeout = properties.getPropertyAsIntWithDefault(property, invocationTimeout); if (invocationTimeout < 1 && invocationTimeout !== -1) { invocationTimeout = -1; this._instance .initializationData() .logger.warning( "invalid value for" + property + "`" + properties.getProperty(property) + "': defaulting to -1", ); } } property = propertyPrefix + ".Context."; const contexts = properties.getPropertiesForPrefix(property); if (contexts.size > 0) { context = new Map(); for (const [key, value] of contexts) { context.set(key.substring(property.length), value); } } } // // Create new reference // return new RoutableReference( this._instance, this._communicator, ident, facet, mode, protocol, encoding, endpoints, adapterId, locatorInfo, routerInfo, cacheConnection, endpointSelection, locatorCacheTimeout, invocationTimeout, context, ); } } |