Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: run multi framework in one process #925

Merged
merged 10 commits into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: origin case
  • Loading branch information
czy88840616 committed Mar 17, 2021
commit b646967b7917bc1da32e022378f374939b10ece4
2 changes: 1 addition & 1 deletion packages/core/src/context/resolverHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class ResolverHandler implements IResolverHandler {
if (prop && getterHandler) {
if (prop.propertyName) {
Object.defineProperty(instance, prop.propertyName, {
get: () => getterHandler(prop.key, instance),
get: () => getterHandler(prop.key, prop.meta, instance),
configurable: true, // 继承对象有可能会有相同属性,这里需要配置成 true
enumerable: true,
});
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export interface IObjectDefinitionMetadata {
export interface FrameworkDecoratorMetadata {
key: string;
propertyName: string;
meta: any;
}

export interface IObjectCreator {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/baseFramework.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@ describe('/test/baseFramework.test.ts', () => {
callback(m);
});

expect(container.registry.hasObject(LIFECYCLE_IDENTIFIER_PREFIX + 'lifeCycleTest')).toBeTruthy();
expect(container.registry.hasDefinition(LIFECYCLE_IDENTIFIER_PREFIX + 'lifeCycleTest')).toBeTruthy();
await framework.stop();
expect(container.registry.hasObject(LIFECYCLE_IDENTIFIER_PREFIX + 'lifeCycleTest')).toBeFalsy();
expect(container.registry.hasDefinition(LIFECYCLE_IDENTIFIER_PREFIX + 'lifeCycleTest')).toBeFalsy();
expect(callback.withArgs('on stop').calledOnce).toBeTruthy();

resetModule(CONFIGURATION_KEY);
Expand Down
12 changes: 6 additions & 6 deletions packages/core/test/context/midwayContainer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('/test/context/midwayContainer.test.ts', () => {
loadDir: path.join(__dirname, '../fixtures/base-app-decorator/src')
});
// register handler for container
container.registerDataHandler(CONFIG_KEY, (key, target) => {
container.registerDataHandler(CONFIG_KEY, (key, meta, target) => {
assert(
target instanceof
require('../fixtures/base-app-decorator/src/lib/service')[
Expand All @@ -50,11 +50,11 @@ describe('/test/context/midwayContainer.test.ts', () => {
return 'hello';
});

container.registerDataHandler(PLUGIN_KEY, (key, target) => {
container.registerDataHandler(PLUGIN_KEY, (key, meta, target) => {
return { b: 2 };
});

container.registerDataHandler(LOGGER_KEY, (key, target) => {
container.registerDataHandler(LOGGER_KEY, (key, meta, target) => {
return console;
});

Expand Down Expand Up @@ -88,7 +88,7 @@ describe('/test/context/midwayContainer.test.ts', () => {
container.registerDataHandler(APPLICATION_KEY, () => tt);
await container.ready();
// register handler for container
container.registerDataHandler(CONFIG_KEY, (key, target) => {
container.registerDataHandler(CONFIG_KEY, (key, meta, target) => {
assert(
target instanceof
require('../fixtures/base-app-forbindapp/src/lib/service')[
Expand All @@ -98,11 +98,11 @@ describe('/test/context/midwayContainer.test.ts', () => {
return 'hello';
});

container.registerDataHandler(PLUGIN_KEY, (key, target) => {
container.registerDataHandler(PLUGIN_KEY, (key, meta, target) => {
return { b: 2 };
});

container.registerDataHandler(LOGGER_KEY, (key, target) => {
container.registerDataHandler(LOGGER_KEY, (key, meta, target) => {
return console;
});

Expand Down
12 changes: 6 additions & 6 deletions packages/core/test/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('/test/loader.test.ts', () => {
await loader.refresh();

// register handler for container
loader.registerHook(CONFIG_KEY, (key, target) => {
loader.registerHook(CONFIG_KEY, (key, meta, target) => {
assert(
target instanceof
require('./fixtures/base-app-decorator/src/lib/service')[
Expand All @@ -55,11 +55,11 @@ describe('/test/loader.test.ts', () => {
return 'hello';
});

loader.registerHook(PLUGIN_KEY, (key, target) => {
loader.registerHook(PLUGIN_KEY, (key, meta, target) => {
return { b: 2 };
});

loader.registerHook(LOGGER_KEY, (key, target) => {
loader.registerHook(LOGGER_KEY, (key, meta, target) => {
return console;
});

Expand Down Expand Up @@ -91,7 +91,7 @@ describe('/test/loader.test.ts', () => {
loader.registerHook(APPLICATION_KEY, () => tt);
await loader.refresh();
// register handler for container
loader.registerHook(CONFIG_KEY, (key, target) => {
loader.registerHook(CONFIG_KEY, (key, meta, target) => {
assert(
target instanceof
require('./fixtures/base-app-forbindapp/src/lib/service')[
Expand All @@ -101,11 +101,11 @@ describe('/test/loader.test.ts', () => {
return 'hello';
});

loader.registerHook(PLUGIN_KEY, (key, target) => {
loader.registerHook(PLUGIN_KEY, (key, meta, target) => {
return { b: 2 };
});

loader.registerHook(LOGGER_KEY, (key, target) => {
loader.registerHook(LOGGER_KEY, (key, meta, target) => {
return console;
});

Expand Down
5 changes: 4 additions & 1 deletion packages/decorator/src/framework/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ export function App(type?: MidwayFrameworkType) {
attachClassMetadata(
APPLICATION_KEY,
{
key: type,
key: APPLICATION_KEY,
propertyName: targetKey,
meta: {
type,
}
},
target
);
Expand Down