/
DataMapperManager.js
50 lines (43 loc) · 1.42 KB
/
DataMapperManager.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* This file is part of the Spludo Framework.
* Copyright (c) 2009-2010 DracoBlue, http://dracoblue.net/
*
* Licensed under the terms of MIT License. For the full copyright and license
* information, please see the LICENSE file in the root folder.
*/
/**
* @class The manager for all registered data_mappers.
*
* @extends Logging
*/
DataMapperManager = function() {
this.data_mappers = {};
};
extend(true, DataMapperManager.prototype, Logging.prototype);
DataMapperManager.prototype.logging_prefix = 'DataMapperManager';
DataMapperManager.prototype.addDataMapper = function(name, data_mapper) {
this.trace("addDataMapper", arguments);
this.data_mappers[name] = data_mapper;
};
DataMapperManager.prototype.getDataMapper = function(name) {
if (this.data_mappers[name]) {
return this.data_mappers[name];
}
throw new Error("DataMapper for name " + name + " not found!");
};
DataMapperManager.prototype.shutdown = function() {
this.trace("shutdown", arguments);
for (name in this.data_mappers) {
/*
* Check wether this data_mapper has a shutdown method.
*/
if (typeof this.data_mappers[name].shutdown === "function") {
try {
this.data_mappers[name].shutdown();
} catch (e) {
this.warn("Exception when trying to shutdown data_mapper " + name);
this.warn(e);
}
}
}
};