Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7862567
dispatcher.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
dispatcher.js
View Options
var
ChipManager
=
require
(
"../chip-types/chip-manager.js"
);
var
ResourceManager
=
require
(
"../chip-types/resource-manager.js"
);
var
Errors
=
require
(
"../response/error.js"
);
Dispatcher
=
function
(){
this
.
datastore_chip
=
null
;
}
Dispatcher
.
prototype
=
new
function
(){
this
.
set_datastore
=
function
(
datastore_chip
){
this
.
datastore_chip
=
datastore_chip
;
}
this
.
init
=
function
(){
this
.
set_datastore
(
ChipManager
.
get_datastore_chip
());
this
.
process_all_resource_manager_methods
();
this
.
process_all_service_methods
();
this
.
process_all_datastore_methods
();
}
this
.
start
=
function
(){
};
this
.
process_all_resource_manager_methods
=
function
(){
this
.
resources
=
{};
if
(
this
.
process_resource_manager_method
){
for
(
var
method_name
in
ResourceManager
){
if
(
ResourceManager
[
method_name
]
instanceof
Function
){
this
.
resources
[
method_name
]
=
this
.
process_resource_manager_method
(
ResourceManager
,
method_name
);
}
}
}
else
{
throw
new
Errors
.
Error
(
"Dispatcher should implement `process_resource_manager_method`"
);
}
}
this
.
process_all_service_methods
=
function
(){
if
(
this
.
process_service_method
){
var
services
=
ChipManager
.
get_chips_by_type
(
"service"
);
this
.
services
=
{};
for
(
var
service_name
in
services
){
console
.
log
(
"service_name:"
,
service_name
);
var
service
=
services
[
service_name
];
this
.
services
[
service_name
]
=
{};
for
(
var
method_name
in
service
){
if
(
service
[
method_name
]
instanceof
Function
){
this
.
services
[
service_name
][
method_name
]
=
this
.
process_service_method
(
service
,
service_name
,
method_name
);
}
}
}
}
else
{
throw
new
Errors
.
Error
(
"Dispatcher should implement `process_service_method`"
);
}
}
this
.
process_all_datastore_methods
=
function
(){
if
(
this
.
process_datastore_method
){
this
.
datastore
=
{};
for
(
var
method_name
in
this
.
datastore_chip
){
if
(
this
.
datastore_chip
[
method_name
]
instanceof
Function
){
this
.
datastore
[
method_name
]
=
this
.
process_datastore_method
(
this
.
datastore_chip
,
method_name
);
}
}
}
else
{
throw
new
Errors
.
Error
(
"Dispatcher should implement `process_datastore_method`"
);
}
}
}
module
.
exports
=
Dispatcher
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 13, 20:32 (5 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
874433
Default Alt Text
dispatcher.js (2 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment