jubilee 2.1.0.beta-java → 2.1.0.rc1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +13 -1
  3. data/README.md +65 -54
  4. data/Rakefile +23 -21
  5. data/examples/chatapp/Gemfile +1 -2
  6. data/examples/chatapp/Gemfile.lock +2 -2
  7. data/examples/chatapp/README.md +14 -2
  8. data/examples/chatapp/app.rb +1 -0
  9. data/examples/chatapp/config.json +4 -0
  10. data/examples/chatapp/config.ru +0 -2
  11. data/jars/annotations-1.3.2.jar +0 -0
  12. data/jars/lang-jruby-2.1.0-final.jar +0 -0
  13. data/jars/log4j-1.2.16.jar +0 -0
  14. data/jars/slf4j-api-1.6.2.jar +0 -0
  15. data/jars/vertx-core-2.1.2.jar +0 -0
  16. data/jars/{vertx-hazelcast-2.1.1.jar → vertx-hazelcast-2.1.2.jar} +0 -0
  17. data/jars/{vertx-platform-2.1.1.jar → vertx-platform-2.1.2.jar} +0 -0
  18. data/lib/container.rb +117 -0
  19. data/lib/{vertx → core}/buffer.rb +1 -1
  20. data/lib/core/datagram.rb +280 -0
  21. data/lib/core/dns.rb +143 -0
  22. data/lib/{vertx → core}/event_bus.rb +79 -8
  23. data/lib/core/file_system.rb +479 -0
  24. data/lib/{vertx → core}/http.rb +635 -5
  25. data/lib/core/net.rb +251 -0
  26. data/lib/core/network_support.rb +77 -0
  27. data/lib/core/parsetools.rb +105 -0
  28. data/lib/{vertx → core}/shared_data.rb +2 -2
  29. data/lib/core/sock_js.rb +116 -0
  30. data/lib/{vertx → core}/ssl_support.rb +21 -1
  31. data/lib/{vertx → core}/streams.rb +32 -21
  32. data/lib/{vertx → core}/tcp_support.rb +22 -36
  33. data/lib/core/timers.rb +73 -0
  34. data/lib/core/vertx_require.rb +25 -0
  35. data/lib/{vertx → core}/wrapped_handler.rb +0 -0
  36. data/lib/jubilee.rb +5 -8
  37. data/lib/jubilee/cli.rb +1 -1
  38. data/lib/jubilee/jubilee.jar +0 -0
  39. data/lib/jubilee/jubilee_require.rb +24 -0
  40. data/lib/jubilee/version.rb +1 -1
  41. data/lib/test_utils.rb +66 -0
  42. data/lib/vertx.rb +13 -10
  43. data/lib/vertx_tests.rb +8 -0
  44. data/pom.xml +351 -0
  45. data/src/main/assembly/mod.xml +21 -0
  46. data/{java/src → src/main/java}/jubilee/JubileeService.java +0 -0
  47. data/{java/src → src/main/java}/org/jruby/jubilee/Const.java +0 -0
  48. data/{java/src → src/main/java}/org/jruby/jubilee/JubileeVerticle.java +12 -2
  49. data/src/main/java/org/jruby/jubilee/JubileeVerticleFactory.java +258 -0
  50. data/{java/src → src/main/java}/org/jruby/jubilee/RackApplication.java +3 -1
  51. data/{java/src → src/main/java}/org/jruby/jubilee/RackEnvironment.java +2 -2
  52. data/{java/src → src/main/java}/org/jruby/jubilee/RackEnvironmentHash.java +0 -0
  53. data/{java/src → src/main/java}/org/jruby/jubilee/RackInput.java +0 -0
  54. data/{java/src → src/main/java}/org/jruby/jubilee/RackResponse.java +0 -0
  55. data/{java/src → src/main/java}/org/jruby/jubilee/RubyCallable.java +0 -0
  56. data/{java/src → src/main/java}/org/jruby/jubilee/RubyHttpServerResponse.java +0 -0
  57. data/{java/src → src/main/java}/org/jruby/jubilee/RubyNetSocket.java +0 -0
  58. data/{java/src → src/main/java}/org/jruby/jubilee/RubyPlatformManager.java +0 -0
  59. data/{java/src → src/main/java}/org/jruby/jubilee/impl/RubyIORackInput.java +0 -0
  60. data/{java/src → src/main/java}/org/jruby/jubilee/impl/RubyNullIO.java +0 -0
  61. data/{java/src → src/main/java}/org/jruby/jubilee/utils/RubyHelper.java +0 -0
  62. data/{java/src → src/main/java}/org/jruby/jubilee/vertx/JubileeVertx.java +0 -0
  63. data/{java → src/main}/resources/META-INF/services/org.vertx.java.core.spi.cluster.ClusterManagerFactory +0 -0
  64. data/src/main/resources/META-INF/services/org.vertx.java.deploy.impl.jruby.JubileeVerticleFactory +1 -0
  65. data/{java → src/main}/resources/default-cluster.xml +0 -0
  66. data/src/main/resources/mod.json +11 -0
  67. data/test/jubilee/test_upload.rb +3 -1
  68. data/vertx_classpath.txt +12 -0
  69. metadata +69 -47
  70. data/Guardfile +0 -24
  71. data/jars/vertx-core-2.1.1.jar +0 -0
  72. data/java/src/org/jruby/jubilee/RubyChannel.java +0 -89
  73. data/lib/vertx/README.md +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 865bcd4759e0b52c639ae642a749f1885da1025c
4
- data.tar.gz: 7a13f948d9e4a4a75ee039b1765b74ea9333c3b6
3
+ metadata.gz: a4025890d1a3b94265ecc1baf4b14c29360b2639
4
+ data.tar.gz: 12d2da1989239ee2b4d52ab5c64e0c0491713c26
5
5
  SHA512:
6
- metadata.gz: ba572a6a03c0c8c593d6f183375c8aa42fa69c10fe5c41b9d50fd9f0d7360f7ad3a71201ee7dd695a4ee5c1ddfac98b77d5ed3727cec2e68c7e4a8d63c1d3757
7
- data.tar.gz: 7e209e4e8a9d0e24599078aa550b2a74c57e1a4f7a8d1961d9fcb67faf1c403301d29436dcfb0c582402a69fc6bff6883c50a6e61482f01f6f947e23efa3a2ae
6
+ metadata.gz: 3d6b27947fe1717e3e5ff1def31dc325ecc6aa00b560e04789a5723d1c4960ed0c70bd90dbc8bc6f369ad290af89386f179fbc6545dfbfe3fe1f439c3c3ff457
7
+ data.tar.gz: 0fe735bc70b1bade1be8ff36062cb65177763944ba74a9b16213c5fb95a26e9bd61bea60030a8f7ac3c0f7931b739b44c37bbd00778ebd3b9afd01a0598a7435
@@ -29,6 +29,7 @@ GEM
29
29
  tzinfo (~> 0.3.37)
30
30
  addressable (2.3.5)
31
31
  arel (4.0.1)
32
+ atomic (1.1.14)
32
33
  atomic (1.1.14-java)
33
34
  builder (3.1.4)
34
35
  capybara (2.2.0)
@@ -53,6 +54,7 @@ GEM
53
54
  execjs (2.0.2)
54
55
  faraday (0.8.8)
55
56
  multipart-post (~> 1.2.0)
57
+ ffi (1.9.3)
56
58
  ffi (1.9.3-java)
57
59
  formatador (0.2.4)
58
60
  git (1.2.6)
@@ -94,6 +96,7 @@ GEM
94
96
  jquery-rails (3.0.4)
95
97
  railties (>= 3.0, < 5.0)
96
98
  thor (>= 0.14, < 2.0)
99
+ json (1.8.1)
97
100
  json (1.8.1-java)
98
101
  jwt (0.1.8)
99
102
  multi_json (>= 1.5)
@@ -111,6 +114,7 @@ GEM
111
114
  multi_json (1.8.2)
112
115
  multi_xml (0.5.5)
113
116
  multipart-post (1.2.0)
117
+ nokogiri (1.5.10)
114
118
  nokogiri (1.5.10-java)
115
119
  oauth2 (0.9.2)
116
120
  faraday (~> 0.8)
@@ -125,6 +129,10 @@ GEM
125
129
  multi_json (~> 1.0)
126
130
  websocket-driver (>= 0.2.0)
127
131
  polyglot (0.3.3)
132
+ pry (0.9.12.4)
133
+ coderay (~> 1.0)
134
+ method_source (~> 0.8)
135
+ slop (~> 3.4)
128
136
  pry (0.9.12.4-java)
129
137
  coderay (~> 1.0)
130
138
  method_source (~> 0.8)
@@ -148,10 +156,11 @@ GEM
148
156
  activesupport (= 4.0.2)
149
157
  rake (>= 0.8.7)
150
158
  thor (>= 0.18.1, < 2.0)
151
- rake (10.1.1)
159
+ rake (10.3.2)
152
160
  rb-fsevent (0.9.4)
153
161
  rb-inotify (0.9.3)
154
162
  ffi (>= 0.5.0)
163
+ rcov (0.9.11)
155
164
  rcov (0.9.11-java)
156
165
  rdoc (4.1.0)
157
166
  json (~> 1.4)
@@ -188,6 +197,8 @@ GEM
188
197
  therubyrhino_jar (>= 1.7.3)
189
198
  therubyrhino_jar (1.7.4)
190
199
  thor (0.18.1)
200
+ thread_safe (0.1.3)
201
+ atomic
191
202
  thread_safe (0.1.3-java)
192
203
  atomic
193
204
  tilt (1.4.1)
@@ -201,6 +212,7 @@ GEM
201
212
  uglifier (2.4.0)
202
213
  execjs (>= 0.3.0)
203
214
  json (>= 1.8.0)
215
+ websocket-driver (0.3.2)
204
216
  websocket-driver (0.3.2-java)
205
217
  xpath (2.0.0)
206
218
  nokogiri (~> 1.3)
data/README.md CHANGED
@@ -1,74 +1,49 @@
1
1
  [![Build Status](https://travis-ci.org/isaiah/jubilee.png?branch=master)](https://travis-ci.org/isaiah/jubilee)
2
2
 
3
- Jubilee server
4
- =========
5
-
6
- > "We need a web framework for Vertx.", you said.
7
-
8
- > "But why not use Vertx in your Rails applications, it's the most productive web framework ever created."
9
-
10
- The Answer is Jubilee, a rack server with [vertx 2.0](http://vertx.io) awesomeness builtin. Check out the
11
- [demo](http://192.241.201.68:8080/) [application](https://github.com/isaiah/jubilee/tree/master/examples/chatapp).
12
-
13
- Why another rack server?
14
- ------------------------
3
+ Jubilee / mod-rack
4
+ ==================
15
5
 
16
- > "Vert.x is a lightweight, high performance application platform for the JVM
17
- > that's designed for modern mobile, web, and enterprise applications."
18
- > - vertx.io site
6
+ > A rack server for jruby.
19
7
 
20
- By using Vertx, jubilee inherent advantages in terms of performance, and all
21
- the other cool features of Vertx:
8
+ > Also works as vertx module.
22
9
 
23
- * [EventBus](https://github.com/isaiah/jubilee/wiki/Event-Bus)
24
- * [SharedData](https://github.com/isaiah/jubilee/wiki/SharedData)
25
- * [Clustering](https://github.com/isaiah/jubilee/wiki/Clustering)
10
+ Get started
11
+ -----------
26
12
 
13
+ Please checkout the [wiki
14
+ page](https://github.com/isaiah/jubilee/wiki/Running-as-vertx-module)
15
+ before you proceed.
27
16
 
17
+ Add the following snippet to ```$VERTX\_HOME/conf/langs.properties```
18
+ ```
19
+ rackup=isaiah~mod-rack~0.1.2:org.jruby.jubilee.JubileeVerticleFactory
20
+ .ru=rackup
21
+ ```
28
22
 
29
- Installation
30
- ------------
23
+ Make sure JRUBY_HOME is correctly set, and ```rack``` gem is install before proceed.
31
24
 
32
- $ jruby -S gem install jubilee
25
+ Then run the rackup file as a normal verticle,
33
26
 
34
- Jubilee requires JRuby 1.7.5 or later, and JDK 7+
27
+ ```shell
28
+ vertx run config.ru
29
+ ```
35
30
 
36
31
  Build from source
37
32
  -----------------
38
33
 
39
- Checkout the source and run the following command in the root directory of the
40
- project:
34
+ First checkout the source from github.
35
+
36
+ 1. To run as a vertx module, run the following command in the root directory:
41
37
 
42
38
  ```shell
43
- bundle && bundle exec rake install
39
+ mvn package
40
+ vertx create-module-link org.jruby.jubilee~mod-rack~0.1.3-SNAPSHOT
44
41
  ```
45
42
 
46
- Get started
47
- -----------
48
-
49
- $ cd a-rack-app
50
- $ jruby -S jubilee
51
-
52
- Setup
53
- -----
54
-
55
- If you use bundler, you might want to add `jubilee` to your Gemfile
43
+ then change your langs.properties file to point to the new module;
56
44
 
57
- gem 'jubilee', '~> 2.0.0'
58
-
59
- Rails
60
- -----
61
-
62
- Under the default setup, jubilee runs 4 instances of web
63
- servers, each with it's own jruby runtime, if you find that jubilee
64
- crashes or hangs with OutOfMemeoryError, please tune your JVM OPTS
65
- like this:
66
-
67
- $ export JAVA_OPTS="-Xms1024m -Xmx2048m -XX:PermSize=512m -XX:MaxPermSize=512m"
68
-
69
- If your OS memory is quite limited, please run jubilee with
70
-
71
- $ jubilee -n 1
45
+ 2. To run as rubygem, run ```rake install``` in the root directory, maven is
46
+ required.
72
47
 
73
48
  Event Bus
74
49
  =========
@@ -81,10 +56,18 @@ Examples
81
56
  --------
82
57
 
83
58
  Assume necessary javascript files are loaded in the page (they can be found [here](https://github.com/isaiah/jubilee/tree/master/examples/client)),
84
- start jubilee in a rack application with:
59
+ run rack application with the following config:
60
+
61
+ ```
62
+ $ cat config.json
63
+ { "host": "0.0.0.0",
64
+ "port": 8080,
65
+ "event_bus": "/eventbus"
66
+ }
67
+ ```
85
68
 
86
69
  ```
87
- $ jubilee --eventbus /eventbus
70
+ $ vertx run config.ru -conf config.json
88
71
  ```
89
72
 
90
73
  In one browser:
@@ -109,6 +92,34 @@ In the previous tab it should print the greetings you just sent.
109
92
  For more advanced examples, please checkout the
110
93
  [chatapp](https://github.com/isaiah/jubilee/tree/master/examples/chatapp).
111
94
 
95
+ EventBus Security
96
+ ------------------
97
+
98
+ The EventBus can (and probably should) be secured by passing in parameters in the config.json
99
+ object.
100
+
101
+ The following config will allow all messages from the browser to `accounts.get_balances` and
102
+ only allow messages outward that match the format `accounts.get_balances.*`.
103
+
104
+ ```
105
+ $ cat config.json
106
+ {
107
+ "host": "0.0.0.0",
108
+ "port": 8080,
109
+ "event_bus": "/eventbus",
110
+ "event_bus_security":
111
+ {
112
+ "incoming": [{address: "user_accounts.get_balances"}],
113
+ "outgoing": [{address_re: "user_accounts.balances.*"}]
114
+ }
115
+ }
116
+ ```
117
+
118
+ More details of parameters can be found in [the VertX docs](http://vertx.io/core_manual_ruby.html#securing-the-bridge)
119
+
120
+ By default the bridge is left wide open. Any browser connected to an application can observe *all* messages being
121
+ passed on your EventBus.
122
+
112
123
  Performance Tuning
113
124
  -------------------
114
125
 
data/Rakefile CHANGED
@@ -34,6 +34,8 @@ Jeweler::Tasks.new do |gem|
34
34
  gem.version = Jubilee::Version::STRING
35
35
  gem.platform = "java"
36
36
  gem.files.include "lib/jubilee/jubilee.jar"
37
+ gem.files.include "jars/*.jar"
38
+ gem.files.include "lib/**/*.rb"
37
39
  # dependencies defined in Gemfile
38
40
  end
39
41
  Jeweler::RubygemsDotOrgTasks.new
@@ -69,35 +71,35 @@ end
69
71
 
70
72
  require 'ant'
71
73
 
72
- DEST_PATH = "pkg/classes"
73
- RESOURCE_PATH = "java/resources"
74
-
75
- directory DEST_PATH
76
-
77
74
  desc "Clean up build artifacts"
78
75
  task :clean do
79
- rm_rf "pkg/classes"
76
+ sh "mvn clean"
77
+ rm_rf "jars"
80
78
  rm_rf "lib/jubilee/*.jar"
79
+ rm_rf "lib/core"
80
+ rm_rf "lib/vertx.rb"
81
+ rm_rf "lib/vertx_tests.rb"
82
+ rm_rf "lib/container.rb"
83
+ rm_rf "lib/test_utils.rb"
81
84
  end
82
85
 
83
- BUILDTIME_LIB_DIR = File.join(File.dirname(__FILE__), "jars")
84
-
85
- desc "Compile the extension, need jdk7 because vertx relies on it"
86
- task :compile => [DEST_PATH, "#{DEST_PATH}/META-INF"] do |t|
87
- ant.javac :srcdir => "java", :destdir => t.prerequisites.first,
88
- :source => "1.7", :target => "1.7", :debug => true, :includeantruntime => false,
89
- :classpath => "${java.class.path}:${sun.boot.class.path}:jars/vertx-core-2.1.1.jar:jars/netty-all-4.0.20.Final.jar:jars/jackson-core-2.2.2.jar:jars/jackson-databind-2.2.2.jar:jars/jackson-annotations-2.2.2.jar:jars/hazelcast-3.2.3.jar:jars/vertx-platform-2.1.1.jar:jars/vertx-hazelcast-2.1.1.jar"
90
- end
86
+ #desc "Compile the extension, need jdk7 because vertx relies on it"
87
+ #task :compile => [DEST_PATH, "#{DEST_PATH}/META-INF"] do |t|
88
+ # #ant.javac :srcdir => "java", :destdir => t.prerequisites.first,
89
+ # # :source => "1.7", :target => "1.7", :debug => true, :includeantruntime => false,
90
+ # # :classpath => "${java.class.path}:${sun.boot.class.path}:jars/vertx-core-2.1.2.jar:jars/netty-all-4.0.20.Final.jar:jars/jackson-core-2.2.2.jar:jars/jackson-databind-2.2.2.jar:jars/jackson-annotations-2.2.2.jar:jars/hazelcast-3.2.3.jar:jars/vertx-platform-2.1.2.jar:jars/vertx-hazelcast-2.1.2.jar"
91
+ #end
91
92
 
92
- desc "Copy META-INF"
93
- task "#{DEST_PATH}/META-INF" => ["#{RESOURCE_PATH}/META-INF", "#{RESOURCE_PATH}/default-cluster.xml"] do |t|
94
- FileUtils.cp_r t.prerequisites.first, t.name, verbose: true
95
- cp t.prerequisites[1], DEST_PATH, verbose: true
96
- end
93
+ #desc "Copy META-INF"
94
+ #task "#{DEST_PATH}/META-INF" => ["#{RESOURCE_PATH}/META-INF", "#{RESOURCE_PATH}/default-cluster.xml"] do |t|
95
+ # FileUtils.cp_r t.prerequisites.first, t.name, verbose: true
96
+ # cp t.prerequisites[1], DEST_PATH, verbose: true
97
+ #end
97
98
 
98
99
  desc "Build the jar"
99
- task :jar => [:clean, :compile] do
100
- ant.jar :basedir => "pkg/classes", :destfile => "lib/jubilee/jubilee.jar"
100
+ task :jar => :clean do
101
+ sh "mvn package"
102
+ sh "unzip jars/*.zip *.rb -d lib"
101
103
  end
102
104
 
103
105
  task :build => :jar
@@ -1,5 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
  gem 'sinatra'
3
3
  gem 'haml'
4
-
5
- gem 'jubilee', '2.0.0.beta'
4
+ gem 'jubilee'
@@ -4,7 +4,7 @@ GEM
4
4
  ffi (1.9.3-java)
5
5
  haml (4.0.4)
6
6
  tilt
7
- jubilee (2.0.0.beta-java)
7
+ jubilee (2.1.0.beta-java)
8
8
  rack (>= 1.4.1)
9
9
  spoon (~> 0.0.4)
10
10
  rack (1.5.2)
@@ -23,5 +23,5 @@ PLATFORMS
23
23
 
24
24
  DEPENDENCIES
25
25
  haml
26
- jubilee (= 2.0.0.beta)
26
+ jubilee
27
27
  sinatra
@@ -6,12 +6,24 @@ application.
6
6
 
7
7
  Make sure you are using jruby 1.7+ (jubilee 1.1.0+ require jruby 1.7.5 or later) and your JDK version is 7+
8
8
 
9
- To run the application:
9
+ Install the lastest stable version of vertx(2.1.2), and put the following snippet in your vertx
10
+ language configuration, you can find the file under $VERTX\_HOME/conf/langs.properties
11
+
12
+ ```
13
+ rackup=isaiah~mod-rack~0.1.1:org.jruby.jubilee.JubileeVerticleFactory
14
+ .ru=rackup
15
+ ```
16
+
17
+ and run
10
18
 
11
19
  ```shell
12
- bundle && jubilee --eventbus /eventbus
20
+ vertx run config.ru -conf config.json
13
21
  ```
14
22
 
15
23
  Then go to http://localhost:8080 in your browser, if you have the page
16
24
  opened in multiple tabs or windows you can see the message you sent are
17
25
  broadcasted to all the other tabs.
26
+
27
+ Checkout the [wiki
28
+ page](https://github.com/isaiah/jubilee/wiki/Running-as-vertx-module) if
29
+ you run into any trouble.
@@ -1,6 +1,7 @@
1
1
  require 'bundler/setup'
2
2
  Bundler.require(:default)
3
3
  require 'vertx'
4
+ Vertx.deploy_verticle('test.rb')
4
5
 
5
6
  def to_a(shared_set)
6
7
  ret = []
@@ -0,0 +1,4 @@
1
+ { "host": "0.0.0.0",
2
+ "port": 8080,
3
+ "event_bus": "/eventbus"
4
+ }
@@ -1,4 +1,2 @@
1
- require 'jubilee'
2
- require 'vertx'
3
1
  require './app'
4
2
  run Sinatra::Application.new
Binary file
Binary file
Binary file
@@ -0,0 +1,117 @@
1
+ # Copyright 2011 the original author or authors.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'core/wrapped_handler'
16
+
17
+ module Vertx
18
+
19
+ # Deploy a verticle. The actual deploy happens asynchronously
20
+ # @param main [String] The main of the verticle to deploy
21
+ # @param config [Hash] JSON configuration for the verticle
22
+ # @param instances [FixNum] Number of instances to deploy
23
+ # @param block [Block] Block will be executed when deploy has completed - the first parameter passed to
24
+ # the block will be an exception or nil if no failure occurred, the second parameter will be the deployment id
25
+ def Vertx.deploy_verticle(main, config = nil, instances = 1, &block)
26
+ if config
27
+ json_str = JSON.generate(config)
28
+ config = org.vertx.java.core.json.JsonObject.new(json_str)
29
+ end
30
+ if block
31
+ block = ARWrappedHandler.new(block)
32
+ end
33
+ org.vertx.java.platform.impl.JRubyVerticleFactory.container.deployVerticle(main, config, instances, block)
34
+ end
35
+
36
+ # Deploy a worker verticle. The actual deploy happens asynchronously
37
+ # @param main [String] The main of the verticle to deploy
38
+ # @param config [Hash] JSON configuration for the verticle
39
+ # @param instances [FixNum] Number of instances to deploy
40
+ # @param block [Block] Block will be executed when deploy has completed - the first parameter passed to
41
+ # the block will be an exception or nil if no failure occurred, the second parameter will be the deployment id
42
+ def Vertx.deploy_worker_verticle(main, config = nil, instances = 1, multi_threaded = false, &block)
43
+ if config
44
+ json_str = JSON.generate(config)
45
+ config = org.vertx.java.core.json.JsonObject.new(json_str)
46
+ end
47
+ if block
48
+ block = ARWrappedHandler.new(block)
49
+ end
50
+ org.vertx.java.platform.impl.JRubyVerticleFactory.container.deployWorkerVerticle(main, config, instances, multi_threaded, block)
51
+ end
52
+
53
+ # Deploy a module. The actual deploy happens asynchronously
54
+ # @param module_name [String] The name of the module to deploy
55
+ # @param config [Hash] JSON configuration for the module
56
+ # @param instances [FixNum] Number of instances to deploy
57
+ # @param block [Block] Block will be executed when deploy has completed - the first parameter passed to
58
+ # the block will be an exception or nil if no failure occurred, the second parameter will be the deployment id
59
+ def Vertx.deploy_module(module_name, config = nil, instances = 1, &block)
60
+ if config
61
+ json_str = JSON.generate(config)
62
+ config = org.vertx.java.core.json.JsonObject.new(json_str)
63
+ end
64
+ if block
65
+ block = ARWrappedHandler.new(block)
66
+ end
67
+ org.vertx.java.platform.impl.JRubyVerticleFactory.container.deployModule(module_name, config, instances, block)
68
+ end
69
+
70
+ # Undeploy a verticle
71
+ # @param id [String] The deployment id - the undeploy happens asynchronously
72
+ # @param block [Block] Block will be executed when undeploy has completed, an exception will be passed to the block
73
+ # as the first parameter if undeploy failed
74
+ def Vertx.undeploy_verticle(id, &block)
75
+ if block
76
+ block = ARWrappedHandler.new(block)
77
+ end
78
+ org.vertx.java.platform.impl.JRubyVerticleFactory.container.undeployVerticle(id, block)
79
+ end
80
+
81
+ # Undeploy a module
82
+ # @param id [String] The deployment id
83
+ # @param block [Block] Block will be executed when undeploy has completed, an exception will be passed to the block
84
+ # as the first parameter if undeploy failed
85
+ def Vertx.undeploy_module(id, &block)
86
+ if block
87
+ block = ARWrappedHandler.new(block)
88
+ end
89
+ org.vertx.java.platform.impl.JRubyVerticleFactory.container.undeployModule(id, block)
90
+ end
91
+
92
+ # Cause the container to exit
93
+ def Vertx.exit
94
+ org.vertx.java.platform.impl.JRubyVerticleFactory.container.exit
95
+ end
96
+
97
+ # Get config for the verticle
98
+ # @return [Hash] The JSON config for the verticle
99
+ def Vertx.config
100
+ if !defined? @@j_conf
101
+ @@j_conf = org.vertx.java.platform.impl.JRubyVerticleFactory.container.config
102
+ @@j_conf = JSON.parse(@@j_conf.encode) if @@j_conf
103
+ end
104
+ @@j_conf
105
+ end
106
+
107
+ # @return [Hash] Get the environment for the verticle
108
+ def Vertx.env
109
+ org.vertx.java.platform.impl.JRubyVerticleFactory.container.env
110
+ end
111
+
112
+ # @return [Logger] Get the logger for the verticle
113
+ def Vertx.logger
114
+ org.vertx.java.platform.impl.JRubyVerticleFactory.container.logger
115
+ end
116
+
117
+ end