UNPKG

2.78 kBJavaScriptView Raw
1/**
2 * @license
3 * MOST Web Framework 2.0 Codename Blueshift
4 * Copyright (c) 2017, THEMOST LP All rights reserved
5 *
6 * Use of this source code is governed by an BSD-3-Clause license that can be
7 * found in the LICENSE file at https://themost.io/license
8 */
9///
10var AbstractMethodError = require("./errors").AbstractMethodError;
11var AbstractClassError = require("./errors").AbstractClassError;
12var LangUtils = require("./utils").LangUtils;
13/**
14 *
15 * @class
16 * @abstract
17 * @param {string=} configPath
18 */
19// eslint-disable-next-line no-unused-vars
20function IApplication(configPath) {
21 if (this.constructor === IApplication.prototype.constructor) {
22 throw new AbstractClassError();
23 }
24}
25
26/**
27 * Registers an application strategy e.g. an singleton service which to be used in application contextr
28 * @param {Function} serviceCtor
29 * @param {Function} strategyCtor
30 * @returns IApplication
31 */
32// eslint-disable-next-line no-unused-vars
33IApplication.prototype.useStrategy = function(serviceCtor, strategyCtor) {
34 throw new AbstractMethodError();
35};
36
37/**
38* @param {Function} serviceCtor
39* @returns {boolean}
40*/
41// eslint-disable-next-line no-unused-vars
42IApplication.prototype.hasStrategy = function(serviceCtor) {
43 throw new AbstractMethodError();
44};
45
46/**
47 * Gets an application strategy based on the given base service type
48 * @param {Function} serviceCtor
49 * @return {*}
50 */
51// eslint-disable-next-line no-unused-vars
52IApplication.prototype.getStrategy = function(serviceCtor) {
53 throw new AbstractMethodError();
54};
55/**
56 * @returns {ConfigurationBase}
57 */
58IApplication.prototype.getConfiguration = function() {
59 throw new AbstractMethodError();
60};
61
62
63/**
64 *
65 * @class
66 * @abstract
67 * @param {IApplication} app
68 */
69// eslint-disable-next-line no-unused-vars
70function IApplicationService(app) {
71 if (this.constructor === IApplicationService.prototype.constructor) {
72 throw new AbstractClassError();
73 }
74}
75
76/**
77 * @returns {IApplication}
78 */
79IApplicationService.prototype.getApplication = function() {
80 throw new AbstractMethodError();
81};
82/**
83 *
84 * @class
85 * @constructor
86 * @param {ApplicationBase} app
87 */
88// eslint-disable-next-line no-unused-vars
89function ApplicationService(app) {
90 ApplicationService.super_.bind(this)(app);
91 Object.defineProperty(this, 'application', {
92 configurable: false,
93 enumerable: false,
94 writable: false,
95 value: app
96 });
97}
98LangUtils.inherits(ApplicationService,IApplicationService);
99/**
100 * @returns {ApplicationBase}
101 */
102ApplicationService.prototype.getApplication = function() {
103 return this.application;
104};
105
106module.exports.IApplication = IApplication;
107module.exports.IApplicationService = IApplicationService;
108module.exports.ApplicationService = ApplicationService;