import RequestContext from "../scope/RequestContext"; import {SCAN_TYPE} from "../@types/types"; import {applicationContext} from "../context/ApplicationContext"; import DiSupplier from "./DiSupplier"; import {logger} from "../logger/Logger"; export class RequestDiSupplier extends DiSupplier{ public async scopeDiSupplierWorker(rc:RequestContext, className:string):Promise { let bean:SCAN_TYPE | undefined = rc.getScopeData(className); if (!bean) { bean = applicationContext.findBean(className); } if (bean) { switch (bean.OPTION?.SCOPE) { case "singleton": return bean.CLASS case "request": let reqClass = new bean.CLASS(); rc.addScopeData(className, reqClass); return reqClass; case "prototype": let newClass = new bean.CLASS(); rc.addScopeData(className, newClass); return newClass; } } // 등록된게 없다? // 그럼 new를 해야하는데 할수가없음 -> string이니까... logger.error(`[@SCOPE.request] no bean exist : ${className}` ); return undefined; } }