UNPKG

2.77 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;
13var Symbol = require('symbol');
14
15/**
16 *
17 * @interface
18 * @param {string=} configPath
19 */
20// eslint-disable-next-line no-unused-vars
21function IApplication(configPath) {
22 if (this.constructor === IApplication.prototype.constructor) {
23 throw new AbstractClassError();
24 }
25}
26
27/**
28 * Registers an application strategy e.g. an singleton service which to be used in application contextr
29 * @param {Function} serviceCtor
30 * @param {Function} strategyCtor
31 * @returns IApplication
32 */
33// eslint-disable-next-line no-unused-vars
34IApplication.prototype.useStrategy = function(serviceCtor, strategyCtor) {
35 throw new AbstractMethodError();
36};
37
38/**
39* @param {Function} serviceCtor
40* @returns {boolean}
41*/
42// eslint-disable-next-line no-unused-vars
43IApplication.prototype.hasStrategy = function(serviceCtor) {
44 throw new AbstractMethodError();
45};
46
47/**
48 * Gets an application strategy based on the given base service type
49 * @param {Function} serviceCtor
50 * @return {*}
51 */
52// eslint-disable-next-line no-unused-vars
53IApplication.prototype.getStrategy = function(serviceCtor) {
54 throw new AbstractMethodError();
55};
56/**
57 * @returns {ConfigurationBase}
58 */
59IApplication.prototype.getConfiguration = function() {
60 throw new AbstractMethodError();
61};
62
63
64/**
65 *
66 * @interface
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};
82var applicationProperty = Symbol('application');
83/**
84 *
85 * @class
86 * @constructor
87 * @param {IApplication} app
88 */
89// eslint-disable-next-line no-unused-vars
90function ApplicationService(app) {
91 ApplicationService.super_.bind(this)(app);
92 this[applicationProperty] = app;
93}
94LangUtils.inherits(ApplicationService,IApplicationService);
95/**
96 * @returns {IApplication}
97 */
98ApplicationService.prototype.getApplication = function() {
99 return this[applicationProperty];
100};
101
102if (typeof exports !== 'undefined')
103{
104 module.exports.IApplication = IApplication;
105 module.exports.IApplicationService = IApplicationService;
106 module.exports.ApplicationService = ApplicationService;
107}
\No newline at end of file