Repository: artusjs/core
Pull request #55 (2022-05-07 06:43:26)

refactor: extension renamed to lifecycle
LifeCycleHookHandler renamed to LifeCycleHook 
to fix issue https://github.com/artusjs/core/issues/52


Patch:
diff --git a/src/constraints.ts b/src/constraints.ts
index e4f995e..af5b893 100644
--- a/src/constraints.ts
+++ b/src/constraints.ts
@@ -23,10 +23,10 @@ export enum ARTUS_DEFAULT_CONFIG_ENV {
 };
 
 export const HOOK_NAME_META_PREFIX = 'hookName:';
-export const HOOK_CONSTRUCTOR_PARAMS = 'appHook:constructorParams';
-export const HOOK_CONSTRUCTOR_PARAMS_APP = 'appHook:constructorParams:app';
-export const HOOK_CONSTRUCTOR_PARAMS_CONTAINER = 'appHook:constructorParams:container';
-export const HOOK_PARAMS_CONTEXT = 'appHook:constructorParams:context';
+export const CONSTRUCTOR_PARAMS = 'constructor:params';
+export const CONSTRUCTOR_PARAMS_APP = 'constructor:params:app';
+export const CONSTRUCTOR_PARAMS_CONTAINER = 'constructor:params:container';
+export const CONSTRUCTOR_PARAMS_CONTEXT = 'constructor:params:context';
 export const HOOK_FILE_LOADER = 'appHook:fileLoader';
 export const HOOK_CONFIG_HANDLE = 'appHook:configHandle::';
 
@@ -51,7 +51,7 @@ export const EXCEPTION_FILE = 'artus-exception.yaml';
 export const DEFAULT_LOADER_LIST_WITH_ORDER = [
   'exception',
   'plugin-config',
-  'extension',
+  'lifecycle-hook-unit',
   'config',
   'plugin-meta',
   'module',
diff --git a/src/decorator.ts b/src/decorator.ts
index 6ee4b18..7ecfd13 100644
--- a/src/decorator.ts
+++ b/src/decorator.ts
@@ -1,20 +1,20 @@
 import {
-  HOOK_CONSTRUCTOR_PARAMS,
-  HOOK_CONSTRUCTOR_PARAMS_APP,
-  HOOK_CONSTRUCTOR_PARAMS_CONTAINER,
+  CONSTRUCTOR_PARAMS,
+  CONSTRUCTOR_PARAMS_APP,
+  CONSTRUCTOR_PARAMS_CONTAINER,
   HOOK_NAME_META_PREFIX,
-  HOOK_PARAMS_CONTEXT,
+  CONSTRUCTOR_PARAMS_CONTEXT,
   HOOK_FILE_LOADER,
 } from './constraints';
 
-export function ApplicationExtension(): ClassDecorator {
+export function LifecycleHookUnit(): ClassDecorator {
   return (target: any) => {
     // Ready to remove?
-    Reflect.defineMetadata(HOOK_FILE_LOADER, { loader: 'extension' }, target);
+    Reflect.defineMetadata(HOOK_FILE_LOADER, { loader: 'lifecycle-hook-unit' }, target);
   };
 };
 
-export function ApplicationHook(hookName?: string): PropertyDecorator {
+export function LifecycleHook(hookName?: string): PropertyDecorator {
   return (target: any, propertyKey: string | symbol) => {
     if (typeof propertyKey === 'symbol') {
       throw new Error(`hookName is not support symbol [${propertyKey.description}]`);
@@ -23,28 +23,28 @@ export function ApplicationHook(hookName?: string): PropertyDecorator {
   };
 };
 
-const WithApplicationExtensionParams = (tag: string): ParameterDecorator => {
+const WithConstructorParams = (tag: string): ParameterDecorator => {
   return (target: any, _propertyKey: string | symbol, parameterIndex: number) => {
-    const paramsMd = Reflect.getOwnMetadata(HOOK_CONSTRUCTOR_PARAMS, target) ?? [];
+    const paramsMd = Reflect.getOwnMetadata(CONSTRUCTOR_PARAMS, target) ?? [];
     paramsMd[parameterIndex] = tag;
     if (_propertyKey) {
-      Reflect.defineMetadata(HOOK_CONSTRUCTOR_PARAMS, paramsMd, target[_propertyKey]); // for proto
+      Reflect.defineMetadata(CONSTRUCTOR_PARAMS, paramsMd, target[_propertyKey]); // for proto
     } else {
-      Reflect.defineMetadata(HOOK_CONSTRUCTOR_PARAMS, paramsMd, target); // for constructor
+      Reflect.defineMetadata(CONSTRUCTOR_PARAMS, paramsMd, target); // for constructor
     }
   };
 }
 
 export function WithApplication(): ParameterDecorator {
-  return WithApplicationExtensionParams(HOOK_CONSTRUCTOR_PARAMS_APP);
+  return WithConstructorParams(CONSTRUCTOR_PARAMS_APP);
 }
 
 export function WithContainer(): ParameterDecorator {
-  return WithApplicationExtensionParams(HOOK_CONSTRUCTOR_PARAMS_CONTAINER);
+  return WithConstructorParams(CONSTRUCTOR_PARAMS_CONTAINER);
 }
 
 export function WithContext(): ParameterDecorator {
-  return WithApplicationExtensionParams(HOOK_PARAMS_CONTEXT);
+  return WithConstructorParams(CONSTRUCTOR_PARAMS_CONTEXT);
 }
 
 export * from './loader/decorator';
diff --git a/src/lifecycle/index.ts b/src/lifecycle/index.ts
index dab544f..3ba0421 100644
--- a/src/lifecycle/index.ts
+++ b/src/lifecycle/index.ts
@@ -1,9 +1,9 @@
 import { Constructable, Container } from '@artus/injection';
 import { Application } from '../types';
 import {
-  HOOK_CONSTRUCTOR_PARAMS,
-  HOOK_CONSTRUCTOR_PARAMS_APP,
-  HOOK_CONSTRUCTOR_PARAMS_CONTAINER,
+  CONSTRUCTOR_PARAMS,
+  CONSTRUCTOR_PARAMS_APP,
+  CONSTRUCTOR_PARAMS_CONTAINER,
   HOOK_NAME_META_PREFIX
 } from '../constraints';
 
@@ -50,12 +50,12 @@ export class LifecycleManager {
     }
   }
 
-  registerExtension(extClazz: Constructable<any>) {
+  registerHookUnit(extClazz: Constructable<any>) {
     const fnMetaKeys = Reflect.getMetadataKeys(extClazz);
-    const constructorParams = Reflect.getMetadata(HOOK_CONSTRUCTOR_PARAMS, extClazz) ?? [];
+    const constructorParams = Reflect.getMetadata(CONSTRUCTOR_PARAMS, extClazz) ?? [];
     const paramsMap = {
-      [HOOK_CONSTRUCTOR_PARAMS_APP]: this.app,
-      [HOOK_CONSTRUCTOR_PARAMS_CONTAINER]: this.container
+      [CONSTRUCTOR_PARAMS_APP]: this.app,
+      [CONSTRUCTOR_PARAMS_CONTAINER]: this.container
     };
     const extClazzInstance = new extClazz(...constructorParams.map((param) => paramsMap[param]));
     for (const fnMetaKey of fnMetaKeys) {
diff --git a/src/loader/impl/index.ts b/src/loader/impl/index.ts
index 7574e04..68ad9c1 100644
--- a/src/loader/impl/index.ts
+++ b/src/loader/impl/index.ts
@@ -1,7 +1,7 @@
 export * from './module';
 export * from './config';
 export * from './exception';
-export * from './extension';
+export * from './lifecycle';
 export * from './pluginMeta';
 export * from './pluginConfig';
 export * from './frameworkConfig';
diff --git a/src/loader/impl/extension.ts b/src/loader/impl/lifecycle.ts
similarity index 81%
rename from src/loader/impl/extension.ts
rename to src/loader/impl/lifecycle.ts
index bc9f5e8..6e5431f 100644
--- a/src/loader/impl/extension.ts
+++ b/src/loader/impl/lifecycle.ts
@@ -6,8 +6,8 @@ import { DefineLoader } from '../decorator';
 import { ManifestItem, Loader } from '../types';
 import compatibleRequire from '../../utils/compatible-require';
 
-@DefineLoader('extension')
-class ExtensionLoader implements Loader {
+@DefineLoader('lifecycle-hook-unit')
+class LifecycleLoader implements Loader {
   private container: Container;
 
   constructor(container) {
@@ -17,8 +17,8 @@ class ExtensionLoader implements Loader {
   async load(item: ManifestItem) {
     const extClazz: Constructable<ApplicationLifecycle> = await compatibleRequire(item.path);
     const lifecycleManager: LifecycleManager = this.container.get(ArtusInjectEnum.LifecycleManager);
-    lifecycleManager.registerExtension(extClazz);
+    lifecycleManager.registerHookUnit(extClazz);
   }
 }
 
-export default ExtensionLoader;
+export default LifecycleLoader;


Test patch:
diff --git a/test/fixtures/app-koa-with-ts/src/app.ts b/test/fixtures/app-koa-with-ts/src/app.ts
index 37c3f4b..ee69120 100644
--- a/test/fixtures/app-koa-with-ts/src/app.ts
+++ b/test/fixtures/app-koa-with-ts/src/app.ts
@@ -4,7 +4,7 @@ import { Container } from '@artus/injection';
 import { Context, Input } from '@artus/pipeline';
 
 import { ArtusApplication } from '../../../../src';
-import { ApplicationExtension, ApplicationHook, WithApplication, WithContainer } from '../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook, WithApplication, WithContainer } from '../../../../src/decorator';
 import { ApplicationLifecycle } from '../../../../src/types';
 
 import KoaApplication from './koaApp';
@@ -12,8 +12,8 @@ import HelloController from './controllers/hello';
 
 export let server: Server;
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   app: ArtusApplication;
   container: Container;
 
@@ -26,7 +26,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
     return this.container.get(KoaApplication);
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   async didLoad() {
     this.app.trigger.use(async (ctx: Context) => {
       const { koaCtx } = ctx.input.params;
@@ -35,7 +35,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
     });
   }
 
-  @ApplicationHook('willReady')
+  @LifecycleHook('willReady')
   setKoaMiddleware() {
     this.koaApp.use(async (koaCtx: DefaultContext) => {
       const input = new Input();
@@ -45,12 +45,12 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
     });
   }
 
-  @ApplicationHook('willReady')
+  @LifecycleHook('willReady')
   startKoaServer() {
     server = this.koaApp.listen(3000);
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   beforeClose() {
     server?.close();
   }
diff --git a/test/fixtures/app-koa-with-ts/src/bootstrap.ts b/test/fixtures/app-koa-with-ts/src/bootstrap.ts
index b0d2bbe..51bac1c 100644
--- a/test/fixtures/app-koa-with-ts/src/bootstrap.ts
+++ b/test/fixtures/app-koa-with-ts/src/bootstrap.ts
@@ -11,7 +11,7 @@ async function main() {
         path: path.resolve(__dirname, './app'),
         extname: '.ts',
         filename: 'app.ts',
-        loader: 'extension',
+        loader: 'lifecycle-hook-unit',
         source: 'app'
       },
       {
diff --git a/test/fixtures/app-koa-with-ts/src/mysql-plugin/app.ts b/test/fixtures/app-koa-with-ts/src/mysql-plugin/app.ts
index aeed69d..d1b3124 100644
--- a/test/fixtures/app-koa-with-ts/src/mysql-plugin/app.ts
+++ b/test/fixtures/app-koa-with-ts/src/mysql-plugin/app.ts
@@ -1,8 +1,8 @@
-import { ApplicationExtension, ApplicationHook } from '../../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook } from '../../../../../src/decorator';
 
-@ApplicationExtension()
+@LifecycleHookUnit()
 export default class Hook {
-  @ApplicationHook()
+  @LifecycleHook()
   async willReady() {
     console.log('MySQL Plugin will ready');
   }
diff --git a/test/fixtures/app-koa-with-ts/src/redis-plugin/app.ts b/test/fixtures/app-koa-with-ts/src/redis-plugin/app.ts
index 602a522..40aa739 100644
--- a/test/fixtures/app-koa-with-ts/src/redis-plugin/app.ts
+++ b/test/fixtures/app-koa-with-ts/src/redis-plugin/app.ts
@@ -1,8 +1,8 @@
-import { ApplicationExtension, ApplicationHook } from '../../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook } from '../../../../../src/decorator';
 
-@ApplicationExtension()
+@LifecycleHookUnit()
 export default class Hook {
-  @ApplicationHook()
+  @LifecycleHook()
   async willReady() {
     console.log('Redis Plugin will ready');
   }
diff --git a/test/fixtures/app-with-config/app.ts b/test/fixtures/app-with-config/app.ts
index 0b44664..e80c641 100644
--- a/test/fixtures/app-with-config/app.ts
+++ b/test/fixtures/app-with-config/app.ts
@@ -1,16 +1,16 @@
 import { Server } from 'http';
 import Koa from 'koa';
-import { ApplicationExtension, ApplicationHook } from '../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook } from '../../../src/decorator';
 import { ApplicationLifecycle } from '../../../src/types';
 
 let server: Server;
 const koaApp = new Koa();
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   testStr: string = 'Hello Artus';
 
-  @ApplicationHook()
+  @LifecycleHook()
   willReady() {
     koaApp.use((ctx) => {
       ctx.status = 200;
@@ -19,7 +19,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
     server = koaApp.listen(3000);
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   beforeClose() {
     server?.close();
   }
diff --git a/test/fixtures/app-with-config/bootstrap.ts b/test/fixtures/app-with-config/bootstrap.ts
index 1fd7a2c..573ee1e 100644
--- a/test/fixtures/app-with-config/bootstrap.ts
+++ b/test/fixtures/app-with-config/bootstrap.ts
@@ -11,7 +11,7 @@ async function main() {
         path: path.resolve(__dirname, './app'),
         extname: '.ts',
         filename: 'app.ts',
-        loader: 'extension',
+        loader: 'lifecycle-hook-unit',
         source: 'app'
       },
       {
diff --git a/test/fixtures/artus-application/src/plugins/artus-plugin-mysql-ob/src/app.ts b/test/fixtures/artus-application/src/plugins/artus-plugin-mysql-ob/src/app.ts
index 60eccd6..125707f 100644
--- a/test/fixtures/artus-application/src/plugins/artus-plugin-mysql-ob/src/app.ts
+++ b/test/fixtures/artus-application/src/plugins/artus-plugin-mysql-ob/src/app.ts
@@ -1,20 +1,20 @@
 import { Server } from 'http';
-import { ApplicationExtension, ApplicationHook, WithApplication } from '../../../../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook, WithApplication } from '../../../../../../../src/decorator';
 import { ApplicationLifecycle } from '../../../../../../../src/types';
 import { ArtusApplication } from '../../../../../../../src';
 import Client, { MysqlConfig } from './client';
 
 export let server: Server;
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   app: ArtusApplication;
 
   constructor(@WithApplication() app: ArtusApplication) {
     this.app = app;
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   async willReady() {
     const mysql = this.app.getContainer().get('ARTUS_MYSQL') as Client;
     await mysql.init(this.app.config.mysql as MysqlConfig);
diff --git a/test/fixtures/artus-application/src/plugins/artus-plugin-mysql-rds/src/app.ts b/test/fixtures/artus-application/src/plugins/artus-plugin-mysql-rds/src/app.ts
index 60eccd6..125707f 100644
--- a/test/fixtures/artus-application/src/plugins/artus-plugin-mysql-rds/src/app.ts
+++ b/test/fixtures/artus-application/src/plugins/artus-plugin-mysql-rds/src/app.ts
@@ -1,20 +1,20 @@
 import { Server } from 'http';
-import { ApplicationExtension, ApplicationHook, WithApplication } from '../../../../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook, WithApplication } from '../../../../../../../src/decorator';
 import { ApplicationLifecycle } from '../../../../../../../src/types';
 import { ArtusApplication } from '../../../../../../../src';
 import Client, { MysqlConfig } from './client';
 
 export let server: Server;
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   app: ArtusApplication;
 
   constructor(@WithApplication() app: ArtusApplication) {
     this.app = app;
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   async willReady() {
     const mysql = this.app.getContainer().get('ARTUS_MYSQL') as Client;
     await mysql.init(this.app.config.mysql as MysqlConfig);
diff --git a/test/fixtures/artus-application/src/plugins/artus-plugin-redis/src/app.ts b/test/fixtures/artus-application/src/plugins/artus-plugin-redis/src/app.ts
index e7287df..352edb0 100644
--- a/test/fixtures/artus-application/src/plugins/artus-plugin-redis/src/app.ts
+++ b/test/fixtures/artus-application/src/plugins/artus-plugin-redis/src/app.ts
@@ -1,20 +1,20 @@
 import { Server } from 'http';
-import { ApplicationExtension, ApplicationHook, WithApplication } from '../../../../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook, WithApplication } from '../../../../../../../src/decorator';
 import { ApplicationLifecycle } from '../../../../../../../src/types';
 import { ArtusApplication } from '../../../../../../../src';
 import Client, { RedisConfig } from './client';
 
 export let server: Server;
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   app: ArtusApplication;
 
   constructor(@WithApplication() app: ArtusApplication) {
     this.app = app;
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   async willReady() {
     const redis = this.app.getContainer().get('ARTUS_REDIS') as Client;
     await redis.init(this.app.config.redis as RedisConfig);
diff --git a/test/fixtures/exception-with-ts-yaml/app.ts b/test/fixtures/exception-with-ts-yaml/app.ts
index 6ee282c..7111502 100644
--- a/test/fixtures/exception-with-ts-yaml/app.ts
+++ b/test/fixtures/exception-with-ts-yaml/app.ts
@@ -1,16 +1,16 @@
 import { Server } from 'http';
 import Koa from 'koa';
-import { ApplicationExtension, ApplicationHook } from '../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook } from '../../../src/decorator';
 import { ApplicationLifecycle } from '../../../src/types';
 
 export let server: Server;
 const koaApp = new Koa();
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   testStr: string = 'Hello Artus';
 
-  @ApplicationHook()
+  @LifecycleHook()
   willReady() {
     koaApp.use((ctx) => {
       ctx.status = 200;
@@ -19,7 +19,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
     server = koaApp.listen(3000);
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   beforeClose() {
     server?.close();
   }
diff --git a/test/fixtures/exception-with-ts-yaml/bootstrap.ts b/test/fixtures/exception-with-ts-yaml/bootstrap.ts
index fd11c9c..1091d95 100644
--- a/test/fixtures/exception-with-ts-yaml/bootstrap.ts
+++ b/test/fixtures/exception-with-ts-yaml/bootstrap.ts
@@ -10,7 +10,7 @@ async function main() {
         path: path.resolve(__dirname, './app'),
         extname: '.ts',
         filename: 'app.ts',
-        loader: 'extension',
+        loader: 'lifecycle-hook-unit',
         source: 'app'
       },
       {
diff --git a/test/fixtures/frameworks/bar/src/http.ts b/test/fixtures/frameworks/bar/src/http.ts
index 71e46bd..49a4cbe 100644
--- a/test/fixtures/frameworks/bar/src/http.ts
+++ b/test/fixtures/frameworks/bar/src/http.ts
@@ -1,7 +1,7 @@
 import 'reflect-metadata';
 import { Context, Next } from '@artus/pipeline';
 import { Constructable } from '@artus/injection';
-import { HOOK_CONSTRUCTOR_PARAMS, HOOK_PARAMS_CONTEXT } from '../../../../../src/constraints';
+import { CONSTRUCTOR_PARAMS, CONSTRUCTOR_PARAMS_CONTEXT } from '../../../../../src/constraints';
 import { HttpTrigger } from '../../abstract/foo';
 import { Injectable, ScopeEnum } from '@artus/injection';
 
@@ -70,9 +70,9 @@ export function registerController(trigger: HttpTrigger) {
         if (req.url === `${prefix}${path}` && req.method === method) {
           const instance: any = ctx.container.get(clazz);
           const target = instance[key];
-          const params: any = Reflect.getMetadata(HOOK_CONSTRUCTOR_PARAMS, target) ?? [];
+          const params: any = Reflect.getMetadata(CONSTRUCTOR_PARAMS, target) ?? [];
           const paramsMap = {
-            [HOOK_PARAMS_CONTEXT]: ctx
+            [CONSTRUCTOR_PARAMS_CONTEXT]: ctx
           };
           ctx.output.data.content = await target.call(instance, ...params.map((param) => paramsMap[param]));
         }
diff --git a/test/fixtures/frameworks/bar/src/lifecycle.ts b/test/fixtures/frameworks/bar/src/lifecycle.ts
index cee108c..024da8a 100644
--- a/test/fixtures/frameworks/bar/src/lifecycle.ts
+++ b/test/fixtures/frameworks/bar/src/lifecycle.ts
@@ -1,5 +1,5 @@
 import { Server } from 'http';
-import { ApplicationExtension, ApplicationHook, WithApplication } from '../../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook, WithApplication } from '../../../../../src/decorator';
 import { ApplicationLifecycle } from '../../../../../src/types';
 import { ArtusApplication } from '../../../../../src';
 import { registerController } from './/http';
@@ -7,15 +7,15 @@ import { HttpTrigger } from '../../abstract/foo';
 
 export let server: Server;
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   app: ArtusApplication;
 
   constructor(@WithApplication() app: ArtusApplication) {
     this.app = app;
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   async didLoad() {
     // register controller
     registerController(this.app.trigger as HttpTrigger);
diff --git a/test/fixtures/frameworks/layer/foo/foo1/src/lifecycle.ts b/test/fixtures/frameworks/layer/foo/foo1/src/lifecycle.ts
index 6ea0e2b..bec5146 100644
--- a/test/fixtures/frameworks/layer/foo/foo1/src/lifecycle.ts
+++ b/test/fixtures/frameworks/layer/foo/foo1/src/lifecycle.ts
@@ -1,21 +1,21 @@
 import { Server } from 'http';
 import http from 'http';
-import { ApplicationExtension, ApplicationHook, WithApplication } from '../../../../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook, WithApplication } from '../../../../../../../src/decorator';
 import { ApplicationLifecycle } from '../../../../../../../src/types';
 import { Input } from '@artus/pipeline';
 import { ArtusApplication } from '../../../../../../../src';
 
 export let server: Server;
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   app: ArtusApplication;
 
   constructor(@WithApplication() app: ArtusApplication) {
     this.app = app;
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   willReady() {
     const config = this.app.config ?? {};
     const port = config.port;
@@ -28,7 +28,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
       .listen(port);
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   beforeClose() {
     server?.close();
   }
diff --git a/test/fixtures/frameworks/layer/foo/foo2/src/lifecycle.ts b/test/fixtures/frameworks/layer/foo/foo2/src/lifecycle.ts
index 6ea0e2b..bec5146 100644
--- a/test/fixtures/frameworks/layer/foo/foo2/src/lifecycle.ts
+++ b/test/fixtures/frameworks/layer/foo/foo2/src/lifecycle.ts
@@ -1,21 +1,21 @@
 import { Server } from 'http';
 import http from 'http';
-import { ApplicationExtension, ApplicationHook, WithApplication } from '../../../../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook, WithApplication } from '../../../../../../../src/decorator';
 import { ApplicationLifecycle } from '../../../../../../../src/types';
 import { Input } from '@artus/pipeline';
 import { ArtusApplication } from '../../../../../../../src';
 
 export let server: Server;
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   app: ArtusApplication;
 
   constructor(@WithApplication() app: ArtusApplication) {
     this.app = app;
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   willReady() {
     const config = this.app.config ?? {};
     const port = config.port;
@@ -28,7 +28,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
       .listen(port);
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   beforeClose() {
     server?.close();
   }
diff --git a/test/fixtures/trigger/event/app.ts b/test/fixtures/trigger/event/app.ts
index d90d701..c1fe442 100644
--- a/test/fixtures/trigger/event/app.ts
+++ b/test/fixtures/trigger/event/app.ts
@@ -1,20 +1,20 @@
 import { EventEmitter } from 'events';
 import { ArtusApplication } from '../../../../src';
-import { ApplicationExtension, ApplicationHook, WithApplication } from '../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook, WithApplication } from '../../../../src/decorator';
 import { Context, Input, Next } from '@artus/pipeline';
 import { ApplicationLifecycle } from '../../../../src/types';
 
 export let event = new EventEmitter();
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   app: ArtusApplication;
 
   constructor(@WithApplication() app: ArtusApplication) {
     this.app = app;
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   async didLoad() {
     this.app.trigger.use(async (ctx: Context, next: Next) => {
       const { input: { params: { type, payload } } } = ctx;
@@ -37,7 +37,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
     });
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   willReady() {
     event.on('e1', async payload => {
       const input = new Input();
@@ -54,7 +54,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
     });
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   beforeClose() {
     event.removeAllListeners();
   }
diff --git a/test/fixtures/trigger/event/bootstrap.ts b/test/fixtures/trigger/event/bootstrap.ts
index c04d13f..9d21830 100644
--- a/test/fixtures/trigger/event/bootstrap.ts
+++ b/test/fixtures/trigger/event/bootstrap.ts
@@ -10,7 +10,7 @@ async function main() {
         path: path.resolve(__dirname, './app'),
         extname: '.ts',
         filename: 'app.ts',
-        loader: 'extension',
+        loader: 'lifecycle-hook-unit',
         source: 'app'
       },
       {
diff --git a/test/fixtures/trigger/http/app.ts b/test/fixtures/trigger/http/app.ts
index caf28f0..18f28b0 100644
--- a/test/fixtures/trigger/http/app.ts
+++ b/test/fixtures/trigger/http/app.ts
@@ -1,20 +1,20 @@
 import http, { Server } from 'http';
 import { Context, Input } from '@artus/pipeline';
 import { ArtusApplication } from '../../../../src';
-import { ApplicationExtension, ApplicationHook, WithApplication } from '../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook, WithApplication } from '../../../../src/decorator';
 import { ApplicationLifecycle } from '../../../../src/types';
 
 export let server: Server;
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   app: ArtusApplication;
 
   constructor(@WithApplication() app: ArtusApplication) {
     this.app = app;
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   async didLoad() {
     this.app.trigger.use(async (ctx: Context) => {
       const { data } = ctx.output;
@@ -22,7 +22,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
     });
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   willReady() {
     server = http
       .createServer(async (req: http.IncomingMessage, res: http.ServerResponse) => {
@@ -33,7 +33,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
       .listen(3001)
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   beforeClose() {
     server?.close();
   }
diff --git a/test/fixtures/trigger/http/bootstrap.ts b/test/fixtures/trigger/http/bootstrap.ts
index d93ef35..aa8808d 100644
--- a/test/fixtures/trigger/http/bootstrap.ts
+++ b/test/fixtures/trigger/http/bootstrap.ts
@@ -10,7 +10,7 @@ async function main() {
         path: path.resolve(__dirname, './app'),
         extname: '.ts',
         filename: 'app.ts',
-        loader: 'extension',
+        loader: 'lifecycle-hook-unit',
         source: 'app'
       },
       {
diff --git a/test/fixtures/trigger/timer/app.ts b/test/fixtures/trigger/timer/app.ts
index d670fe7..22b3067 100644
--- a/test/fixtures/trigger/timer/app.ts
+++ b/test/fixtures/trigger/timer/app.ts
@@ -1,5 +1,5 @@
 import { ArtusApplication } from '../../../../src';
-import { ApplicationExtension, ApplicationHook, WithApplication } from '../../../../src/decorator';
+import { LifecycleHookUnit, LifecycleHook, WithApplication } from '../../../../src/decorator';
 import { Context, Input } from '@artus/pipeline';
 import { ApplicationLifecycle } from '../../../../src/types';
 
@@ -15,15 +15,15 @@ export let execution = {
   }
 };
 
-@ApplicationExtension()
-export default class ApplicationHookExtension implements ApplicationLifecycle {
+@LifecycleHookUnit()
+export default class MyLifecycle implements ApplicationLifecycle {
   app: ArtusApplication;
 
   constructor(@WithApplication() app: ArtusApplication) {
     this.app = app;
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   async didLoad() {
     this.app.trigger.use(async (ctx: Context) => {
       const { input: { params } } = ctx;
@@ -42,7 +42,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
     });
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   willReady() {
     timers.push(setInterval(async () => {
       const input = new Input();
@@ -57,7 +57,7 @@ export default class ApplicationHookExtension implements ApplicationLifecycle {
     }, 200));
   }
 
-  @ApplicationHook()
+  @LifecycleHook()
   beforeClose() {
     timers.forEach(clearInterval);
   }
diff --git a/test/fixtures/trigger/timer/bootstrap.ts b/test/fixtures/trigger/timer/bootstrap.ts
index 2367e3a..4f6ae54 100644
--- a/test/fixtures/trigger/timer/bootstrap.ts
+++ b/test/fixtures/trigger/timer/bootstrap.ts
@@ -10,7 +10,7 @@ async function main() {
         path: path.resolve(__dirname, './app'),
         extname: '.ts',
         filename: 'app.ts',
-        loader: 'extension',
+        loader: 'lifecycle-hook-unit',
         source: 'app'
       },
       {
diff --git a/test/scanner.test.ts b/test/scanner.test.ts
index 3fce73e..a1db4b5 100644
--- a/test/scanner.test.ts
+++ b/test/scanner.test.ts
@@ -16,7 +16,7 @@ describe('test/scanner.test.ts', () => {
         expect(manifest.items.filter(item => item.loader === 'plugin-config').length).toBe(1);
         expect(manifest.items.filter(item => item.loader === 'plugin-meta').length).toBe(1);
         expect(manifest.items.filter(item => item.loader === 'exception').length).toBe(1);
-        expect(manifest.items.filter(item => item.loader === 'extension').length).toBe(2);
+        expect(manifest.items.filter(item => item.loader === 'lifecycle-hook-unit').length).toBe(2);
         expect(manifest.items.filter(item => item.loader === 'config').length).toBe(1);
         expect(manifest.items.filter(item => item.loader === 'module').length).toBe(5);