diff options
author | Valerio Virgillito | 2012-02-03 15:58:41 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-03 15:58:41 -0800 |
commit | 796bb5ecf6b0dce700ea3c17bbda2ed49b6a84de (patch) | |
tree | 6c2e941e3e61b43f51761f831e9a9c6b8729a84b /node_modules/montage-user/data/transactionid.js | |
parent | dbd3a60478db35b0b12baa2ca54a0712d880951f (diff) | |
download | ninja-796bb5ecf6b0dce700ea3c17bbda2ed49b6a84de.tar.gz |
removing the old v0.6 montage folder and updating the references
Diffstat (limited to 'node_modules/montage-user/data/transactionid.js')
-rwxr-xr-x | node_modules/montage-user/data/transactionid.js | 230 |
1 files changed, 0 insertions, 230 deletions
diff --git a/node_modules/montage-user/data/transactionid.js b/node_modules/montage-user/data/transactionid.js deleted file mode 100755 index 330dc6c4..00000000 --- a/node_modules/montage-user/data/transactionid.js +++ /dev/null | |||
@@ -1,230 +0,0 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | /** | ||
7 | @module montage/data/transactionid | ||
8 | @requires montage/core/core | ||
9 | @requires montage/core/uuid | ||
10 | @requires montage/core/logger | ||
11 | */ | ||
12 | var Montage = require("montage").Montage; | ||
13 | var Uuid = require("core/uuid").Uuid; | ||
14 | var logger = require("core/logger").logger("transactionid"); | ||
15 | /** | ||
16 | Description TODO | ||
17 | @private | ||
18 | */ | ||
19 | var _lastTimestamp = Date.now(); | ||
20 | /** | ||
21 | Description TODO | ||
22 | @private | ||
23 | */ | ||
24 | var _lastNanos = 1; | ||
25 | /** | ||
26 | Description TODO | ||
27 | @private | ||
28 | */ | ||
29 | var _transactionManagerInstance = null; | ||
30 | /** | ||
31 | @class module:montage/data/transactionid.TransactionId | ||
32 | @extends module:montage/core/core.Montage | ||
33 | */ | ||
34 | var TransactionId = exports.TransactionId = Montage.create(Montage,/** @lends module:montage/data/transactionid.TransactionId# */ { | ||
35 | /** | ||
36 | This is used to guarantee unicity. | ||
37 | @private | ||
38 | */ | ||
39 | _uuid: { | ||
40 | serializable: true, | ||
41 | enumerable: false, | ||
42 | value: null | ||
43 | }, | ||
44 | /** | ||
45 | This is used to order transactions. | ||
46 | @private | ||
47 | */ | ||
48 | _timestamp: { | ||
49 | serializable: true, | ||
50 | enumerable: false, | ||
51 | value: null | ||
52 | }, | ||
53 | /** | ||
54 | This is used to order transactions. | ||
55 | @private | ||
56 | */ | ||
57 | _nanos: { | ||
58 | serializable: true, | ||
59 | enumerable: false, | ||
60 | value: null | ||
61 | }, | ||
62 | /** | ||
63 | Description TODO | ||
64 | @function | ||
65 | @returns itself | ||
66 | */ | ||
67 | init: { | ||
68 | serializable: false, | ||
69 | enumerable: false, | ||
70 | value: function() { | ||
71 | this._uuid = Uuid.generate(); | ||
72 | var timestamp = Date.now(); | ||
73 | if (_lastTimestamp === timestamp) { | ||
74 | _lastNanos = _lastNanos + 1; | ||
75 | } else { | ||
76 | _lastTimestamp = timestamp; | ||
77 | _lastNanos = 1 | ||
78 | } | ||
79 | this._timestamp = _lastTimestamp; | ||
80 | this._nanos = _lastNanos; | ||
81 | if (logger.isDebug) { | ||
82 | logger.debug(this, "New Transaction ID: " + this._timestamp); | ||
83 | } | ||
84 | return this; | ||
85 | } | ||
86 | }, | ||
87 | |||
88 | /** | ||
89 | Factory method used to create new Transaction IDs.<br> | ||
90 | This factory supports a delegate so that application requiring subclassing can do so easily.<br> | ||
91 | The factory delegate should implement <code>createTransactionId</code> method. | ||
92 | @function | ||
93 | @returns TransactionId.create().init() A newly initialized transaction ID. | ||
94 | */ | ||
95 | factory: { | ||
96 | value: function() { | ||
97 | if (this.factory.delegate && typeof this.factory.delegate.createTransactionId === "function") { | ||
98 | return this.factory.delegate.createTransactionId(); | ||
99 | } else { | ||
100 | return TransactionId.create().init(); | ||
101 | } | ||
102 | }}, | ||
103 | |||
104 | /** | ||
105 | Description TODO | ||
106 | @function | ||
107 | @param {Property} transactionId For comparison purposes. | ||
108 | @returns {Boolean} true If transactionId is after the target transaction ID. | ||
109 | */ | ||
110 | before: { | ||
111 | value: function(transactionId) { | ||
112 | if (this._timestamp === transactionId._timestamp) { | ||
113 | return this._nanos < transactionId._nanos; | ||
114 | } | ||
115 | return this._timestamp < transactionId._timestamp; | ||
116 | |||
117 | }}, | ||
118 | |||
119 | /** | ||
120 | Description TODO | ||
121 | @function | ||
122 | @param {Property} transactionId For comparison purposes. | ||
123 | @returns {Boolean} true If transactionId is before the target transaction ID. | ||
124 | */ | ||
125 | after: { | ||
126 | value: function(transactionId) { | ||
127 | if (this._timestamp === transactionId._timestamp) { | ||
128 | return this._nanos > transactionId._nanos; | ||
129 | } | ||
130 | return this._timestamp > transactionId._timestamp; | ||
131 | }}, | ||
132 | |||
133 | /** | ||
134 | Returns the transaction manager.<br> | ||
135 | The transaction manager is a unique object in charge of openning and closing transactions. | ||
136 | @function | ||
137 | @returns transaction manager | ||
138 | */ | ||
139 | manager: { | ||
140 | get: function() { | ||
141 | if (_transactionManagerInstance === null) { | ||
142 | _transactionManagerInstance = Object.freeze(TransactionManager.create().init()); | ||
143 | } | ||
144 | return _transactionManagerInstance; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | |||
149 | }); | ||
150 | /** | ||
151 | @class module:montage/data/transactionid.TransactionManager | ||
152 | */ | ||
153 | var TransactionManager = exports.TransactionManager = Montage.create(Montage,/** @lends module:montage/data/transactionid.TransactionManager# */ { | ||
154 | |||
155 | /** | ||
156 | Enables the trace of creation starts.<br> | ||
157 | When enabled, the transaction ID will memorize the state of the thread stack when created. | ||
158 | @type {Property} Function | ||
159 | @default {Boolean} false | ||
160 | */ | ||
161 | traceTransactionStart: { | ||
162 | serializable: false, | ||
163 | enumerable: false, | ||
164 | value: false | ||
165 | }, | ||
166 | |||
167 | /** | ||
168 | Description TODO | ||
169 | @function | ||
170 | @returns itself | ||
171 | */ | ||
172 | init: { | ||
173 | serializable: false, | ||
174 | enumerable: false, | ||
175 | value: function() { | ||
176 | return this; | ||
177 | } | ||
178 | }, | ||
179 | |||
180 | /** | ||
181 | Opens a new transaction ID for this thread. | ||
182 | @function | ||
183 | @returns null or new transaction ID | ||
184 | @throws IllegalStateException if a transaction is already open for this thread. | ||
185 | */ | ||
186 | startTransaction: { value: function() { | ||
187 | return null; | ||
188 | }}, | ||
189 | |||
190 | /** | ||
191 | Returns the current transaction ID for this thread. | ||
192 | @function | ||
193 | @returns null or current transaction ID | ||
194 | */ | ||
195 | currentTransaction: { value: function() { | ||
196 | return null; | ||
197 | }}, | ||
198 | |||
199 | /** | ||
200 | Checks if the current thread has an open transaction. | ||
201 | @function | ||
202 | @returns {Boolean} <code>true</code> if the current thread has an open transaction, <code>flase</code> otherwise. | ||
203 | */ | ||
204 | hasCurrentTransaction: { value: function() { | ||
205 | return false; | ||
206 | }}, | ||
207 | |||
208 | /** | ||
209 | Sets the transaction ID as the current transaction.<br> | ||
210 | The transaction ID can be made current only if there is no other transaction in process for the thread, and this transaction is not used by another thread. | ||
211 | @function | ||
212 | @param {Property} transactionId to use | ||
213 | @throws IllegalStateException if there is an open transaction for this thread or if there is another thread using this ID. | ||
214 | */ | ||
215 | openTransaction: { value: function(transactionId) { | ||
216 | // | ||
217 | }}, | ||
218 | |||
219 | /** | ||
220 | Retires a transaction ID of the current thread. | ||
221 | @function | ||
222 | @param {Property} transactionId The current transaction ID. | ||