node-web-mvc
Version:
node spring mvc
59 lines (58 loc) • 1.9 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const MethodInterceptor_1 = __importDefault(require("../advice/MethodInterceptor"));
const MethodInvocationProceedingJoinPoint_1 = __importDefault(require("./MethodInvocationProceedingJoinPoint"));
class ReflectiveMethodInvocation {
constructor(proxy, target, method, args, interceptorOradvices) {
this.proxy = proxy;
this.target = target;
this.method = method;
this.args = args;
this.currentIndex = -1;
this.interceptors = interceptorOradvices;
this.joinPoint = new MethodInvocationProceedingJoinPoint_1.default(this, this.proxy);
}
getProxy() {
return this.proxy;
}
setArguments(...args) {
this.args = args;
}
getMethod() {
return this.method;
}
getArguments() {
return this.args;
}
getJoinPint() {
return this.joinPoint;
}
proceed() {
if (this.currentIndex >= (this.interceptors.length - 1)) {
return this.invokeJoinpoint();
}
else {
const interceptor = this.interceptors[++this.currentIndex];
if (interceptor instanceof MethodInterceptor_1.default) {
return interceptor.invoke(this);
}
else {
if (interceptor) {
// 其他暂不支持
console.warn('Unsupported Interceptor:', interceptor);
}
return this.proceed();
}
}
}
invokeJoinpoint() {
return this.getMethod().handler.apply(this.target, this.args);
}
getThis() {
return this.target;
}
}
exports.default = ReflectiveMethodInvocation;