torquebox-core 4.0.0.beta2-java → 4.0.0.beta3-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 064ab706a2d83b43252af08da71d29b9770a95cc
4
- data.tar.gz: e63a2845b426855b3ba7fef611558bb759a5273d
3
+ metadata.gz: ddd01042745f0acb74e5cd5c698edfcd5dfbbd06
4
+ data.tar.gz: 1c64810b337f920ea9dc8ff1bad6e31a99853899
5
5
  SHA512:
6
- metadata.gz: eac2bfbda2e5404d0a2bb9fef0ec46b7ad760d9c8a1e79e19765b9a4728ebb0d728842835695a0c3165cc72bfde85e19eaaf3a55890767a632697dcfadaa0d3c
7
- data.tar.gz: f8c2cdf6d27a2250742a5d272dc3a389caebe0fc4760703aedd6a6c3a74f6fb8f0706f151cb9f3c9393465892db787f4a61c7450514caa70a21dce4d890d1556
6
+ metadata.gz: d7e9a657df452f20ec5781e76b9b5f2bb3ef7b5f6bceb8071bee480bc14936fdf243bc0b0b0d7e5cb42bcf890b65002b93153640bc2e0f71081dcc2d3415c803
7
+ data.tar.gz: aa0c26f15d5fc56cf11454fc0d1eaefd89c1306358c27b2c461adf6412d8246801dc63ed7524846661f56865940d5dfafafd962b73ed65672ca64281af57b2ce
Binary file
@@ -46,7 +46,7 @@ module TorqueBox
46
46
 
47
47
  class << self
48
48
  def in_wildfly?
49
- !org.projectodd.wunderboss.WunderBoss.options.get('wildfly-service').nil?
49
+ org.projectodd.wunderboss.WunderBoss.inWildFly
50
50
  end
51
51
  end
52
52
  end
@@ -60,6 +60,7 @@ require 'torquebox/cli'
60
60
  require 'torquebox/cli/archive'
61
61
  require 'torquebox/cli/jar'
62
62
  require 'torquebox/cli/war'
63
+ require 'torquebox/daemon'
63
64
  require 'torquebox/logger'
64
65
  require 'torquebox/option_utils'
65
66
  require 'torquebox/version'
data/lib/torquebox/cli.rb CHANGED
@@ -35,7 +35,7 @@ module TorqueBox
35
35
  end
36
36
 
37
37
  def initialize(argv)
38
- @argv = argv
38
+ @argv = argv = argv.dup
39
39
  require_torquebox_gems
40
40
  options = {}
41
41
  @extension = TorqueBox::CLI.extensions[argv.first]
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'optparse'
16
+ require 'rbconfig'
16
17
 
17
18
  module TorqueBox
18
19
  class CLI
@@ -41,11 +42,13 @@ module TorqueBox
41
42
  # "java -jar foo.jar -S torquebox help" work without quotes
42
43
  arg = ([arg] + @argv).join(' ')
43
44
  app_jar = java.lang.System.get_property("torquebox.app_jar")
45
+ lib_dir = RbConfig::CONFIG['libdir']
44
46
  load_path = $LOAD_PATH.map { |entry| "-I#{entry}" }.join(' ')
45
47
  jars = Dir.glob("../jars/*.jar").map { |j| "-r#{j}" }.join(' ')
46
48
  # PWD is $tmpdir/app and jruby.jar is $tmpdir/jars/jruby.jar
47
49
  Kernel.exec("java -Dtorquebox.app_jar=#{app_jar} \
48
50
  -Djava.io.tmpdir=#{java.lang.System.get_property('java.io.tmpdir')} \
51
+ -Djruby.lib=#{lib_dir} \
49
52
  -jar ../jars/jruby.jar #{load_path} -r#{app_jar} \
50
53
  #{jars} -rbundler/setup -rtorquebox/cli/archive_cleaner \
51
54
  -S #{arg}")
@@ -163,11 +163,27 @@ module TorqueBox
163
163
  :pattern => "/*",
164
164
  :jar_prefix => "jruby/bin")
165
165
  add_jar(jar_builder, "#{rb_config['libdir']}/jruby.jar")
166
+ add_default_gems(jar_builder)
167
+ end
168
+
169
+ def add_default_gems(jar_builder)
170
+ default_spec_suffix = "specifications/default"
171
+ default_spec_dir = "#{Gem.default_dir}/#{default_spec_suffix}"
172
+ jar_prefix = "jruby/lib/ruby/gems/shared"
173
+ Dir.glob("#{default_spec_dir}/*.gemspec").each do |file|
174
+ jar_builder.add_file(File.join(jar_prefix, default_spec_suffix,
175
+ File.basename(file)), file)
176
+ gem_full_name = File.basename(file, ".*")
177
+ add_files(jar_builder,
178
+ :file_prefix => "#{Gem.default_dir}/gems/#{gem_full_name}",
179
+ :pattern => "/**/*",
180
+ :jar_prefix => "#{jar_prefix}/gems/#{gem_full_name}")
181
+ end
166
182
  end
167
183
 
168
184
  def add_app_files(jar_builder, options)
169
185
  @logger.trace("Adding application files to jar...")
170
- exclude = [%r{^/[^/]*\.(jar|war)}]
186
+ exclude = [Regexp.new("^[^/]*\.(jar|war)")]
171
187
  if options[:exclude]
172
188
  exclude += options[:exclude].map { |e| Regexp.new("^#{e}") }
173
189
  end
@@ -285,7 +301,7 @@ module TorqueBox
285
301
  def add_files(jar_builder, options)
286
302
  prefix = options[:file_prefix]
287
303
  prefix += '/' unless prefix.end_with?('/')
288
- Dir.glob("#{prefix}#{options[:pattern]}").each do |file|
304
+ Dir.glob(File.join(prefix, options[:pattern])).each do |file|
289
305
  suffix = file.sub(prefix, '')
290
306
  excludes = [options[:exclude]].compact.flatten
291
307
  next if excludes.any? do |exclude|
@@ -0,0 +1,157 @@
1
+ # Copyright 2015 Red Hat, Inc, and individual contributors.
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 'torquebox/option_utils'
16
+
17
+ module TorqueBox
18
+ # Respresents a long-running daemon.
19
+ #
20
+ # When started, the daemon will execute its action in another
21
+ # thread, and if that thread throws an unhandled exception, the
22
+ # error will be logged and the action restarted.
23
+ #
24
+ # You can override this behavior by providing your own {#on_error}
25
+ # handler.
26
+ #
27
+ # In a WildFly cluster, daemons will be singletons, meaning only one
28
+ # instance of the daemon (based on its name) will run at a time. If
29
+ # the node running the daemon dies, it will start on another node as
30
+ # long as {#start} has been called on a daemon with the same name
31
+ # has been started on that node. If the daemon dies due to an error
32
+ # and is restarted (via {#start}), then the current node will be in
33
+ # competition with the other nodes in the cluster to start the
34
+ # daemon, and it may actually start on another node.
35
+ class Daemon
36
+ include TorqueBox::OptionUtils
37
+ extend TorqueBox::OptionUtils
38
+
39
+ java_import org.projectodd.wunderboss::WunderBoss
40
+ java_import org.projectodd.wunderboss.ec::DaemonContext
41
+
42
+ DAEMON_OPTIONS = optset(DaemonContext::CreateOption,
43
+ :on_error,
44
+ :on_stop)
45
+
46
+ # The name of this daemon.
47
+ attr_reader :name
48
+
49
+ # Creates a daemon object.
50
+ #
51
+ # Optionally takes a block that is the action of the daemon. If
52
+ # not provided, you must extend this class and override {#action}
53
+ # if you want the daemon to actually do anything. The block will
54
+ # be passed the daemon object.
55
+ #
56
+ # @param name [String] The name of this daemon. Needs to be the
57
+ # same across a cluster for :singleton to work, and must be
58
+ # unique.
59
+ # @param options [Hash] Options for the daemon.
60
+ # @option options :singleton [true, false] (true)
61
+ # @option options :on_error [Proc] A custom error handler, will be
62
+ # passed the daemon object and the error (see {#on_error})
63
+ # @option options :on_stop [Proc] A custom stop handler, will be
64
+ # passed the daemon object (see {#on_stop})
65
+ # @option options :stop_timeout [Number] (30_000) Milliseconds to
66
+ # wait for the daemon thread to exit when stopping.
67
+ def initialize(name, options = {}, &block)
68
+ validate_options(options, DAEMON_OPTIONS)
69
+ @name = name.to_s
70
+ @on_error_lambda = options.delete(:on_error)
71
+ @on_stop_lambda = options.delete(:on_stop)
72
+ @action_lambda = block
73
+ @options = options
74
+
75
+ if WunderBoss.find_component(DaemonContext.java_class, @name)
76
+ raise "A daemon named #{@name} already exists"
77
+ end
78
+
79
+ @java_daemon =
80
+ WunderBoss.find_or_create_component(DaemonContext.java_class,
81
+ @name,
82
+ extract_options(@options,
83
+ DaemonContext::CreateOption))
84
+ end
85
+
86
+ # Starts the daemon. If :singleton and in a cluster, the daemon
87
+ # may not be running on the current node after calling start.
88
+ # @return [Daemon] self
89
+ def start
90
+ @java_daemon.set_action do
91
+ action
92
+ end
93
+
94
+ @java_daemon.set_error_callback do |_, err|
95
+ on_error(err)
96
+ end
97
+
98
+ @java_daemon.set_stop_callback do |_|
99
+ on_stop
100
+ end
101
+
102
+ @java_daemon.start
103
+
104
+ self
105
+ end
106
+
107
+ # Stops the daemon. This will trigger the {#on_stop} callback if
108
+ # this daemon is {#running?}.
109
+ # @return [Daemon] self
110
+ def stop
111
+ if @java_daemon
112
+ @java_daemon.stop
113
+ end
114
+
115
+ self
116
+ end
117
+
118
+ # true if the daemon is actually running. If not :singleton or
119
+ # not in a cluster, and the action hasn't exited normally,
120
+ # running? == {#started?}
121
+ def running?
122
+ @java_daemon && @java_daemon.is_running
123
+ end
124
+
125
+ # true if in the started state. May not actually be running. see
126
+ # {#running?}
127
+ def started?
128
+ @java_daemon && @java_daemon.is_started
129
+ end
130
+
131
+ # The action to perform. If you override this method, the block
132
+ # given to {#initialize} will be ignored. You should never call
133
+ # this method directly.
134
+ def action
135
+ @action_lambda.call(self) if @action_lambda
136
+ end
137
+
138
+ # Called when an unhandled error occurs in #{action}. If you
139
+ # override this method, the :on_error proc given to #{initialize}
140
+ # will be ignored.
141
+ #
142
+ # @param error [] The error that occurred.
143
+ def on_error(error)
144
+ if @on_error_lambda
145
+ @on_error_lambda.call(self, error)
146
+ else
147
+ DaemonContext::DEFAULT_ERROR_CALLBACK.notify(@java_daemon.name, error)
148
+ start
149
+ end
150
+ end
151
+
152
+ # Called when {#stop} is called, but only if {#started?} is true.
153
+ def on_stop
154
+ @on_stop_lambda.call(self) if @on_stop_lambda
155
+ end
156
+ end
157
+ end
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
  module TorqueBox
17
- VERSION = '4.0.0.beta2'
18
- WUNDERBOSS_VERSION = '0.8.0'
19
- WILDFLY_VERSION = '9.0.1.Final'
17
+ VERSION = '4.0.0.beta3'
18
+ WUNDERBOSS_VERSION = '0.12.1'
19
+ WILDFLY_VERSION = '10.0.0.Final'
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torquebox-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta2
4
+ version: 4.0.0.beta3
5
5
  platform: java
6
6
  authors:
7
7
  - The TorqueBox Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-03 00:00:00.000000000 Z
11
+ date: 2016-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbundler
@@ -74,32 +74,33 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - bin/torquebox
77
- - lib/torquebox-core.rb
78
77
  - lib/torquebox-core.jar
79
- - lib/wunderboss-jars/wunderboss-wildfly-0.8.0.jar
80
- - lib/wunderboss-jars/wunderboss-core-0.8.0.jar
81
- - lib/wunderboss-jars/logback-core-1.1.2.jar
82
- - lib/wunderboss-jars/logback-classic-1.1.2.jar
83
- - lib/wunderboss-jars/slf4j-api-1.7.5.jar
84
- - lib/wunderboss-jars/wunderboss-ruby-0.8.0.jar
78
+ - lib/torquebox-core.rb
79
+ - lib/wunderboss-jars/wunderboss-wildfly-core-0.12.1.jar
85
80
  - lib/wunderboss-jars/jboss-logging-3.1.4.GA.jar
86
- - lib/resources/logback-cli.xml
81
+ - lib/wunderboss-jars/wunderboss-core-0.12.1.jar
82
+ - lib/wunderboss-jars/logback-core-1.1.3.jar
83
+ - lib/wunderboss-jars/wunderboss-ruby-0.12.1.jar
84
+ - lib/wunderboss-jars/logback-classic-1.1.3.jar
85
+ - lib/wunderboss-jars/slf4j-api-1.7.7.jar
86
+ - lib/torquebox/cli.rb
87
87
  - lib/torquebox/spec_helpers.rb
88
88
  - lib/torquebox/logger.rb
89
- - lib/torquebox/cli.rb
89
+ - lib/torquebox/version.rb
90
90
  - lib/torquebox/codecs.rb
91
91
  - lib/torquebox/option_utils.rb
92
- - lib/torquebox/version.rb
92
+ - lib/torquebox/daemon.rb
93
+ - lib/torquebox/cli/archive_cleaner.rb
93
94
  - lib/torquebox/cli/jar.rb
94
95
  - lib/torquebox/cli/war.rb
95
- - lib/torquebox/cli/archive_cleaner.rb
96
96
  - lib/torquebox/cli/archive.rb
97
- - lib/torquebox/codecs/marshal_smart.rb
98
- - lib/torquebox/codecs/marshal.rb
99
- - lib/torquebox/codecs/json.rb
100
97
  - lib/torquebox/codecs/edn.rb
101
98
  - lib/torquebox/codecs/marshal_base64.rb
99
+ - lib/torquebox/codecs/marshal_smart.rb
100
+ - lib/torquebox/codecs/marshal.rb
102
101
  - lib/torquebox/codecs/text.rb
102
+ - lib/torquebox/codecs/json.rb
103
+ - lib/resources/logback-cli.xml
103
104
  homepage: http://torquebox.org/4x
104
105
  licenses:
105
106
  - Apache-2.0
@@ -119,8 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  - !ruby/object:Gem::Version
120
121
  version: 1.3.1
121
122
  requirements:
122
- - jar org.projectodd.wunderboss:wunderboss-ruby, 0.8.0
123
- - jar org.projectodd.wunderboss:wunderboss-wildfly, 0.8.0
123
+ - jar org.projectodd.wunderboss:wunderboss-ruby, 0.12.1
124
+ - jar org.projectodd.wunderboss:wunderboss-wildfly-core, 0.12.1
124
125
  rubyforge_project:
125
126
  rubygems_version: 2.1.9
126
127
  signing_key: