Author: nbelaevski
Date: 2008-11-13 15:09:50 -0500 (Thu, 13 Nov 2008)
New Revision: 11156
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
Log:
Cleaned legacy queue code
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-13 19:51:28 UTC (rev
11155)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-13 20:09:50 UTC (rev
11156)
@@ -359,7 +359,6 @@
* }
*/
-
var EventQueueData = function(queue, query, options) {
this.queue = queue;
this.query = query;
@@ -397,51 +396,16 @@
});
-// EventQueueData.prototype.setEventData = function(query, options) {
-// this.query = query;
-// this.options = options;
-// };
-//
-// EventQueueData.prototype.increaseEventCounter = function() {
-// this.eventsCount++;
-// };
-//
-// EventQueueData.prototype.executeDelay = function() {
-// var delay = this.options.requestDelay;
-// LOG.debug("Queue will wait " + (delay || 0) + "ms before
submit");
-//
-// if (delay) {
-// var _this = this;
-//
-// this.timerId = setTimeout(function() {
-// try {
-// _this.delayPassed = true;
-// _this.queue.submit();
-// } finally {
-// _this = undefined;
-// }
-// }, delay);
-// } else {
-// this.delayPassed = true;
-// this.queue.submit();
-// }
-// };
-//
-// EventQueueData.prototype.abortDelay = function() {
-// if (this.timerId) {
-// clearTimeout(this.timerId);
-//
-// this.timerId = undefined;
-// }
-//
-// this.delayPassed = false;
-// };
-//
-// EventQueueData.prototype.submit = function() {
-// this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
-//
-// return A4J.AJAX.SubmitQuery(this.query, this.options)
-// };
+// LOG.debug("Queue will wait " + (delay || 0) + "ms before
submit");
+// LOG.debug("Similar request already in queue '" + this.name +
"'");
+// LOG.debug("After request: queue '" + this.name + "' is empty
now");
+// LOG.debug("Deleting transient queue '" + this.name + "' from
queues registry");
+// LOG.debug("After request: queue not empty, processing next event in queue
'" + this.name + "'");
+// LOG.debug("Queue '" + this.name + "' will submit request
NOW");
+// LOG.debug("Delay for request not passed yet, have to wait");
+// LOG.debug("Queue '" + this.name + "' is empty, nothing to
submit");
+// LOG.debug("Request in queue '" + this.name + "' is active now,
wait until its completion");
+// LOG.debug("New event added to queue '" + this.name + "'. Queue
requestId changed to " + requestId);
var extendOptions = function(options) {
var opts = {};
@@ -475,124 +439,15 @@
return policy;
},
- submit: function() {
- if (!this.request) {
- var queueData = this.queue[0];
-
- if (queueData) {
- if (queueData.delayPassed) {
- this.queue.shift();
- LOG.debug("Queue '" + this.name + "' will submit request
NOW");
-
- this.request = queueData.submit();
- this.request.queue = this;
- } else {
- LOG.debug("Delay for request not passed yet, have to wait");
- }
- } else {
- LOG.debug("Queue '" + this.name + "' is empty, nothing to
submit");
- }
- } else {
- LOG.debug("Request in queue '" + this.name + "' is active now,
wait until its completion");
- }
+ push: function(query, opts) {
+ var options = extendOptions.call(this, opts);
+ var queueData = new EventQueueData(this, query, options);
+
+ this.gate.push(queueData);
},
-
- push: function() {
- var dropNew = function() {
- this._requestId = undefined;
- };
- var fireNew = function(queueData) {
- this._requestId = undefined;
- queueData.submit();
- };
-
- var addToQueue = function(queueData, requestId) {
- this.queue.push(queueData);
- this._requestId = requestId;
- queueData.executeDelay();
-
- LOG.debug("New event added to queue '" + this.name + "'. Queue
requestId changed to " + requestId);
- };
-
- var removeFirst = function() {
- var nextQueueData = this.queue.shift();
- if (nextQueueData) {
- nextQueueData.abortDelay();
- }
-
- //barrier element could be removed
- //next element can be ready for submit
- this.submit();
-
- return nextQueueData;
- };
-
- return function(query, opts) {
- var options = extendOptions.call(this, opts);
- var queueData = new EventQueueData(this, query, options);
-
- this.gate.push(queueData);
-
-// var options = extendOptions.call(this, opts);
-//
-// //TODO add processing for ignoreDupResponse
-//
-// var queueData;
-//
-// var requestId = options.requestId;
-//
-// if (this.queue.length == 0 || requestId != this._requestId) {
-// queueData = new EventQueueData(this, query, options);
-//
-// if (this.getQueueSize() == this.queue.length) {
-// var oversizeBehavior = this.getSizeExceededBehavior();
-// if ('dropNext' == oversizeBehavior) {
-// removeFirst.call(this);
-// addToQueue.call(this, queueData, requestId);
-// } else if ('fireNext' == oversizeBehavior) {
-// var firstQueueData = removeFirst.call(this);
-// if (firstQueueData) {
-// firstQueueData.submit();
-// }
-// addToQueue.call(this, queueData, requestId);
-// } else if ('dropNew' == oversizeBehavior) {
-// dropNew.call(this);
-// } else if ('fireNew' == oversizeBehavior) {
-// fireNew.call(this, queueData);
-// }
-// } else {
-// addToQueue.call(this, queueData, requestId);
-// }
-// } else {
-// queueData = this.queue[this.queue.length - 1];
-// queueData.setEventData(query, options);
-// queueData.increaseEventCounter();
-//
-// queueData.abortDelay();
-// queueData.executeDelay();
-//
-// LOG.debug("Similar request already in queue '" + this.name +
"'");
-// }
- }
- }(),
-
pop: function() {
this.pipeline.submitNext()
-
-// this.request = undefined;
-//
-// if (this.queue.length == 0) {
-// LOG.debug("After request: queue '" + this.name + "' is empty
now");
-//
-// if (this._transient) {
-// LOG.debug("Deleting transient queue '" + this.name + "'
from queues registry");
-// A4J.AJAX.EventQueue.removeQueue(this.name);
-// }
-// } else {
-// LOG.debug("After request: queue not empty, processing next event in queue
'" + this.name + "'");
-// this.submit();
-// }
}
}
}();
Show replies by date