@midwayjs/core 3.0.0-alpha.2 → 3.0.0-alpha.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +3 -17
  2. package/dist/baseFramework.d.ts +0 -1
  3. package/dist/baseFramework.js +36 -80
  4. package/dist/common/reflectTool.d.ts +3 -1
  5. package/dist/context/container.d.ts +49 -24
  6. package/dist/context/container.js +245 -224
  7. package/dist/context/definitionRegistry.d.ts +26 -0
  8. package/dist/context/definitionRegistry.js +124 -0
  9. package/dist/context/managedResolverFactory.d.ts +15 -19
  10. package/dist/context/managedResolverFactory.js +27 -256
  11. package/dist/context/providerWrapper.d.ts +2 -3
  12. package/dist/context/requestContainer.d.ts +1 -2
  13. package/dist/context/requestContainer.js +5 -12
  14. package/dist/context/resolverHandler.d.ts +3 -2
  15. package/dist/context/resolverHandler.js +5 -2
  16. package/dist/definitions/functionDefinition.d.ts +0 -2
  17. package/dist/definitions/functionDefinition.js +0 -6
  18. package/dist/definitions/objectCreator.js +6 -6
  19. package/dist/definitions/objectDefinition.d.ts +1 -4
  20. package/dist/definitions/objectDefinition.js +0 -8
  21. package/dist/definitions/properties.d.ts +0 -2
  22. package/dist/definitions/properties.js +5 -21
  23. package/dist/definitions/resource.js +13 -13
  24. package/dist/features/pipeline.d.ts +3 -3
  25. package/dist/features/pipeline.js +1 -1
  26. package/dist/functional/configuration.d.ts +2 -0
  27. package/dist/functional/configuration.js +10 -0
  28. package/dist/index.d.ts +2 -1
  29. package/dist/index.js +2 -23
  30. package/dist/interface.d.ts +24 -32
  31. package/dist/logger.js +4 -4
  32. package/dist/service/aspectService.js +9 -4
  33. package/dist/service/configService.d.ts +2 -2
  34. package/dist/service/configService.js +30 -18
  35. package/dist/service/environmentService.js +2 -2
  36. package/dist/service/informationService.js +4 -4
  37. package/dist/util/containerUtil.d.ts +11 -0
  38. package/dist/util/containerUtil.js +26 -0
  39. package/dist/util/contextUtil.js +2 -2
  40. package/dist/util/fileDetector.js +2 -2
  41. package/dist/util/index.js +3 -3
  42. package/dist/util/pathFileUtil.js +2 -2
  43. package/dist/util/serviceFactory.d.ts +4 -2
  44. package/dist/util/serviceFactory.js +11 -3
  45. package/dist/util/webRouterCollector.d.ts +9 -4
  46. package/dist/util/webRouterCollector.js +83 -132
  47. package/package.json +5 -4
  48. package/dist/context/applicationContext.d.ts +0 -81
  49. package/dist/context/applicationContext.js +0 -247
  50. package/dist/context/configuration.d.ts +0 -1
  51. package/dist/context/configuration.js +0 -370
  52. package/dist/context/managed.d.ts +0 -45
  53. package/dist/context/managed.js +0 -69
  54. package/dist/context/midwayContainer.d.ts +0 -1
  55. package/dist/context/midwayContainer.js +0 -695
  56. package/dist/util/staticConfig.d.ts +0 -10
  57. package/dist/util/staticConfig.js +0 -67
@@ -1,695 +0,0 @@
1
- // import {
2
- // getProviderId,
3
- // isProvide,
4
- // ObjectDefinitionOptions,
5
- // ObjectIdentifier,
6
- // PIPELINE_IDENTIFIER,
7
- // saveClassMetadata,
8
- // ScopeEnum,
9
- // PRIVATE_META_DATA_KEY,
10
- // generateProvideId,
11
- // MAIN_MODULE_KEY,
12
- // CONFIG_KEY,
13
- // ALL,
14
- // isAsyncFunction,
15
- // isClass,
16
- // isFunction,
17
- // getConstructorInject,
18
- // TAGGED_PROP,
19
- // getObjectDefProps,
20
- // INJECT_CLASS_KEY_PREFIX,
21
- // DecoratorManager,
22
- // ResolveFilter,
23
- // isRegExp,
24
- // } from '@midwayjs/decorator';
25
- // import { ContainerConfiguration } from './configuration';
26
- // import { FUNCTION_INJECT_KEY } from '../common/constants';
27
- // import {
28
- // IApplicationContext,
29
- // IConfigService,
30
- // IContainerConfiguration,
31
- // IEnvironmentService,
32
- // IInformationService,
33
- // IMidwayContainer,
34
- // IObjectDefinitionMetadata,
35
- // REQUEST_CTX_KEY,
36
- // } from '../interface';
37
- // import { MidwayConfigService } from '../service/configService';
38
- // import { MidwayEnvironmentService } from '../service/environmentService';
39
- // import { pipelineFactory } from '../features/pipeline';
40
- // import { ResolverHandler } from './resolverHandler';
41
- // import { run } from '@midwayjs/glob';
42
- // import { BaseApplicationContext } from './applicationContext';
43
- // import * as util from 'util';
44
- // import { getOwnMetadata, recursiveGetPrototypeOf } from '../common/reflectTool';
45
- // import { ObjectDefinition } from '../definitions/objectDefinition';
46
- // import { FunctionDefinition } from '../definitions/functionDefinition';
47
- // import { ManagedReference, ManagedValue } from './managed';
48
- // import { MidwayAspectService } from '../service/aspectService';
49
- //
50
- // const DEFAULT_PATTERN = ['**/**.ts', '**/**.tsx', '**/**.js'];
51
- // const DEFAULT_IGNORE_PATTERN = [
52
- // '**/**.d.ts',
53
- // '**/logs/**',
54
- // '**/run/**',
55
- // '**/public/**',
56
- // '**/app/view/**',
57
- // '**/app/views/**',
58
- // '**/app/extend/**',
59
- // '**/node_modules/**',
60
- // '**/**.test.ts',
61
- // '**/**.test.js',
62
- // '**/__test__/**',
63
- // ];
64
- //
65
- // const globalDebugLogger = util.debuglog('midway:container');
66
- // let containerIdx = 0;
67
- //
68
- // export function clearContainerCache() {
69
- // MidwayContainer.parentDefinitionMetadata = null;
70
- // MidwayContainer.parentApplicationContext = null;
71
- // }
72
- //
73
- // export class MidwayContainer
74
- // extends BaseApplicationContext
75
- // implements IMidwayContainer
76
- // {
77
- // public id: string;
78
- // private debugLogger = globalDebugLogger;
79
- // private definitionMetadataList = [];
80
- // protected resolverHandler: ResolverHandler;
81
- // // 仅仅用于兼容requestContainer的ctx
82
- // protected ctx = {};
83
- // private configurationMap: Map<string, IContainerConfiguration> = new Map();
84
- // // 特殊处理,按照 main 加载
85
- // private likeMainConfiguration: IContainerConfiguration[] = [];
86
- // protected configService: IConfigService;
87
- // protected environmentService: IEnvironmentService;
88
- // protected informationService: IInformationService;
89
- // protected aspectService;
90
- // private directoryFilterArray: ResolveFilter[] = [];
91
- // private attrMap: Map<string, any> = new Map();
92
- //
93
- // /**
94
- // * 单个进程中上一次的 applicationContext 的 registry
95
- // */
96
- // static parentDefinitionMetadata: Map<string, IObjectDefinitionMetadata[]>;
97
- // /**
98
- // * 单进程中上一次的 applicationContext
99
- // */
100
- // static parentApplicationContext: IMidwayContainer;
101
- //
102
- // constructor(baseDir: string = process.cwd(), parent?: IApplicationContext) {
103
- // super(baseDir, parent);
104
- // this.id = '00' + this.createContainerIdx();
105
- // if (!MidwayContainer.parentApplicationContext) {
106
- // MidwayContainer.parentApplicationContext = this;
107
- // }
108
- // }
109
- //
110
- // protected createContainerIdx() {
111
- // return containerIdx++;
112
- // }
113
- //
114
- // init(): void {
115
- // this.initService();
116
- //
117
- // this.resolverHandler = new ResolverHandler(
118
- // this,
119
- // this.getManagedResolverFactory()
120
- // );
121
- // // 防止直接从applicationContext.getAsync or get对象实例时依赖当前上下文信息出错
122
- // // ctx is in requestContainer
123
- // this.registerObject(REQUEST_CTX_KEY, this.ctx);
124
- // }
125
- //
126
- // initService() {
127
- // this.environmentService = new MidwayEnvironmentService();
128
- // this.configService = new MidwayConfigService(this);
129
- // this.aspectService = new MidwayAspectService(this);
130
- // }
131
- //
132
- // /**
133
- // * load directory and traverse file to find bind class
134
- // * @param opts
135
- // */
136
- // load(
137
- // opts: {
138
- // loadDir: string | string[];
139
- // pattern?: string | string[];
140
- // ignore?: string | string[];
141
- // } = { loadDir: [] }
142
- // ) {
143
- // // 添加全局白名单
144
- // this.midwayIdentifiers.push(PIPELINE_IDENTIFIER);
145
- //
146
- // this.debugLogger('main:create "Main Module" and "Main Configuration"');
147
- // // create main module configuration
148
- // const configuration = this.createConfiguration();
149
- // configuration.namespace = MAIN_MODULE_KEY;
150
- // this.debugLogger(`main:"Main Configuration" load from "${this.baseDir}"`);
151
- // configuration.load(this.baseDir);
152
- // // loadDir
153
- // this.debugLogger('main:load directory');
154
- //
155
- // // auto load cache next time when loadDirectory invoked
156
- // let loadDirKey = this.baseDir;
157
- // const loadDirs = [].concat(opts.loadDir || []);
158
- // MidwayContainer.parentDefinitionMetadata =
159
- // MidwayContainer.parentDefinitionMetadata || new Map();
160
- //
161
- // if (loadDirs.length > 0) {
162
- // loadDirKey = loadDirs.join('-');
163
- // }
164
- //
165
- // if (MidwayContainer.parentDefinitionMetadata.has(loadDirKey)) {
166
- // this.restoreDefinitions(
167
- // MidwayContainer.parentDefinitionMetadata.get(loadDirKey)
168
- // );
169
- // } else {
170
- // this.loadDirectory(opts);
171
- // // 保存元信息最新的上下文中,供其他容器复用,减少重复扫描
172
- // MidwayContainer.parentDefinitionMetadata.set(
173
- // loadDirKey,
174
- // this.getDefinitionMetaList()
175
- // );
176
- // }
177
- //
178
- // this.debugLogger('main:main configuration register import objects');
179
- // this.registerImportObjects(configuration.getImportObjects());
180
- //
181
- // // register base config hook
182
- // this.registerDataHandler(CONFIG_KEY, (key: string) => {
183
- // if (key === ALL) {
184
- // return this.getConfigService().getConfiguration();
185
- // } else {
186
- // return this.getConfigService().getConfiguration(key);
187
- // }
188
- // });
189
- // }
190
- //
191
- // // 加载模块
192
- // loadDirectory(opts: {
193
- // loadDir: string | string[];
194
- // pattern?: string | string[];
195
- // ignore?: string | string[];
196
- // namespace?: string;
197
- // }) {
198
- // const loadDirs = [].concat(opts.loadDir || []);
199
- //
200
- // for (const dir of loadDirs) {
201
- // const fileResults = run(DEFAULT_PATTERN.concat(opts.pattern || []), {
202
- // cwd: dir,
203
- // ignore: DEFAULT_IGNORE_PATTERN.concat(opts.ignore || []),
204
- // });
205
- //
206
- // for (const file of fileResults) {
207
- // this.debugLogger(`\nmain:*********** binding "${file}" ***********`);
208
- // this.debugLogger(` namespace => "${opts.namespace}"`);
209
- //
210
- // if (this.directoryFilterArray.length) {
211
- // for (const resolveFilter of this.directoryFilterArray) {
212
- // if (typeof resolveFilter.pattern === 'string') {
213
- // if (file.includes(resolveFilter.pattern)) {
214
- // const exports = resolveFilter.ignoreRequire
215
- // ? undefined
216
- // : require(file);
217
- // resolveFilter.filter(exports, file, this);
218
- // continue;
219
- // }
220
- // } else if (isRegExp(resolveFilter.pattern)) {
221
- // if ((resolveFilter.pattern as RegExp).test(file)) {
222
- // const exports = resolveFilter.ignoreRequire
223
- // ? undefined
224
- // : require(file);
225
- // resolveFilter.filter(exports, file, this);
226
- // continue;
227
- // }
228
- // }
229
- //
230
- // const exports = require(file);
231
- // // add module to set
232
- // this.bindClass(exports, opts.namespace, file);
233
- // this.debugLogger(` binding "${file}" end`);
234
- // }
235
- // } else {
236
- // const exports = require(file);
237
- // // add module to set
238
- // this.bindClass(exports, opts.namespace, file);
239
- // this.debugLogger(` binding "${file}" end`);
240
- // }
241
- // }
242
- // }
243
- // }
244
- //
245
- // bindClass(exports, namespace = '', filePath?: string) {
246
- // if (isClass(exports) || isFunction(exports)) {
247
- // this.bindModule(exports, namespace, filePath);
248
- // } else {
249
- // for (const m in exports) {
250
- // const module = exports[m];
251
- // if (isClass(module) || isFunction(module)) {
252
- // this.bindModule(module, namespace, filePath);
253
- // }
254
- // }
255
- // }
256
- // }
257
- //
258
- // bind<T>(target: T, options?: ObjectDefinitionOptions): void;
259
- // bind<T>(
260
- // identifier: ObjectIdentifier,
261
- // target: T,
262
- // options?: ObjectDefinitionOptions
263
- // ): void;
264
- // bind<T>(identifier: any, target: any, options?: any): void {
265
- // const definitionMeta = {} as IObjectDefinitionMetadata;
266
- // this.definitionMetadataList.push(definitionMeta);
267
- //
268
- // if (isClass(identifier) || isFunction(identifier)) {
269
- // options = target;
270
- // target = identifier as any;
271
- // identifier = this.getIdentifier(target);
272
- // }
273
- //
274
- // if (isClass(target)) {
275
- // definitionMeta.definitionType = 'object';
276
- // } else {
277
- // definitionMeta.definitionType = 'function';
278
- // if (!isAsyncFunction(target)) {
279
- // definitionMeta.asynchronous = false;
280
- // }
281
- // }
282
- //
283
- // definitionMeta.path = target;
284
- // definitionMeta.id = identifier;
285
- // definitionMeta.srcPath = options?.srcPath || null;
286
- // definitionMeta.namespace = options?.namespace || '';
287
- // definitionMeta.scope = options?.scope || ScopeEnum.Request;
288
- // definitionMeta.autowire = options?.isAutowire !== false;
289
- //
290
- // this.debugLogger(` bind id => [${definitionMeta.id}]`);
291
- //
292
- // // inject constructArgs
293
- // const constructorMetaData = getConstructorInject(target);
294
- // if (constructorMetaData) {
295
- // this.debugLogger(`inject constructor => length = ${target['length']}`);
296
- // definitionMeta.constructorArgs = [];
297
- // const maxLength = Math.max.apply(null, Object.keys(constructorMetaData));
298
- // for (let i = 0; i < maxLength + 1; i++) {
299
- // const propertyMeta = constructorMetaData[i];
300
- // if (propertyMeta) {
301
- // definitionMeta.constructorArgs.push({
302
- // type: 'ref',
303
- // value: propertyMeta[0].value,
304
- // args: propertyMeta[0].args,
305
- // });
306
- // } else {
307
- // definitionMeta.constructorArgs.push({
308
- // type: 'value',
309
- // value: propertyMeta?.[0].value,
310
- // });
311
- // }
312
- // }
313
- // }
314
- //
315
- // // inject properties
316
- // const props = recursiveGetPrototypeOf(target);
317
- // props.push(target);
318
- //
319
- // definitionMeta.properties = [];
320
- // definitionMeta.handlerProps = [];
321
- // for (const p of props) {
322
- // const metaData = getOwnMetadata(TAGGED_PROP, p);
323
- //
324
- // if (metaData) {
325
- // this.debugLogger(` inject properties => [${Object.keys(metaData)}]`);
326
- // for (const metaKey in metaData) {
327
- // for (const propertyMeta of metaData[metaKey]) {
328
- // definitionMeta.properties.push({
329
- // metaKey,
330
- // args: propertyMeta.args,
331
- // value: propertyMeta.value,
332
- // });
333
- // }
334
- // }
335
- // }
336
- //
337
- // const meta = getOwnMetadata(INJECT_CLASS_KEY_PREFIX, p) as any;
338
- // if (meta) {
339
- // for (const [key, vals] of meta) {
340
- // if (Array.isArray(vals)) {
341
- // for (const val of vals) {
342
- // if (
343
- // val.key !== undefined &&
344
- // val.key !== null &&
345
- // typeof val.propertyName === 'string'
346
- // ) {
347
- // definitionMeta.handlerProps.push({
348
- // handlerKey:
349
- // DecoratorManager.removeDecoratorClassKeySuffix(key),
350
- // prop: val,
351
- // });
352
- // }
353
- // }
354
- // }
355
- // }
356
- // }
357
- // }
358
- //
359
- // this.convertOptionsToDefinition(options, definitionMeta);
360
- // // 对象自定义的annotations可以覆盖默认的属性
361
- // this.registerCustomBinding(definitionMeta, target);
362
- //
363
- // // 把源信息变成真正的对象定义
364
- // this.restoreDefinition(definitionMeta);
365
- // }
366
- //
367
- // protected restoreDefinition(definitionMeta: IObjectDefinitionMetadata) {
368
- // let definition;
369
- // if (definitionMeta.definitionType === 'object') {
370
- // definition = new ObjectDefinition();
371
- // } else {
372
- // definition = new FunctionDefinition();
373
- // if (!definitionMeta.asynchronous) {
374
- // definition.asynchronous = false;
375
- // }
376
- // }
377
- //
378
- // definition.path = definitionMeta.path;
379
- // definition.id = definitionMeta.id;
380
- // definition.srcPath = definitionMeta.srcPath;
381
- // definition.namespace = definitionMeta.namespace;
382
- //
383
- // this.debugLogger(` bind id => [${definition.id}]`);
384
- //
385
- // // inject constructArgs
386
- // if (
387
- // definitionMeta.constructorArgs &&
388
- // definitionMeta.constructorArgs.length
389
- // ) {
390
- // for (const constructorInfo of definitionMeta.constructorArgs) {
391
- // if (constructorInfo.type === 'ref') {
392
- // const refManagedIns = new ManagedReference();
393
- // const name = constructorInfo.value;
394
- // refManagedIns.args = constructorInfo.args;
395
- // if (this.midwayIdentifiers.includes(name)) {
396
- // refManagedIns.name = name;
397
- // } else {
398
- // refManagedIns.name = generateProvideId(name, definition.namespace);
399
- // }
400
- // definition.constructorArgs.push(refManagedIns);
401
- // } else {
402
- // // inject empty value
403
- // const valueManagedIns = new ManagedValue();
404
- // valueManagedIns.valueType = constructorInfo.type;
405
- // valueManagedIns.value = constructorInfo.value;
406
- // definition.constructorArgs.push(valueManagedIns);
407
- // }
408
- // }
409
- // }
410
- //
411
- // // inject properties
412
- // for (const propertyMeta of definitionMeta.properties) {
413
- // const refManaged = new ManagedReference();
414
- // refManaged.args = propertyMeta.args;
415
- // if (this.midwayIdentifiers.includes(propertyMeta.value)) {
416
- // refManaged.name = propertyMeta.value;
417
- // } else {
418
- // refManaged.name = generateProvideId(
419
- // propertyMeta.value,
420
- // definition.namespace
421
- // );
422
- // }
423
- // definition.properties.set(propertyMeta.metaKey, refManaged);
424
- // }
425
- //
426
- // definition.asynchronous = definitionMeta.asynchronous;
427
- // definition.initMethod = definitionMeta.initMethod;
428
- // definition.destroyMethod = definitionMeta.destroyMethod;
429
- // definition.scope = definitionMeta.scope;
430
- // definition.autowire = definitionMeta.autowire;
431
- // definition.handlerProps = definitionMeta.handlerProps;
432
- //
433
- // this.registerDefinition(definitionMeta.id, definition);
434
- // }
435
- //
436
- // protected restoreDefinitions(definitionMetadataList) {
437
- // if (definitionMetadataList && definitionMetadataList.length) {
438
- // for (const definitionMeta of definitionMetadataList) {
439
- // this.restoreDefinition(definitionMeta);
440
- // }
441
- // }
442
- // }
443
- //
444
- // protected getDefinitionMetaList() {
445
- // return this.definitionMetadataList;
446
- // }
447
- //
448
- // protected bindModule(module, namespace = '', filePath?: string) {
449
- // if (isClass(module)) {
450
- // const providerId = isProvide(module) ? getProviderId(module) : null;
451
- // if (providerId) {
452
- // if (namespace) {
453
- // saveClassMetadata(
454
- // PRIVATE_META_DATA_KEY,
455
- // { namespace, providerId, srcPath: filePath },
456
- // module
457
- // );
458
- // }
459
- // this.bind(generateProvideId(providerId, namespace), module, {
460
- // namespace,
461
- // srcPath: filePath,
462
- // });
463
- // } else {
464
- // // no provide or js class must be skip
465
- // }
466
- // } else {
467
- // const info: {
468
- // id: ObjectIdentifier;
469
- // provider: (context?: IApplicationContext) => any;
470
- // scope?: ScopeEnum;
471
- // isAutowire?: boolean;
472
- // } = module[FUNCTION_INJECT_KEY];
473
- // if (info && info.id) {
474
- // if (!info.scope) {
475
- // info.scope = ScopeEnum.Request;
476
- // }
477
- // this.bind(generateProvideId(info.id, namespace), module, {
478
- // scope: info.scope,
479
- // isAutowire: info.isAutowire,
480
- // namespace,
481
- // srcPath: filePath,
482
- // });
483
- // }
484
- // }
485
- // }
486
- //
487
- // createChild(baseDir?: string): IMidwayContainer {
488
- // return new MidwayContainer(baseDir || this.baseDir, this);
489
- // }
490
- //
491
- // registerDataHandler(handlerType: string, handler: (...args) => any) {
492
- // this.resolverHandler.registerHandler(handlerType, handler);
493
- // }
494
- //
495
- // registerCustomBinding(objectDefinition, target) {
496
- // // @async, @init, @destroy @scope
497
- // const objDefOptions: ObjectDefinitionOptions = getObjectDefProps(target);
498
- // this.convertOptionsToDefinition(objDefOptions, objectDefinition);
499
- //
500
- // if (objectDefinition && !objectDefinition.scope) {
501
- // this.debugLogger(' @scope => request');
502
- // objectDefinition.scope = ScopeEnum.Request;
503
- // }
504
- // }
505
- //
506
- // registerObject(identifier: ObjectIdentifier, target: any) {
507
- // this.midwayIdentifiers.push(identifier);
508
- // if (this?.getCurrentNamespace()) {
509
- // if (this?.getCurrentNamespace() === MAIN_MODULE_KEY) {
510
- // // 如果是 main,则同步 alias 到所有的 namespace
511
- // for (const value of this.configurationMap.values()) {
512
- // if (value.namespace !== MAIN_MODULE_KEY) {
513
- // const key =
514
- // identifier.indexOf(value.namespace + ':') > -1
515
- // ? identifier
516
- // : value.namespace + ':' + identifier;
517
- // super.registerObject(key, target);
518
- // }
519
- // }
520
- // } else {
521
- // const key =
522
- // identifier.indexOf(this.getCurrentNamespace() + ':') > -1
523
- // ? identifier
524
- // : this.getCurrentNamespace() + ':' + identifier;
525
- // identifier = key;
526
- // }
527
- // }
528
- // return super.registerObject(identifier, target);
529
- // }
530
- //
531
- // createConfiguration(): IContainerConfiguration {
532
- // return new ContainerConfiguration(this);
533
- // }
534
- //
535
- // addConfiguration(configuration: IContainerConfiguration) {
536
- // if (configuration.namespace === '') {
537
- // this.likeMainConfiguration.push(configuration);
538
- // } else {
539
- // this.configurationMap.set(configuration.packageName, configuration);
540
- // }
541
- // }
542
- //
543
- // containsConfiguration(namespace: string): boolean {
544
- // return this.configurationMap.has(namespace);
545
- // }
546
- //
547
- // getConfigService() {
548
- // return this.configService;
549
- // }
550
- //
551
- // getEnvironmentService() {
552
- // return this.environmentService;
553
- // }
554
- //
555
- // getInformationService() {
556
- // return this.informationService;
557
- // }
558
- //
559
- // setInformationService(informationService) {
560
- // this.informationService = informationService;
561
- // }
562
- //
563
- // getAspectService() {
564
- // return this.aspectService;
565
- // }
566
- //
567
- // getCurrentEnv() {
568
- // return this.environmentService.getCurrentEnvironment();
569
- // }
570
- //
571
- // protected getCurrentNamespace(): string {
572
- // return '';
573
- // }
574
- //
575
- // resolve<T>(target: T): T {
576
- // const tempContainer = new MidwayContainer();
577
- // tempContainer.bind<T>(target);
578
- // tempContainer.parent = this;
579
- // return tempContainer.get<T>(target);
580
- // }
581
- //
582
- // get<T>(identifier: any, args?: any): T {
583
- // if (typeof identifier !== 'string') {
584
- // identifier = this.getIdentifier(identifier);
585
- // }
586
- // const ins: any = super.get<T>(identifier, args);
587
- // return this.aspectService.wrapperAspectToInstance(ins);
588
- // }
589
- //
590
- // async getAsync<T>(identifier: any, args?: any): Promise<T> {
591
- // if (typeof identifier !== 'string') {
592
- // identifier = this.getIdentifier(identifier);
593
- // }
594
- //
595
- // const ins: any = await super.getAsync<T>(identifier, args);
596
- // return this.aspectService.wrapperAspectToInstance(ins);
597
- // }
598
- //
599
- // protected getIdentifier(target: any) {
600
- // return getProviderId(target);
601
- // }
602
- //
603
- // async ready() {
604
- // if (this.readied) return;
605
- // await super.ready();
606
- // // 加载配置
607
- // await this.configService.load();
608
- // }
609
- //
610
- // async stop(): Promise<void> {
611
- // await super.stop();
612
- // }
613
- // /**
614
- // * 注册 importObjects
615
- // * @param objs configuration 中的 importObjects
616
- // * @param namespace namespace
617
- // */
618
- // private registerImportObjects(objs: any, namespace?: string) {
619
- // if (objs) {
620
- // const keys = Object.keys(objs);
621
- // for (const key of keys) {
622
- // if (typeof objs[key] !== undefined) {
623
- // this.registerObject(generateProvideId(key, namespace), objs[key]);
624
- // }
625
- // }
626
- // }
627
- // }
628
- // /**
629
- // * 初始化默认需要 bind 到 container 中的基础依赖
630
- // */
631
- // loadDefinitions() {
632
- // // 默认加载 pipeline
633
- // this.bindModule(pipelineFactory);
634
- // }
635
- //
636
- // private convertOptionsToDefinition(
637
- // options: ObjectDefinitionOptions,
638
- // definition: IObjectDefinitionMetadata
639
- // ) {
640
- // if (options) {
641
- // if (options.isAsync) {
642
- // this.debugLogger(' register isAsync = true');
643
- // definition.asynchronous = true;
644
- // }
645
- //
646
- // if (options.initMethod) {
647
- // this.debugLogger(` register initMethod = ${options.initMethod}`);
648
- // definition.initMethod = options.initMethod;
649
- // }
650
- //
651
- // if (options.destroyMethod) {
652
- // this.debugLogger(` register destroyMethod = ${options.destroyMethod}`);
653
- // definition.destroyMethod = options.destroyMethod;
654
- // }
655
- //
656
- // if (options.scope) {
657
- // this.debugLogger(` register scope = ${options.scope}`);
658
- // definition.scope = options.scope;
659
- // }
660
- //
661
- // if (options.constructorArgs) {
662
- // this.debugLogger(
663
- // ` register constructorArgs = ${options.constructorArgs}`
664
- // );
665
- // definition.constructorArgs = options.constructorArgs;
666
- // }
667
- //
668
- // if (options.isAutowire === false) {
669
- // this.debugLogger(` register autowire = ${options.isAutowire}`);
670
- // definition.autowire = false;
671
- // } else if (options.isAutowire === true) {
672
- // this.debugLogger(` register autowire = ${options.isAutowire}`);
673
- // definition.autowire = true;
674
- // }
675
- // }
676
- // }
677
- //
678
- // public getResolverHandler() {
679
- // return this.resolverHandler;
680
- // }
681
- //
682
- // public addDirectoryFilter(directoryFilter) {
683
- // this.directoryFilterArray =
684
- // this.directoryFilterArray.concat(directoryFilter);
685
- // }
686
- //
687
- // public setAttr(key: string, value) {
688
- // this.attrMap.set(key, value);
689
- // }
690
- //
691
- // public getAttr<T>(key: string): T {
692
- // return this.attrMap.get(key);
693
- // }
694
- // }
695
- //# sourceMappingURL=midwayContainer.js.map