torquebox-web 1.1.1-java → 2.0.0.beta1-java

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gem_hook.rb CHANGED
@@ -1,3 +1,20 @@
1
+ # Copyright 2008-2011 Red Hat, Inc, and individual contributors.
2
+ #
3
+ # This is free software; you can redistribute it and/or modify it
4
+ # under the terms of the GNU Lesser General Public License as
5
+ # published by the Free Software Foundation; either version 2.1 of
6
+ # the License, or (at your option) any later version.
7
+ #
8
+ # This software is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this software; if not, write to the Free
15
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
1
17
 
2
18
  require 'action_dispatch/session/torque_box_store'
3
19
  require 'action_controller/session/torque_box_store'
20
+
@@ -27,23 +27,23 @@ module TorqueBox
27
27
  end
28
28
 
29
29
  def call(env)
30
- load_session(env)
30
+ ServletStore.load_session(env)
31
31
  status, headers, body = @app.call(env)
32
- commit_session(env, status, headers, body)
32
+ ServletStore.commit_session(env, status, headers, body)
33
33
  return [ status, headers, body ]
34
34
  end
35
35
 
36
- def load_session(env)
36
+ def self.load_session(env)
37
37
  env['rack.session'] = load_session_data( env['java.servlet_request'].getSession(true) )
38
38
  env['rack.session.options' ] = {}
39
39
  end
40
40
 
41
- def commit_session(env, status, headers, body)
41
+ def self.commit_session(env, status, headers, body)
42
42
  session_data = env['rack.session' ]
43
- store_session_data( env['java.servlet_request'].getSession(true), session_data )
43
+ ServletStore.store_session_data( env['java.servlet_request'].getSession(true), session_data )
44
44
  end
45
45
 
46
- def load_session_data(session)
46
+ def self.load_session_data(session)
47
47
  session_data = SessionData.new
48
48
  session_data.java_session = session
49
49
  session.getAttributeNames.each do |key|
@@ -64,7 +64,7 @@ module TorqueBox
64
64
  session_data
65
65
  end
66
66
 
67
- def symbolize_keys!(session_data)
67
+ def self.symbolize_keys!(session_data)
68
68
  symbol_keys = session_data[ SYMBOL_KEYS ] || []
69
69
  keys = session_data.keys
70
70
  keys.each do |key|
@@ -74,7 +74,7 @@ module TorqueBox
74
74
  end
75
75
  end
76
76
 
77
- def store_session_data(session, session_data)
77
+ def self.store_session_data(session, session_data)
78
78
  hash = session_data.dup
79
79
  # java session shouldn't be marshalled
80
80
  hash.java_session = nil if hash.respond_to?(:java_session=)
Binary file
data/lib/torquebox-web.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module TorqueboxWeb
2
- VERSION = '1.1.1'
3
- MAVEN_VERSION = '1.1.1'
2
+ VERSION = '2.0.0.beta1'
3
+ MAVEN_VERSION = '2.0.0.beta1'
4
4
  end
5
5
  begin
6
6
  require 'java'
@@ -1,5 +1,5 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 2.1, February 1999
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 2.1, February 1999
3
3
 
4
4
  Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5
5
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -10,7 +10,7 @@
10
10
  as the successor of the GNU Library Public License, version 2, hence
11
11
  the version number 2.1.]
12
12
 
13
- Preamble
13
+ Preamble
14
14
 
15
15
  The licenses for most software are designed to take away your
16
16
  freedom to share and change it. By contrast, the GNU General Public
@@ -112,7 +112,7 @@ modification follow. Pay close attention to the difference between a
112
112
  former contains code derived from the library, whereas the latter must
113
113
  be combined with the library in order to run.
114
114
 
115
- GNU LESSER GENERAL PUBLIC LICENSE
115
+ GNU LESSER GENERAL PUBLIC LICENSE
116
116
  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
117
 
118
118
  0. This License Agreement applies to any software library or other
@@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
146
146
  on the Library (independent of the use of the Library in a tool for
147
147
  writing it). Whether that is true depends on what the Library does
148
148
  and what the program that uses the Library does.
149
-
149
+
150
150
  1. You may copy and distribute verbatim copies of the Library's
151
151
  complete source code as you receive it, in any medium, provided that
152
152
  you conspicuously and appropriately publish on each copy an
@@ -432,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
432
432
  of all derivatives of our free software and of promoting the sharing
433
433
  and reuse of software generally.
434
434
 
435
- NO WARRANTY
435
+ NO WARRANTY
436
436
 
437
437
  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438
438
  WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
@@ -455,7 +455,7 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455
455
  SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456
456
  DAMAGES.
457
457
 
458
- END OF TERMS AND CONDITIONS
458
+ END OF TERMS AND CONDITIONS
459
459
 
460
460
  How to Apply These Terms to Your New Libraries
461
461
 
@@ -500,5 +500,3 @@ necessary. Here is a sample; alter the names:
500
500
  Ty Coon, President of Vice
501
501
 
502
502
  That's all there is to it!
503
-
504
-
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torquebox-web
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.1.1
4
+ prerelease: 6
5
+ version: 2.0.0.beta1
6
6
  platform: java
7
7
  authors:
8
8
  - The TorqueBox Team
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-09 00:00:00 -04:00
14
- default_executable:
13
+ date: 2011-12-02 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: actionpack
@@ -21,7 +20,7 @@ dependencies:
21
20
  requirements:
22
21
  - - "="
23
22
  - !ruby/object:Gem::Version
24
- version: 3.0.5
23
+ version: 3.0.10
25
24
  type: :development
26
25
  version_requirements: *id001
27
26
  - !ruby/object:Gem::Dependency
@@ -32,7 +31,7 @@ dependencies:
32
31
  requirements:
33
32
  - - "="
34
33
  - !ruby/object:Gem::Version
35
- version: 2.3.0
34
+ version: 2.7.0
36
35
  type: :development
37
36
  version_requirements: *id002
38
37
  description: ""
@@ -51,12 +50,8 @@ files:
51
50
  - lib/gem_hook.rb
52
51
  - lib/action_controller/session/torque_box_store.rb
53
52
  - lib/action_dispatch/session/torque_box_store.rb
54
- - lib/generators/websockets_client/USAGE
55
- - lib/generators/websockets_client/websockets_client_generator.rb
56
- - lib/generators/websockets_client/templates/torquebox_ws_client.js
57
53
  - lib/torquebox/session/servlet_store.rb
58
- has_rdoc: true
59
- homepage: http://www.torquebox.org/gem-parent/torquebox-web/
54
+ homepage: http://www.torquebox.org/torquebox-gems-parent/torquebox-web/
60
55
  licenses:
61
56
  - lgpl
62
57
  post_install_message:
@@ -73,15 +68,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
68
  required_rubygems_version: !ruby/object:Gem::Requirement
74
69
  none: false
75
70
  requirements:
76
- - - ">="
71
+ - - ">"
77
72
  - !ruby/object:Gem::Version
78
- version: "0"
73
+ version: 1.3.1
79
74
  requirements: []
80
75
 
81
76
  rubyforge_project:
82
- rubygems_version: 1.5.1
77
+ rubygems_version: 1.8.9
83
78
  signing_key:
84
79
  specification_version: 3
85
- summary: TorqueBox Base Gem
80
+ summary: TorqueBox Web Gem
86
81
  test_files: []
87
82
 
@@ -1,17 +0,0 @@
1
- Usage:
2
- rails generate websockets_client [options]
3
-
4
- Runtime options:
5
- -f, [--force] # Overwrite files that already exist
6
- -p, [--pretend] # Run but do not make any changes
7
- -s, [--skip] # Skip files that already exist
8
- -q, [--quiet] # Suppress status output
9
-
10
- Description:
11
- Generates the websockets javascript client library for this app.
12
-
13
- Example:
14
- rails generate websockets_client
15
-
16
- This will create:
17
- public/javascripts/torquebox_ws_client.js
@@ -1,358 +0,0 @@
1
- /*
2
- * Based upon Stomp client (c) 2010 by Jeff Mesnil -- http://jmesnil.net/
3
- *
4
- */
5
-
6
- (function(window) {
7
-
8
- var Stomp = {};
9
- var TorqueBox = {};
10
- TorqueBox.WebSockets = {};
11
- TorqueBox.WebSockets.Assembly = {};
12
-
13
-
14
- TorqueBox.WebSockets.Types = {
15
-
16
- any : 0,
17
- generic : 1,
18
-
19
- registerMediaType: function(mediaName, mediaType) {
20
- this[mediaName] = mediaType;
21
- return this[mediaName];
22
- }
23
-
24
- };
25
-
26
- TorqueBox.WebSockets.Commands = {
27
- handshake : 0x01,
28
- handshake_response : 0x02,
29
- normal : 0x03
30
- };
31
-
32
- TorqueBox.WebSockets.State = {
33
- disconnected : 0,
34
- handshake : 1,
35
- ready : 2
36
- };
37
-
38
- TorqueBox.WebSockets.Frame = function(type, command, data) {
39
- this.type = type || TorqueBox.WebSockets.Types.generic;
40
- this.command = command || TorqueBox.WebSockets.Commands.normal;
41
- this.data = data;
42
- return this;
43
- }
44
-
45
- TorqueBox.WebSockets.Assembly.decode = function(message) {
46
- return new TorqueBox.WebSockets.Frame(
47
- message.charCodeAt(0),
48
- message.charCodeAt(1),
49
- message.substring(2));
50
- };
51
-
52
- TorqueBox.WebSockets.Assembly.encode = function(frame) {
53
- var encodedFrame = [ String.fromCharCode(frame.type),String.fromCharCode(frame.command), frame.data ].join('');
54
- return encodedFrame;
55
- };
56
-
57
- TorqueBox.WebSockets.client = function(id, url) {
58
-
59
- var uuid = id;
60
- var websocket = null;
61
- var state = TorqueBox.WebSockets.State.disconnected;
62
- var log = window.console;
63
- var listeners = {};
64
-
65
- var onopen = function(event) {
66
- state = TorqueBox.WebSockets.State.handshake;
67
- log.debug("Sending UUID handshake " + uuid);
68
- var frame = new TorqueBox.WebSockets.Frame(TorqueBox.WebSockets.Types.generic,
69
- TorqueBox.WebSockets.Commands.handshake,
70
- uuid);
71
- this.send(TorqueBox.WebSockets.Assembly.encode(frame));
72
- };
73
-
74
- var onerror = function(error, event) {
75
- raise('THERE IS AN ERROR');
76
- };
77
-
78
- this.addEventListener = function(event, type, callback, scopeObject) {
79
- if (!listeners[event]) listeners[event] = [];
80
- listeners[event].push({
81
- mediaType: type,
82
- fn: callback,
83
- scope: scopeObject || this
84
- });
85
- };
86
-
87
- this.connect = function() {
88
- var that = this;
89
- websocket = new WebSocket(url);
90
- websocket.onmessage = function(message) {
91
- onmessage(message, that);
92
- }
93
- websocket.onclose = function() {
94
- onclose(that);
95
- };
96
- websocket.onerror = onerror;
97
- websocket.onopen = onopen;
98
- };
99
-
100
- this.notifyListeners = function(event, type, arguments) {
101
- var evtListeners = listeners[event];
102
- for (var i = 0; i < evtListeners.length; i++) {
103
- if (evtListeners[i].mediaType == type || evtListeners[i].mediaType == TorqueBox.WebSockets.Types.any)
104
- evtListeners[i].fn.apply(evtListeners[i].scope, arguments);
105
- }
106
- };
107
-
108
- var onmessage = function(message, client) {
109
- var frame = TorqueBox.WebSockets.Assembly.decode(message.data);
110
- if (state == TorqueBox.WebSockets.State.handshake) {
111
- if (frame.data != uuid) {
112
- client.onerror("UUID received from server does not match generated UUID.");
113
- websocket.close();
114
- } // end if
115
- state = TorqueBox.WebSockets.State.ready;
116
- client.onready();
117
- } else {
118
- client.notifyListeners('onmessage', frame.type, [message]);
119
- }
120
- };
121
-
122
- var onclose = function(client) {
123
- client.state = TorqueBox.WebSockets.State.disconnected;
124
- client.onclose();
125
- }
126
-
127
- this.send = function(frame) {
128
- if (state != TorqueBox.WebSockets.State.ready) {
129
- this.onerror("The websocket client is not ready!");
130
- }
131
- var message = TorqueBox.WebSockets.Assembly.encode(frame);
132
- websocket.send(message);
133
- }
134
-
135
- this.close = function() {
136
- websocket.close();
137
- };
138
-
139
- this.onready = function() {
140
- };
141
-
142
- this.onclose = function() {
143
- };
144
-
145
- this.onerror = function(error) {
146
- log.error(error);
147
- if (state != TorqueBox.WebSockets.State.ready) {
148
- log.error("Closing web socket, since we haven't completed the handshake yet.");
149
- websocket.close(); // start again if we haven't completed the handshake.
150
- }
151
- };
152
-
153
- };
154
-
155
- Stomp.mediaType = TorqueBox.WebSockets.Types.registerMediaType('stomp', 0x02);
156
-
157
- Stomp.frame = function(command, headers, body) {
158
- return {
159
- command : command,
160
- headers : headers,
161
- body : body,
162
- toString : function() {
163
- var out = command + '\n';
164
- if (headers) {
165
- for (header in headers) {
166
- if (headers.hasOwnProperty(header)) {
167
- out = out + header + ': ' + headers[header] + '\n';
168
- }
169
- }
170
- }
171
- out = out + '\n';
172
- if (body) {
173
- out = out + body;
174
- }
175
- return out;
176
- }
177
- }
178
- };
179
-
180
- trim = function(str) {
181
- return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
182
- };
183
-
184
- Stomp.unmarshal = function(data) {
185
- var divider = data.search(/\n\n/), headerLines = data.substring(0,
186
- divider).split('\n'), command = headerLines.shift(), headers = {}, body = '';
187
-
188
- // Parse headers
189
- var line = idx = null;
190
- for ( var i = 0; i < headerLines.length; i++) {
191
- line = headerLines[i];
192
- idx = line.indexOf(':');
193
- headers[trim(line.substring(0, idx))] = trim(line
194
- .substring(idx + 1));
195
- }
196
-
197
- // Parse body, stopping at the first \0 found.
198
- // TODO: Add support for content-length header.
199
- var chr = null;
200
- for ( var i = divider + 2; i < data.length; i++) {
201
- chr = data.charAt(i);
202
- if (chr === '\0') {
203
- break;
204
- }
205
- body += chr;
206
- }
207
-
208
- return Stomp.frame(command, headers, body);
209
- };
210
-
211
- Stomp.marshal = function(command, headers, body) {
212
- return Stomp.frame(command, headers, body).toString() + '\0';
213
- };
214
-
215
- Stomp.client = function(name, url) {
216
-
217
- var that, login, passcode;
218
- var ws = null;
219
- var counter = 0; // used to index subscribers
220
- // subscription callbacks indexed by subscriber's ID
221
- var subscriptions = {};
222
- var listeners = {};
223
-
224
- var log = window.console;
225
-
226
- var notifyListeners = function(event, arguments) {
227
- var ocListeners = listeners[event];
228
- if (ocListeners) {
229
- for ( var i = 0; i < ocListeners.length; i++) {
230
- ocListeners[i].fn.apply(ocListeners[i].scope, arguments);
231
- }
232
- } // end if (listeners are defined)
233
- }
234
-
235
- onmessage = function(event) {
236
- var tbFrame = TorqueBox.WebSockets.Assembly.decode(event.data);
237
- log.debug('<<< ' + tbFrame.data);
238
- var frame = Stomp.unmarshal(tbFrame.data);
239
- if (frame.command === "CONNECTED") {
240
- notifyListeners('onconnect', [ frame ]);
241
- } else if (frame.command === "MESSAGE") {
242
- var onreceive = subscriptions[frame.headers.subscription];
243
- if (onreceive) {
244
- onreceive(frame);
245
- }
246
- } else if (frame.command === "RECEIPT" && that.onreceipt) {
247
- that.onreceipt(frame);
248
- } else if (frame.command === "ERROR" && that.onerror) {
249
- notifyListeners('onerror', [ frame ]);
250
- } else if (frame.command == "DISCONNECTED")
251
- alert('disconnected');
252
- };
253
-
254
- transmit = function(command, headers, body) {
255
- var out = Stomp.marshal(command, headers, body);
256
- log.debug(">>> " + out);
257
- var frame = new TorqueBox.WebSockets.Frame();
258
- frame.type = Stomp.mediaType;
259
- frame.data = out;
260
- ws.send(frame);
261
- };
262
-
263
- that = {};
264
-
265
- that.addEventListener = function(event, callback, scopeObject) {
266
- if (!listeners[event])
267
- listeners[event] = [];
268
- listeners[event].push({
269
- scope : scopeObject || this,
270
- fn : callback
271
- });
272
- }
273
-
274
- that.close = function() {
275
- ws.close();
276
- }
277
-
278
- that.connect = function(login_, passcode_) {
279
- log.debug("Opening Web Socket...");
280
- ws = new TorqueBox.WebSockets.client(name, url);
281
- ws.addEventListener('onmessage', Stomp.mediaType, onmessage);
282
- ws.addEventListener('ondisconnect', Stomp.mediaType, function() {
283
- this.close();
284
- });
285
- ws.onclose = function() {
286
- var msg = "Disconnected from STOMP server.";
287
- log.debug(msg);
288
- notifyListeners('onerror', [ msg ]);
289
- };
290
- ws.onready = function() {
291
- log.debug("Web socket opened... connecting to STOMP server.")
292
- transmit("CONNECT", {
293
- login : login,
294
- passcode : passcode
295
- });
296
- };
297
- login = login_;
298
- passcode = passcode_;
299
- ws.connect();
300
- };
301
-
302
- that.disconnect = function(disconnectCallback) {
303
- transmit("DISCONNECT");
304
- };
305
-
306
- that.send = function(destination, headers, body) {
307
- var headers = headers || {};
308
- headers.destination = destination;
309
- transmit("SEND", headers, body);
310
- };
311
-
312
- that.subscribe = function(destination, callback, headers) {
313
- var headers = headers || {};
314
- var id = "sub-" + counter++;
315
- headers.destination = destination;
316
- headers.id = id;
317
- subscriptions[id] = callback;
318
- transmit("SUBSCRIBE", headers);
319
- return id;
320
- };
321
-
322
- that.unsubscribe = function(id, headers) {
323
- var headers = headers || {};
324
- headers.id = id;
325
- delete subscriptions[id];
326
- transmit("UNSUBSCRIBE", headers);
327
- };
328
-
329
- that.begin = function(transaction, headers) {
330
- var headers = headers || {};
331
- headers.transaction = transaction;
332
- transmit("BEGIN", headers);
333
- };
334
-
335
- that.commit = function(transaction, headers) {
336
- var headers = headers || {};
337
- headers.transaction = transaction;
338
- transmit("COMMIT", headers);
339
- };
340
-
341
- that.abort = function(transaction, headers) {
342
- var headers = headers || {};
343
- headers.transaction = transaction;
344
- transmit("ABORT", headers);
345
- };
346
-
347
- that.ack = function(message_id, headers) {
348
- var headers = headers || {};
349
- headers["message-id"] = message_id;
350
- transmit("ACK", headers);
351
- };
352
- return that;
353
- };
354
-
355
- window.Stomp = Stomp;
356
- window.TorqueBox = TorqueBox;
357
-
358
- })(window);
@@ -1,12 +0,0 @@
1
-
2
- class WebsocketsClientGenerator < Rails::Generators::Base
3
-
4
- source_root File.expand_path('../templates', __FILE__)
5
-
6
- def generate
7
- puts "generating ws client"
8
- copy_file "torquebox_ws_client.js", "public/javascripts/torquebox_ws_client.js"
9
- puts "done generating ws client"
10
- end
11
-
12
- end