Commit 38cde22c authored by Tristan Cavelier's avatar Tristan Cavelier

Separate `classes' from `singletons'.

parent 4e099262
......@@ -17,11 +17,9 @@ module.exports = function(grunt) {
// Wrapper top
'<file_strip_banner:../../src/<%= pkg.name %>/intro.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/exceptions.js>',
// Jio wrapper top
'<file_strip_banner:../../src/<%= pkg.name %>/storages/storage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/storages/storageHandler.js>',
// Jio wrapper top
'<file_strip_banner:../../src/<%= pkg.name %>/jio.intro.js>',
// Jio Classes
'<file_strip_banner:../../src/<%= pkg.name %>/commands/command.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/getDocumentList.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/loadDocument.js>',
......@@ -35,6 +33,7 @@ module.exports = function(grunt) {
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/waitStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/job.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcement.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jio.intro.js>',
// Singletons
'<file_strip_banner:../../src/<%= pkg.name %>/activityUpdater.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcer.js>',
......
......@@ -15,7 +15,9 @@ module.exports = function(grunt) {
dist: {
src: ['<banner:meta.banner>',
'<file_strip_banner:../../src/<%= pkg.name %>/intro.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/localStorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/localstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/davstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/replicatestorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/outro.js>'],
dest: '../../lib/jio/<%= pkg.name %>.js'
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -16,7 +16,7 @@
// Tells us that the document is saved.
setTimeout (function () {
command.done();
that.done();
}, 100);
}; // end saveDocument
......@@ -30,7 +30,7 @@
'content': 'content',
'creation_date': 10000,
'last_modified': 15000};
command.done(doc);
that.done(doc);
}, 100);
}; // end loadDocument
......@@ -53,7 +53,7 @@
delete list[0].content;
delete list[1].content;
}
command.done(list);
that.done(list);
}, 100);
}; // end getDocumentList
......@@ -61,7 +61,7 @@
// Remove a document from the storage.
setTimeout (function () {
command.done();
that.done();
}, 100);
};
return that;
......@@ -80,7 +80,7 @@
// Tells us that the document is not saved.
setTimeout (function () {
command.fail({status:0,statusText:'Unknown Error',
that.fail({status:0,statusText:'Unknown Error',
message:'Unknown error.'});
}, 100);
}; // end saveDocument
......@@ -89,7 +89,7 @@
// Returns a document object containing nothing.
setTimeout(function () {
command.fail({status:0,statusText:'Unknown Error',
that.fail({status:0,statusText:'Unknown Error',
message:'Unknown error.'});
}, 100);
}; // end loadDocument
......@@ -98,7 +98,7 @@
// It returns nothing.
setTimeout(function () {
command.fail({status:0,statusText:'Unknown Error',
that.fail({status:0,statusText:'Unknown Error',
message:'Unknown error.'});
}, 100);
}; // end getDocumentList
......@@ -107,7 +107,7 @@
// Remove a document from the storage.
setTimeout (function () {
command.fail({status:0,statusText:'Unknown Error',
that.fail({status:0,statusText:'Unknown Error',
message:'Unknown error.'});
}, 100);
};
......@@ -127,7 +127,7 @@
// Document does not exists yet, create it.
setTimeout (function () {
command.done();
that.done();
}, 100);
}; // end saveDocument
......@@ -135,7 +135,7 @@
// Returns a document object containing nothing.
setTimeout(function () {
command.fail({status:404,statusText:'Not Found',
that.fail({status:404,statusText:'Not Found',
message:'Document "'+ command.getPath() +
'" not found.'});
}, 100);
......@@ -145,7 +145,7 @@
// It returns nothing.
setTimeout(function () {
command.fail({status:404,statusText:'Not Found',
that.fail({status:404,statusText:'Not Found',
message:'User list not found.'});
}, 100);
}; // end getDocumentList
......@@ -154,7 +154,7 @@
// Remove a document from the storage.
setTimeout (function () {
command.done();
that.done();
}, 100);
};
return that;
......@@ -169,33 +169,31 @@
that.setType('dummyall3tries');
priv.doJob = function (if_ok_return) {
priv.doJob = function (command,if_ok_return) {
// wait a little in order to simulate asynchronous operation
setTimeout(function () {
priv.Try3OKElseFail (priv.command.getTried(),if_ok_return);
priv.Try3OKElseFail (command.getTried(),if_ok_return);
}, 100);
};
priv.Try3OKElseFail = function (tries,if_ok_return) {
if ( tries === 3 ) {
return priv.command.done(if_ok_return);
return that.done(if_ok_return);
}
if ( tries < 3 ) {
return priv.command.fail(
return that.fail(
{message:'' + (3 - tries) + ' tries left.'});
}
if ( tries > 3 ) {
return priv.command.fail({message:'Too much tries.'});
return that.fail({message:'Too much tries.'});
}
};
that.saveDocument = function (command) {
priv.command = command;
priv.doJob ();
priv.doJob (command);
}; // end saveDocument
that.loadDocument = function (command) {
priv.command = command;
priv.doJob ({
priv.doJob (command,{
'content': 'content2',
'name': 'file',
'creation_date': 11000,
......@@ -204,19 +202,17 @@
}; // end loadDocument
that.getDocumentList = function (command) {
priv.command = command;
priv.doJob([{'name':'file',
'creation_date':10000,
'last_modified':15000},
{'name':'memo',
'creation_date':20000,
'last_modified':25000}
]);
priv.doJob(command,[{'name':'file',
'creation_date':10000,
'last_modified':15000},
{'name':'memo',
'creation_date':20000,
'last_modified':25000}
]);
}; // end getDocumentList
that.removeDocument = function (command) {
priv.command = command;
priv.doJob();
priv.doJob(command);
}; // end removeDocument
return that;
......
......@@ -7,19 +7,49 @@ var activityUpdater = (function(spec, my) {
priv.id = spec.id || 0;
priv.interval = 400;
priv.interval_id = null;
// Methods //
/**
* Update the last activity date in the localStorage.
* @method touch
*/
priv.touch = function() {
LocalOrCookieStorage.setItem ('jio/id/'+priv.id, Date.now());
};
/**
* Sets the jio id into the activity.
* @method setId
* @param {number} id The jio id.
*/
that.setId = function(id) {
priv.id = id;
};
/**
* Sets the interval delay between two updates.
* @method setIntervalDelay
* @param {number} ms In milliseconds
*/
that.setIntervalDelay = function(ms) {
priv.interval = ms;
};
/**
* Gets the interval delay.
* @method getIntervalDelay
* @return {number} The interval delay.
*/
that.getIntervalDelay = function() {
return priv.interval;
};
/**
* Starts the activity updater. It will update regulary the last activity
* date in the localStorage to show to other jio instance that this instance
* is active.
* @method start
*/
that.start = function() {
if (!priv.interval_id) {
priv.touch();
......@@ -28,12 +58,18 @@ var activityUpdater = (function(spec, my) {
}, priv.interval);
}
};
/**
* Stops the activity updater.
* @method stop
*/
that.stop = function() {
if (priv.interval_id !== null) {
clearInterval(priv.interval_id);
priv.interval_id = null;
}
};
return that;
}());
......@@ -5,6 +5,7 @@ var announcement = function(spec, my) {
// Attributes //
var callback_a = [];
var name = spec.name || '';
var announcer = spec.announcer || {};
// Methods //
that.add = function(callback) {
callback_a.push(callback);
......
......@@ -103,8 +103,8 @@ var command = function(spec, my) {
};
that.done = function(return_value) {
priv.done(return_value);
priv.respond({status:doneStatus(),value:return_value});
priv.done(return_value);
priv.end();
};
......@@ -112,17 +112,29 @@ var command = function(spec, my) {
if (priv.option.max_retry === 0 || priv.tried < priv.option.max_retry) {
priv.retry();
} else {
priv.fail(return_error);
priv.respond({status:failStatus(),error:return_error});
priv.fail(return_error);
priv.end();
}
};
that.onEndDo = function(fun) {
that.onResponseDo = function (fun) {
priv.respond = fun;
};
that.onDoneDo = function (fun) {
priv.done = fun;
};
that.onFailDo = function (fun) {
priv.fail = fun;
};
that.onEndDo = function (fun) {
priv.end = fun;
};
that.onRetryDo = function(fun) {
that.onRetryDo = function (fun) {
priv.retry = fun;
};
......@@ -144,5 +156,9 @@ var command = function(spec, my) {
return true;
};
that.clone = function () {
return command(that.serialized(), my);
};
return that;
};
......@@ -16,5 +16,23 @@ var getDocumentList = function(spec, my) {
return false;
};
var super_done = that.done;
that.done = function (res) {
var i;
if (res) {
for (i = 0; i < res.length; i+= 1) {
if (typeof res[i].last_modified !== 'number') {
res[i].last_modified =
new Date(res[i].last_modified).getTime();
}
if (typeof res[i].creation_date !== 'number') {
res[i].creation_date =
new Date(res[i].creation_date).getTime();
}
}
}
super_done(res);
};
return that;
};
......@@ -16,5 +16,17 @@ var loadDocument = function(spec, my) {
return false;
};
var super_done = that.done;
that.done = function (res) {
if (res) {
if (typeof res.last_modified !== 'number') {
res.last_modified=new Date(res.last_modified).getTime();
}
if (typeof res.creation_date !== 'number') {
res.creation_date=new Date(res.creation_date).getTime();
}
}
super_done(res);
};
return that;
};
......@@ -6,7 +6,11 @@
var priv = {};
var jio_id_array_name = 'jio/id_array';
priv.id = null;
priv.storage = jioNamespace.storage(spec);
my.jobManager = jobManager;
my.jobIdHandler = jobIdHandler;
priv.storage = jioNamespace.storage(spec, my);
// initialize //
priv.init = function() {
......@@ -68,7 +72,7 @@
* @return {boolean} true if ok, else false.
*/
that.validateStorageDescription = function(description) {
return jioNamespace.storage(description.type)(description).isValid();
return jioNamespace.storage(description, my).isValid();
};
/**
......@@ -92,10 +96,10 @@
option.max_retry = option.max_retry || 0;
jobManager.addJob(
job({storage:(specificstorage?
jioNamespace.storage(specificstorage):
jioNamespace.storage(specificstorage,my):
priv.storage),
command:saveDocument(
{path:path,content:content,option:option})}));
{path:path,content:content,option:option})},my));
};
/**
......@@ -121,10 +125,10 @@
option.metadata_only:false);
jobManager.addJob(
job({storage:(specificstorage?
jioNamespace.storage(specificstorage):
jioNamespace.storage(specificstorage,my):
priv.storage),
command:loadDocument(
{path:path,option:option})}));
{path:path,option:option})},my));
};
/**
......@@ -147,10 +151,10 @@
option.max_retry = option.max_retry || 0;
jobManager.addJob(
job({storage:(specificstorage?
jioNamespace.storage(specificstorage):
jioNamespace.storage(specificstorage,my):
priv.storage),
command:removeDocument(
{path:path,option:option})}));
{path:path,option:option})},my));
};
/**
......@@ -176,10 +180,10 @@
option.metadata_only:true);
jobManager.addJob(
job({storage:(specificstorage?
jioNamespace.storage(specificstorage):
jioNamespace.storage(specificstorage,my):
priv.storage),
command:getDocumentList(
{path:path,option:option})}));
{path:path,option:option})},my));
};
return that;
......
......@@ -3,7 +3,10 @@ var jioNamespace = (function(spec, my) {
spec = spec || {};
my = my || {};
// Attributes //
var storage_type_o = {'base':storage,'handler':storageHandler};
var storage_type_o = { // -> 'key':constructorFunction
'base': storage,
'handler': storageHandler
};
// Methods //
......
......@@ -4,7 +4,7 @@ var job = function(spec, my) {
my = my || {};
// Attributes //
var priv = {};
priv.id = jobIdHandler.nextId();
priv.id = my.jobIdHandler.nextId();
priv.command = spec.command;
priv.storage = spec.storage;
priv.status = initialStatus();
......@@ -78,7 +78,7 @@ var job = function(spec, my) {
*/
that.waitForJob = function(job) {
if (priv.status.getLabel() !== 'wait') {
priv.status = waitStatus();
priv.status = waitStatus({},my);
}
priv.status.waitForJob(job);
};
......@@ -101,7 +101,7 @@ var job = function(spec, my) {
*/
that.waitForTime = function(ms) {
if (priv.status.getLabel() !== 'wait') {
priv.status = waitStatus();
priv.status = waitStatus({},my);
}
priv.status.waitForTime(ms);
};
......@@ -148,7 +148,7 @@ var job = function(spec, my) {
that.waitForTime(ms);
});
priv.command.onEndDo (function() {
jobManager.terminateJob (that);
my.jobManager.terminateJob (that);
});
priv.command.execute (priv.storage);
};
......
......@@ -10,13 +10,32 @@ var jobManager = (function(spec, my) {
priv.interval = 200;
priv.job_a = [];
my.jobManager = that;
my.jobIdHandler = that;
// Methods //
/**
* Get the job array name in the localStorage
* @method getJobArrayName
* @return {string} The job array name
*/
priv.getJobArrayName = function() {
return job_array_name + '/' + priv.id;
};
/**
* Returns the job array from the localStorage
* @method getJobArray
* @return {array} The job array.
*/
priv.getJobArray = function() {
return LocalOrCookieStorage.getItem(priv.getJobArrayName())||[];
};
/**
* Does a backup of the job array in the localStorage.
* @method copyJobArrayToLocal
*/
priv.copyJobArrayToLocal = function() {
var new_a = [], i;
for (i = 0; i < priv.job_a.length; i+= 1) {
......@@ -25,6 +44,11 @@ var jobManager = (function(spec, my) {
LocalOrCookieStorage.setItem(priv.getJobArrayName(),new_a);
};
/**
* Removes a job from the current job array.
* @method removeJob
* @param {object} job The job object.
*/
priv.removeJob = function(job) {
var i, tmp_job_a = [];
for (i = 0; i < priv.job_a.length; i+= 1) {
......@@ -75,6 +99,12 @@ var jobManager = (function(spec, my) {
}
};
/**
* Try to restore an the inactive older jio instances.
* It will restore the on going or initial jobs from their job array
* and it will add them to this job array.
* @method restoreOldJio
*/
priv.restoreOldJio = function() {
var i, jio_id_a;
priv.lastrestore = priv.lastrestore || 0;
......@@ -86,6 +116,11 @@ var jobManager = (function(spec, my) {
priv.lastrestore = Date.now();
};
/**
* Try to restore an old jio according to an id.
* @method restoreOldJioId
* @param {number} id The jio id.
*/
priv.restoreOldJioId = function(id) {
var jio_date;
jio_date = LocalOrCookieStorage.getItem('jio/id/'+id)||0;
......@@ -96,19 +131,29 @@ var jobManager = (function(spec, my) {
}
};
/**
* Try to restore all jobs from another jio according to an id.
* @method restoreOldJobFromJioId
* @param {number} id The jio id.
*/
priv.restoreOldJobFromJioId = function(id) {
var i, jio_job_array;
jio_job_array = LocalOrCookieStorage.getItem('jio/job_array/'+id)||[];
for (i = 0; i < jio_job_array.length; i+= 1) {
var command_o = command(jio_job_array[i].command);
var command_o = command(jio_job_array[i].command, my);
if (command_o.canBeRestored()) {
that.addJob ( job(
{storage:jioNamespace.storage(jio_job_array[i].storage),
command:command_o}));
{storage:jioNamespace.storage(jio_job_array[i].storage,my),
command:command_o}, my));
}
}
};
/**
* Removes a jio instance according to an id.
* @method removeOldJioId
* @param {number} id The jio id.
*/
priv.removeOldJioId = function(id) {
var i, jio_id_a, new_a = [];
jio_id_a = LocalOrCookieStorage.getItem('jio/id_array')||[];
......@@ -121,6 +166,11 @@ var jobManager = (function(spec, my) {
LocalOrCookieStorage.deleteItem('jio/id/'+id);
};
/**
* Removes a job array from a jio instance according to an id.
* @method removeJobArrayFromJioId
* @param {number} id The jio id.
*/
priv.removeJobArrayFromJioId = function(id) {
LocalOrCookieStorage.deleteItem('jio/job_array/'+id);
};
......@@ -143,6 +193,12 @@ var jobManager = (function(spec, my) {
priv.copyJobArrayToLocal();
};
/**
* Checks if a job exists in the job array according to a job id.
* @method jobIdExists
* @param {number} id The job id.
* @return {boolean} true if exists, else false.
*/
that.jobIdExists = function(id) {
var i;
for (i = 0; i < priv.job_a.length; i+= 1) {
......@@ -153,16 +209,32 @@ var jobManager = (function(spec, my) {
return false;
};
/**
* Terminate a job. It only remove it from the job array.
* @method terminateJob
* @param {object} job The job object
*/
that.terminateJob = function(job) {
priv.removeJob(job);
priv.copyJobArrayToLocal();
};
/**
* Adds a job to the current job array.
* @method addJob
* @param {object} job The new job.
*/
that.addJob = function(job) {
var result_a = that.validateJobAccordingToJobList (priv.job_a,job);
priv.manage (job,result_a);
priv.appendJob (job,result_a);
};
/**
* Generate a result array containing action string to do with the good job.
* @method validateJobAccordingToJobList
* @param {array} job_a A job array.
* @param {object} job The new job to compare with.
* @return {array} A result array.
*/
that.validateJobAccordingToJobList = function(job_a,job) {
var i, result_a = [];
for (i = 0; i < job_a.length; i+= 1) {
......@@ -171,7 +243,16 @@ var jobManager = (function(spec, my) {
return result_a;
};
priv.manage = function(job,result_a) {
/**
* It will manage the job in order to know what to do thanks to a result
* array. The new job can be added to the job array, but it can also be
* not accepted. It is this method which can tells jobs to wait for another
* one, to replace one or to eliminate some while browsing.
* @method appendJob
* @param {object} job The job to append.
* @param {array} result_a The result array.
*/
priv.appendJob = function(job,result_a) {
var i;
if (priv.job_a.length !== result_a.length) {
throw new RangeError("Array out of bound");
......@@ -184,7 +265,7 @@ var jobManager = (function(spec, my) {
for (i = 0; i < result_a.length; i+= 1) {
switch (result_a[i].action) {
case 'eliminate':
that.eliminate(result_a[i].job);
priv.removeJob(result_a[i].job);
break;
case 'update':
result_a[i].job.update(job);
......@@ -200,16 +281,5 @@ var jobManager = (function(spec, my) {
priv.copyJobArrayToLocal();
};
that.eliminate = function(job) {
var i, tmp_a = [];
for (i = 0; i < priv.job_a.length; i+= 1) {
if (priv.job_a[i].getId() !== job.getId()) {
tmp_a.push(priv.job_a[i]);
}
}
priv.job_a = tmp_a;
priv.copyJobArrayToLocal();
};
return that;
}());
......@@ -18,6 +18,13 @@ var jobRules = (function(spec, my) {
};
// Methods //
/**
* Returns an action according the jobs given in parameters.
* @method getAction
* @param {object} job1 The already existant job.
* @param {object} job2 The job to compare with.
* @return {string} An action string.
*/
priv.getAction = function(job1,job2) {
var j1label, j2label, j1status;
j1label = job1.getCommand().getLabel();
......@@ -32,6 +39,14 @@ var jobRules = (function(spec, my) {
return that.default_action(job1,job2);
}
};
/**
* Checks if the two jobs are comparable.
* @method canCompare
* @param {object} job1 The already existant job.
* @param {object} job2 The job to compare with.
* @return {boolean} true if comparable, else false.
*/
priv.canCompare = function(job1,job2) {
var job1label = job1.getCommand().getLabel(),
job2label = job2.getCommand().getLabel();
......@@ -85,6 +100,8 @@ var jobRules = (function(spec, my) {
priv.compare[method1][method2] = rule;
};
////////////////////////////////////////////////////////////////////////////
// Adding some rules
/*
LEGEND:
- s: storage
......@@ -165,5 +182,7 @@ var jobRules = (function(spec, my) {
that.addActionRule('getDocumentList',true ,'getDocumentList',that.dontAccept);
that.addActionRule('getDocumentList',false,'getDocumentList',that.update);
// end adding rules
////////////////////////////////////////////////////////////////////////////
return that;
}());
......@@ -14,5 +14,10 @@ var jobStatus = function(spec, my) {
that.serialized = function() {
return {label:that.getLabel()};
};
that.isWaitStatus = function() {
return false;
};
return that;
};
\ No newline at end of file
};
......@@ -6,21 +6,36 @@ var waitStatus = function(spec, my) {
var priv = {};
priv.job_id_a = spec.job_id_array || [];
priv.threshold = 0;
// Methods //
/**
* Returns the label of this status.
* @method getLabel
* @return {string} The label: 'wait'.
*/
that.getLabel = function() {
return 'wait';
};
/**
* Refresh the job id array to wait.
* @method refreshJobIdArray
*/
priv.refreshJobIdArray = function() {
var tmp_job_id_a = [], i;
for (i = 0; i < priv.job_id_a.length; i+= 1) {
if (jobManager.jobIdExists(priv.job_id_a[i])) {
if (my.jobManager.jobIdExists(priv.job_id_a[i])) {
tmp_job_id_a.push(priv.job_id_a[i]);
}
}
priv.job_id_a = tmp_job_id_a;
};
/**
* The status must wait for the job end before start again.
* @method waitForJob
* @param {object} job The job to wait for.
*/
that.waitForJob = function(job) {
var i;
for (i = 0; i < priv.job_id_a.length; i+= 1) {
......@@ -30,6 +45,12 @@ var waitStatus = function(spec, my) {
}
priv.job_id_a.push(job.getId());
};
/**
* The status stops to wait for this job.
* @method dontWaitForJob
* @param {object} job The job to stop waiting for.
*/
that.dontWaitForJob = function(job) {
var i, tmp_job_id_a = [];
for (i = 0; i < priv.job_id_a.length; i+= 1) {
......@@ -40,9 +61,19 @@ var waitStatus = function(spec, my) {
priv.job_id_a = tmp_job_id_a;
};
/**
* The status must wait for some milliseconds.
* @method waitForTime
* @param {number} ms The number of milliseconds
*/
that.waitForTime = function(ms) {
priv.threshold = Date.now() + ms;
};
/**
* The status stops to wait for some time.
* @method stopWaitForTime
*/
that.stopWaitForTime = function() {
priv.threshold = 0;
};
......@@ -61,5 +92,14 @@ var waitStatus = function(spec, my) {
waitforjob:priv.job_id_a};
};
/**
* Checks if this status is waitStatus
* @method isWaitStatus
* @return {boolean} true
*/
that.isWaitStatus = function () {
return true;
};
return that;
};
......@@ -5,7 +5,6 @@ var storage = function(spec, my) {
// Attributes //
var priv = {};
priv.type = spec.type || '';
// my.jio exists
// Methods //
that.getType = function() {
......@@ -22,6 +21,8 @@ var storage = function(spec, my) {
*/
that.execute = function(command) {
that.validate(command);
that.done = command.done;
that.fail = command.fail;
command.executeOn(that);
};
......@@ -68,5 +69,8 @@ var storage = function(spec, my) {
return '';
};
that.done = function() {};
that.fail = function() {};
return that;
};
var storageHandler = function(spec, my) {
var that = storage(spec, my);
spec = spec || {};
my = my || {};
// Attributes //
var priv = {};
priv.storage_a = spec.storagelist || [];
var that = storage( spec, my );
// Methods //
/**
* It is called before the execution.
* Override this function.
* @method beforeExecute
* @param {object} command The command.
*/
that.beforeExecute = function(command) {};
/**
* Execute the command according to this storage.
* @method execute
* @param {object} command The command.
*/
that.execute = function(command) {
var i;
that.validate(command);
that.beforeExecute(command);
for(i = 0; i < priv.storage_a.length; i++) {
priv.storage_a[i].execute(command);
}
that.afterExecute(command);
};
/**
* Is is called after the execution.
* Override this function.
* @method afterExecute
* @param {object} command The command.
*/
that.afterExecute = function(command) {
command.done();
};
/**
* Returns a serialized version of this storage
* @method serialized
* @return {object} The serialized storage.
*/
that.serialized = function() {
return {type:priv.type,
storagelist:priv.storagelist};
that.addJob = function (storage,command) {
my.jobManager.addJob ( job({storage:storage, command:command}), my );
};
return that;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment