inceptum
Version:
hipages take on the foundational library for enterprise-grade apps written in NodeJS
58 lines • 1.94 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const LogManager_1 = require("../../log/LogManager");
const Lifecycle_1 = require("./../Lifecycle");
class ObjectDefinition extends Lifecycle_1.Lifecycle {
constructor(clazz, name, logger) {
super(name || clazz.name, logger || LogManager_1.LogManager.getLogger(__filename));
this.clazz = clazz;
this.lazyLoading = true;
this.instance = null;
this.autowireCandidate = true;
this.context = null;
}
// ************************************
// Configuration methods
// ************************************
withLazyLoading(lazyLoading) {
this.assertState(Lifecycle_1.LifecycleState.NOT_STARTED);
this.lazyLoading = lazyLoading;
return this;
}
setAutowireCandidate(autowireCandidate) {
this.assertState(Lifecycle_1.LifecycleState.NOT_STARTED);
this.autowireCandidate = autowireCandidate;
return this;
}
setContext(context) {
this.assertState(Lifecycle_1.LifecycleState.NOT_STARTED);
this.context = context;
}
getContext() {
return this.context;
}
// ************************************
// Information methods
// ************************************
getProducedClass() {
return this.clazz;
}
isLazy() {
return this.lazyLoading;
}
isAutowireCandidate() {
return this.autowireCandidate;
}
copy() {
const theCopy = this.getCopyInstance();
this.copyInternalProperties(theCopy);
return theCopy;
}
copyInternalProperties(copyTo) {
copyTo.lazyLoading = this.lazyLoading;
copyTo.autowireCandidate = this.autowireCandidate;
copyTo.context = null; // The copy must not inherit the context
}
}
exports.ObjectDefinition = ObjectDefinition;
//# sourceMappingURL=ObjectDefinition.js.map