Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore committed Sep 19, 2023
1 parent 2c71715 commit 9bd8979
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
3 changes: 2 additions & 1 deletion core/core-decorator/src/decorator/MultiInstanceProto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,18 @@ export function MultiInstanceProto(param: MultiInstancePrototypeParams) {
const property: EggMultiInstancePrototypeInfo = {
...DEFAULT_PARAMS,
...param as MultiInstancePrototypeStaticParams,
className: clazz.name,
};
PrototypeUtil.setMultiInstanceStaticProperty(clazz, property);
} else if ((param as MultiInstancePrototypeCallbackParams).getObjects) {
const property: EggMultiInstanceCallbackPrototypeInfo = {
...DEFAULT_PARAMS,
...param as MultiInstancePrototypeCallbackParams,
className: clazz.name,
};
PrototypeUtil.setMultiInstanceCallbackProperty(clazz, property);
}


// './tegg/core/common-util/src/StackUtil.ts',
// './tegg/core/core-decorator/src/decorator/Prototype.ts',
// './tegg/core/core-decorator/node_modules/_reflect-metadata@0.1.13@reflect-metadata/Reflect.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export interface MultiInstancePrototypeGetObjectsContext {
}

export interface EggMultiInstancePrototypeInfo {
/**
* The class name of the object
*/
className: string;
/**
* obj init type
*/
Expand All @@ -33,6 +37,10 @@ export interface EggMultiInstancePrototypeInfo {
}

export interface EggMultiInstanceCallbackPrototypeInfo {
/**
* The class name of the object
*/
className: string;
/**
* obj init type
*/
Expand Down
8 changes: 4 additions & 4 deletions core/core-decorator/src/model/EggPrototypeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export interface EggPrototypeInfo {
* egg object name
*/
name: EggPrototypeName;
/**
* The class name of the object
*/
className: string;
/**
* obj init type
*/
Expand All @@ -26,8 +30,4 @@ export interface EggPrototypeInfo {
* EggPrototype qualifiers
*/
qualifiers?: QualifierInfo[];
/**
* The class name of the object
*/
className?: string;
}
1 change: 1 addition & 0 deletions core/metadata/src/factory/EggPrototypeCreatorFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class EggPrototypeCreatorFactory {
initType: multiInstanceProtoInfo.initType,
accessLevel: multiInstanceProtoInfo.accessLevel,
qualifiers: obj.qualifiers,
className: multiInstanceProtoInfo.className,
});
}
} else {
Expand Down
3 changes: 3 additions & 0 deletions core/metadata/src/impl/EggPrototypeBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class EggPrototypeBuilder {
private injectObjects: Array<InjectObject> = [];
private loadUnit: LoadUnit;
private qualifiers: QualifierInfo[] = [];
private className: string;

static create(ctx: EggPrototypeLifecycleContext): EggPrototype {
const { clazz, loadUnit } = ctx;
Expand All @@ -48,6 +49,7 @@ export class EggPrototypeBuilder {
const builder = new EggPrototypeBuilder();
builder.clazz = clazz;
builder.name = ctx.prototypeInfo.name;
builder.className = ctx.prototypeInfo.className;
builder.initType = ctx.prototypeInfo.initType;
builder.accessLevel = ctx.prototypeInfo.accessLevel;
builder.filepath = filepath!;
Expand Down Expand Up @@ -131,6 +133,7 @@ export class EggPrototypeBuilder {
injectObjectProtos,
this.loadUnit.id,
this.qualifiers,
this.className,
);
}
}
Expand Down
3 changes: 3 additions & 0 deletions core/metadata/src/impl/EggPrototypeImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class EggPrototypeImpl implements EggPrototype {
readonly accessLevel: AccessLevel;
readonly injectObjects: InjectObjectProto[];
readonly loadUnitId: Id;
readonly className: string;

constructor(
id: string,
Expand All @@ -31,6 +32,7 @@ export class EggPrototypeImpl implements EggPrototype {
injectObjectMap: InjectObjectProto[],
loadUnitId: Id,
qualifiers: QualifierInfo[],
className: string,
) {
this.id = id;
this.clazz = clazz;
Expand All @@ -41,6 +43,7 @@ export class EggPrototypeImpl implements EggPrototype {
this.injectObjects = injectObjectMap;
this.loadUnitId = loadUnitId;
this.qualifiers = qualifiers;
this.className = className;
}

verifyQualifiers(qualifiers: QualifierInfo[]): boolean {
Expand Down
1 change: 1 addition & 0 deletions core/metadata/src/model/EggPrototype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface EggPrototype extends LifecycleObject<EggPrototypeLifecycleConte
readonly accessLevel: AccessLevel;
readonly loadUnitId: string;
readonly injectObjects: InjectObjectProto[];
readonly className: string;

/**
* get metedata for key
Expand Down
8 changes: 5 additions & 3 deletions core/metadata/test/LoadUnit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ describe('test/LoadUnit/LoadUnit.test.ts', () => {
const appRepoProto = loadUnit.getEggPrototype('appRepo', [{ attribute: InitTypeQualifierAttribute, value: ObjectInitType.SINGLETON }]);
const sprintRepoProto = loadUnit.getEggPrototype('sprintRepo', [{ attribute: InitTypeQualifierAttribute, value: ObjectInitType.SINGLETON }]);
const userRepoProto = loadUnit.getEggPrototype('userRepo', [{ attribute: InitTypeQualifierAttribute, value: ObjectInitType.SINGLETON }]);
assert(appRepoProto);
assert(sprintRepoProto);
assert(userRepoProto);
assert.strictEqual(appRepoProto.length, 1);
assert.strictEqual(appRepoProto[0].className, 'AppRepo');
assert.strictEqual(sprintRepoProto.length, 1);
assert.strictEqual(userRepoProto.length, 1);
await LoadUnitFactory.destroyLoadUnit(loadUnit);
});

Expand Down Expand Up @@ -92,6 +93,7 @@ describe('test/LoadUnit/LoadUnit.test.ts', () => {
const foo2Prototype = loadUnit.getEggPrototype('foo', [{ attribute: FOO_ATTRIBUTE, value: 'foo2' }]);
assert(foo1Prototype);
assert(foo1Prototype.length === 1);
assert.strictEqual(foo1Prototype[0].className, 'FooLogger');
assert(foo2Prototype);
assert(foo2Prototype.length === 1);
await LoadUnitFactory.destroyLoadUnit(loadUnit);
Expand Down

0 comments on commit 9bd8979

Please sign in to comment.