torquebox-core 4.0.0.alpha1-java → 4.0.0.beta1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8cf11a23000d1db2bbf771b2d4a8ae8c177cc2d
4
- data.tar.gz: b8875fb8ee9f5d3d144ecad52976ae5aa1e69f05
3
+ metadata.gz: a214188915ae4edc4146fdbaccc7f2486e90299c
4
+ data.tar.gz: 44b8ca8c0f8c71b082286e30ee4410fb0f785eae
5
5
  SHA512:
6
- metadata.gz: 7f867844665d4c0f451b6de698c9b9f3d08ec046a65d0a3992e36c1040c9541990683d02d8373ccdbf22cc00690cf106e72dbb0179084d68054cf026eb449bfe
7
- data.tar.gz: d57604b36264857fa2ce6d19db91b962f9450503255ab1c2a90635470a8a04736aeb02143460b654fd19133629e7b5a3aeaf6b6355502b5d90d427febb16e273
6
+ metadata.gz: ffa0c2cfd42df46a709a8f5dbeb69c76198351845d7d1a997cb04983210b6195478a674e7308225a670e3bf967e2f59e3bbe2860e70c45d66fb3d997130db5b9
7
+ data.tar.gz: 281bf2ff66a003b39b59ac608f8401dae5748562e56dd79ecb7c0b1ffe9a87b87a915ce649d61deecd96264dee2bb30599d284ced1cf294179db86752530d64f
data/bin/torquebox CHANGED
@@ -17,4 +17,4 @@ java.lang.System.set_property('logback.configurationFile',
17
17
 
18
18
  require 'torquebox-core'
19
19
 
20
- cli = TorqueBox::CLI.new(ARGV)
20
+ cli = TorqueBox::CLI.new(ARGV).run
Binary file
@@ -14,6 +14,11 @@
14
14
 
15
15
  require "pathname"
16
16
 
17
+ # Set the Thread context classloader since many Java libs we
18
+ # bring in use it to locate their classes
19
+ java.lang.Thread.current_thread
20
+ .set_context_class_loader(JRuby.runtime.jruby_class_loader)
21
+
17
22
  module TorqueBox
18
23
 
19
24
  # @api private
@@ -38,6 +43,12 @@ module TorqueBox
38
43
  end
39
44
  end
40
45
  end
46
+
47
+ class << self
48
+ def in_wildfly?
49
+ !org.projectodd.wunderboss.WunderBoss.options.get('wildfly-service').nil?
50
+ end
51
+ end
41
52
  end
42
53
 
43
54
  Dir.glob("#{File.dirname(__FILE__)}/wunderboss-jars/*.jar") do |jar|
@@ -46,6 +57,7 @@ end
46
57
 
47
58
  TorqueBox::Jars.register_and_require("#{File.dirname(__FILE__)}/torquebox-core.jar")
48
59
  require 'torquebox/cli'
60
+ require 'torquebox/cli/archive'
49
61
  require 'torquebox/cli/jar'
50
62
  require 'torquebox/cli/war'
51
63
  require 'torquebox/logger'
data/lib/torquebox/cli.rb CHANGED
@@ -17,6 +17,8 @@ require 'optparse'
17
17
  module TorqueBox
18
18
  class CLI
19
19
 
20
+ attr_reader :parser
21
+
20
22
  class << self
21
23
  def extensions
22
24
  @extensions ||= {}
@@ -33,38 +35,42 @@ module TorqueBox
33
35
  end
34
36
 
35
37
  def initialize(argv)
38
+ @argv = argv
36
39
  require_torquebox_gems
37
40
  options = {}
38
- extension = TorqueBox::CLI.extensions[argv.first]
39
- parser = OptionParser.new
40
- if extension
41
- setup_extension_parser(extension, argv.shift, parser, options)
41
+ @extension = TorqueBox::CLI.extensions[argv.first]
42
+ @parser = OptionParser.new
43
+ if @extension
44
+ setup_extension_parser(@extension, argv.shift, @parser, options)
42
45
  else
43
- setup_usage_parser(parser)
46
+ setup_usage_parser(@parser)
44
47
  end
45
48
 
46
- setup_common_parser(parser, options)
49
+ setup_common_parser(@parser, options)
50
+ @options = options
51
+ end
52
+
53
+ def run
47
54
  begin
48
- parser.parse!(argv)
55
+ @parser.parse!(@argv)
49
56
  rescue OptionParser::InvalidOption => e
50
57
  puts e.message
51
58
  puts
52
- puts parser
59
+ puts @parser
53
60
  exit 1
54
61
  end
55
62
 
56
-
57
- if extension
58
- log_level = case options.delete(:verbosity)
63
+ if @extension
64
+ log_level = case @options.delete(:verbosity)
59
65
  when :quiet then 'ERROR'
60
66
  when :verbose then 'DEBUG'
61
67
  when :really_verbose then 'TRACE'
62
68
  else 'INFO'
63
69
  end
64
70
  TorqueBox::Logger.log_level = log_level
65
- extension.run(argv, options)
71
+ @extension.run(@argv, @options)
66
72
  else
67
- puts parser
73
+ puts @parser
68
74
  exit 1
69
75
  end
70
76
  end
@@ -104,11 +110,11 @@ module TorqueBox
104
110
  options[:verbosity] = :verbose
105
111
  end
106
112
  end
107
- parser.on_tail('-h', '--help', 'Show this message') do
113
+ parser.on('-h', '--help', 'Show this message') do
108
114
  puts parser
109
115
  exit 1
110
116
  end
111
- parser.on_tail('--version', 'Show version') do
117
+ parser.on('--version', 'Show version') do
112
118
  puts "TorqueBox #{TorqueBox::VERSION}"
113
119
  exit 1
114
120
  end
@@ -0,0 +1,76 @@
1
+ # Copyright 2014 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 'optparse'
16
+
17
+ module TorqueBox
18
+ class CLI
19
+ class Archive
20
+ def initialize(argv)
21
+ @argv = argv
22
+ @main = ENV['TORQUEBOX_MAIN']
23
+ @rackup = ENV['TORQUEBOX_RACKUP']
24
+
25
+ if @main
26
+ @parser = OptionParser.new
27
+ @parser.on('-h', '--help', 'Show this message') do |arg|
28
+ puts @parser
29
+ exit 1
30
+ end
31
+ else
32
+ @cli = TorqueBox::CLI.new(['run'] + @argv)
33
+ @parser = @cli.parser
34
+ end
35
+
36
+ @parser.separator ""
37
+ @parser.separator "Archive options:"
38
+ @parser.on('-S SCRIPT',
39
+ 'Run a script from inside the archive (rake tasks, etc)') do |arg|
40
+ # Treat any unprocessed args as belonging to -S so that things like
41
+ # "java -jar foo.jar -S torquebox help" work without quotes
42
+ arg = ([arg] + @argv).join(' ')
43
+ app_jar = java.lang.System.get_property("torquebox.app_jar")
44
+ load_path = $LOAD_PATH.map { |entry| "-I#{entry}" }.join(' ')
45
+ jars = Dir.glob("../jars/*.jar").map { |j| "-r#{j}" }.join(' ')
46
+ # PWD is $tmpdir/app and jruby.jar is $tmpdir/jars/jruby.jar
47
+ Kernel.exec("java -Dtorquebox.app_jar=#{app_jar} \
48
+ -Djava.io.tmpdir=#{java.lang.System.get_property('java.io.tmpdir')} \
49
+ -jar ../jars/jruby.jar #{load_path} -r#{app_jar} \
50
+ #{jars} -rbundler/setup -rtorquebox/cli/archive_cleaner \
51
+ -S #{arg}")
52
+ end
53
+ end
54
+
55
+ def run
56
+ @parser.parse!(@argv)
57
+
58
+ if @main
59
+ require @main
60
+ else
61
+ require 'torquebox-web'
62
+ if TorqueBox.in_wildfly?
63
+ TorqueBox::Web.run(:rackup => @rackup)
64
+ else
65
+ @cli.run
66
+ end
67
+ end
68
+ rescue OptionParser::InvalidOption => e
69
+ puts e.message
70
+ puts
71
+ puts @parser
72
+ exit 1
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,35 @@
1
+ # Copyright 2014 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 'fileutils'
16
+
17
+ at_exit do
18
+ # Clean up any temporary files left around by our jar unpacking
19
+ # shenanigans. This is only used when executing a script inside
20
+ # an archive, which ends up calling Kernel.exec and bypassing the
21
+ # typical temp file cleaning mechanisms.
22
+ java_tmpdir = File.expand_path(java.lang.System.get_property('java.io.tmpdir'))
23
+ app_jar = java.lang.System.get_property('torquebox.app_jar')
24
+ paths = $LOAD_PATH + [app_jar]
25
+ path_pattern = %r{^(#{java_tmpdir}/wunderboss.+?/).+}
26
+ paths.each do |path|
27
+ path = File.expand_path(path)
28
+ if path =~ path_pattern
29
+ dir = $1
30
+ if Dir.exist?(dir)
31
+ FileUtils.rm_rf(dir)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -22,17 +22,8 @@ module TorqueBox
22
22
  class CLI
23
23
  class Jar
24
24
 
25
- DEFAULT_INIT = "require 'torquebox-web'; \
26
- if org.projectodd.wunderboss.WunderBoss.options.get('wildfly-service').nil?; \
27
- begin; \
28
- TorqueBox::CLI.new(ARGV.unshift('run')); \
29
- rescue SystemExit => e; \
30
- status = e.respond_to?(:status) ? e.status : 0; \
31
- java.lang.System.exit(status); \
32
- end; \
33
- else; \
34
- TorqueBox::Web.run(:rackup => '$$rackup$$'); \
35
- end;"
25
+ DEFAULT_INIT = "require 'torquebox-core'; \
26
+ TorqueBox::CLI::Archive.new(ARGV).run;"
36
27
 
37
28
  def initialize
38
29
  @logger = org.projectodd.wunderboss.WunderBoss.logger('TorqueBox')
@@ -86,6 +77,12 @@ end;"
86
77
  :name => :main,
87
78
  :switch => '--main MAIN',
88
79
  :description => 'File to require to bootstrap the application (if not given, assumes a web app)'
80
+ },
81
+ {
82
+ :name => :exclude,
83
+ :switch => '--exclude EXCLUDES',
84
+ :description => 'File paths to exclude from bundled jar',
85
+ :type => Array
89
86
  }]
90
87
  end
91
88
 
@@ -109,14 +106,14 @@ end;"
109
106
 
110
107
  def run(_argv, options)
111
108
  options = option_defaults.merge(options)
112
- jar_path = File.join(options[:destination], options[:jar_name])
109
+ jar_path = File.expand_path(File.join(options[:destination], options[:jar_name]))
113
110
  @logger.debug("Creating jar with options {}", options.inspect)
114
111
 
112
+ init = DEFAULT_INIT
115
113
  if options[:main]
116
- init = "require '#{options[:main]}'"
117
- else
118
- init = DEFAULT_INIT.sub('$$rackup$$', options[:rackup])
114
+ init = "ENV['TORQUEBOX_MAIN'] = '#{options[:main]}'; #{init}"
119
115
  end
116
+ init = "ENV['TORQUEBOX_RACKUP'] = '#{options[:rackup]}'; #{init}"
120
117
 
121
118
  jar_builder = org.torquebox.core.JarBuilder.new
122
119
  jar_builder.add_manifest_attribute("Main-Class", "org.torquebox.core.TorqueBoxMain")
@@ -128,7 +125,7 @@ end;"
128
125
  add_jruby_files(jar_builder)
129
126
  end
130
127
 
131
- add_app_files(jar_builder)
128
+ add_app_files(jar_builder, options)
132
129
 
133
130
  if options[:bundle_gems]
134
131
  tmpdir = Dir.mktmpdir("tmptorqueboxjar", ".")
@@ -168,13 +165,17 @@ end;"
168
165
  add_jar(jar_builder, "#{rb_config['libdir']}/jruby.jar")
169
166
  end
170
167
 
171
- def add_app_files(jar_builder)
168
+ def add_app_files(jar_builder, options)
172
169
  @logger.trace("Adding application files to jar...")
170
+ exclude = [%r{^/[^/]*\.(jar|war)}]
171
+ if options[:exclude]
172
+ exclude += options[:exclude].map { |e| Regexp.new("^#{e}") }
173
+ end
173
174
  add_files(jar_builder,
174
175
  :file_prefix => Dir.pwd,
175
176
  :pattern => "/**/*",
176
177
  :jar_prefix => "app",
177
- :exclude => [%r{^/[^/]*\.(jar|war)}])
178
+ :exclude => exclude)
178
179
  end
179
180
 
180
181
  def add_bundler_files(jar_builder, tmpdir, bundle_without)
@@ -207,7 +208,7 @@ end;"
207
208
  :pattern => "/{**/*,.bundle/**/*}",
208
209
  :jar_prefix => "app",
209
210
  :exclude => TorqueBox::Jars.list.map { |j| File.basename(j) })
210
- Gem.default_path.each do |prefix|
211
+ Gem.path.each do |prefix|
211
212
  add_files(jar_builder,
212
213
  :file_prefix => prefix,
213
214
  :pattern => "/**/bundler-#{Bundler::VERSION}{*,/**/*}",
@@ -301,7 +302,11 @@ end;"
301
302
  end
302
303
 
303
304
  def eval_in_new_ruby(script)
304
- ruby = org.jruby.Ruby.new_instance
305
+ # Copy our environment to the new Ruby runtime
306
+ config = org.jruby.RubyInstanceConfig.new
307
+ config.environment = ENV
308
+ config.current_directory = Dir.pwd
309
+ ruby = org.jruby.Ruby.new_instance(config)
305
310
  unless %W(DEBUG TRACE).include?(TorqueBox::Logger.log_level)
306
311
  dev_null = PLATFORM =~ /mswin/ ? 'NUL' : '/dev/null'
307
312
  ruby.evalScriptlet("$stdout = File.open('#{dev_null}', 'w')")
@@ -311,7 +316,7 @@ end;"
311
316
 
312
317
  def app_properties(env, init)
313
318
  env_str = env.map do |key, value|
314
- "ENV['#{key}']||='#{value}';"
319
+ "ENV['#{key}'] ||= '#{value}';"
315
320
  end.join(' ')
316
321
  classpath_str = @classpath.join(':')
317
322
 
@@ -56,15 +56,12 @@ module TorqueBox
56
56
  options[:rackup] = argv.shift
57
57
  end
58
58
  options = option_defaults.merge(options)
59
- if options[:env]
60
- options[:envvar]['RACK_ENV'] = options[:env]
61
- options[:envvar]['RAILS_ENV'] = options[:env]
62
- end
59
+ process_env(options)
63
60
  jar_options = options.dup
64
61
  jar_options.delete(:destination)
65
62
  jar_path = super(argv, jar_options)
66
63
  begin
67
- war_path = File.join(options[:destination], options[:war_name])
64
+ war_path = File.expand_path(File.join(options[:destination], options[:war_name]))
68
65
  war_builder = org.torquebox.core.JarBuilder.new
69
66
 
70
67
  (options[:resource_paths] || []).each do |path|
@@ -74,11 +71,12 @@ module TorqueBox
74
71
  :pattern => "**/*")
75
72
  end
76
73
 
74
+ add_main(war_builder)
77
75
  add_web_xml(war_builder)
78
76
  add_jboss_deployment_structure_xml(war_builder)
79
77
  add_jboss_web_xml(war_builder, options)
80
78
 
81
- war_builder.add_file("WEB-INF/lib/#{File.basename(jar_path)}", jar_path)
79
+ war_builder.add_file("WEB-INF/lib/app.jar", jar_path)
82
80
 
83
81
  if File.exist?(war_path)
84
82
  @logger.info("Removing {}", war_path)
@@ -94,6 +92,21 @@ module TorqueBox
94
92
 
95
93
  protected
96
94
 
95
+ def process_env(options)
96
+ if options[:env]
97
+ options[:envvar] ||= {}
98
+ options[:envvar]['RACK_ENV'] = options[:env]
99
+ options[:envvar]['RAILS_ENV'] = options[:env]
100
+ end
101
+ end
102
+
103
+ def add_main(war_builder)
104
+ war_builder.add_manifest_attribute("Main-Class", "org.torquebox.core.TorqueBoxWarMain")
105
+ main_class = org.torquebox.core.TorqueBoxWarMain.java_class
106
+ main_path = main_class.name.gsub(".", "/") + ".class"
107
+ war_builder.add_resource(main_path, main_path)
108
+ end
109
+
97
110
  def add_web_xml(war_builder)
98
111
  unless war_builder.has_entry('WEB-INF/web.xml')
99
112
  war_builder.add_string('WEB-INF/web.xml',
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
  module TorqueBox
17
- VERSION = '4.0.0.alpha1'
18
- WUNDERBOSS_VERSION = '1.x.incremental.174'
17
+ VERSION = '4.0.0.beta1'
18
+ WUNDERBOSS_VERSION = '0.8.0'
19
19
  WILDFLY_VERSION = '8.2.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.alpha1
4
+ version: 4.0.0.beta1
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: 2014-12-04 00:00:00.000000000 Z
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbundler
@@ -76,29 +76,31 @@ files:
76
76
  - bin/torquebox
77
77
  - lib/torquebox-core.jar
78
78
  - lib/torquebox-core.rb
79
- - lib/resources/logback-cli.xml
80
- - lib/wunderboss-jars/slf4j-api-1.7.5.jar
81
- - lib/wunderboss-jars/logback-core-1.1.2.jar
82
- - lib/wunderboss-jars/wunderboss-core-1.x.incremental.174.jar
83
- - lib/wunderboss-jars/wunderboss-wildfly-1.x.incremental.174.jar
84
- - lib/wunderboss-jars/logback-classic-1.1.2.jar
85
- - lib/wunderboss-jars/jboss-logging-3.1.4.GA.jar
86
- - lib/wunderboss-jars/wunderboss-ruby-1.x.incremental.174.jar
87
- - lib/torquebox/logger.rb
88
- - lib/torquebox/option_utils.rb
89
- - lib/torquebox/cli.rb
90
- - lib/torquebox/codecs.rb
91
79
  - lib/torquebox/version.rb
92
80
  - lib/torquebox/spec_helpers.rb
93
- - lib/torquebox/cli/jar.rb
94
- - lib/torquebox/cli/war.rb
81
+ - lib/torquebox/codecs.rb
82
+ - lib/torquebox/option_utils.rb
83
+ - lib/torquebox/logger.rb
84
+ - lib/torquebox/cli.rb
85
+ - lib/torquebox/codecs/marshal_smart.rb
95
86
  - lib/torquebox/codecs/marshal.rb
96
87
  - lib/torquebox/codecs/edn.rb
88
+ - lib/torquebox/codecs/json.rb
97
89
  - lib/torquebox/codecs/marshal_base64.rb
98
- - lib/torquebox/codecs/marshal_smart.rb
99
90
  - lib/torquebox/codecs/text.rb
100
- - lib/torquebox/codecs/json.rb
101
- homepage: http://torquebox.org/torqbox
91
+ - lib/torquebox/cli/archive_cleaner.rb
92
+ - lib/torquebox/cli/war.rb
93
+ - lib/torquebox/cli/jar.rb
94
+ - lib/torquebox/cli/archive.rb
95
+ - lib/wunderboss-jars/wunderboss-ruby-0.8.0.jar
96
+ - lib/wunderboss-jars/logback-classic-1.1.2.jar
97
+ - lib/wunderboss-jars/logback-core-1.1.2.jar
98
+ - lib/wunderboss-jars/wunderboss-core-0.8.0.jar
99
+ - lib/wunderboss-jars/jboss-logging-3.1.4.GA.jar
100
+ - lib/wunderboss-jars/slf4j-api-1.7.5.jar
101
+ - lib/wunderboss-jars/wunderboss-wildfly-0.8.0.jar
102
+ - lib/resources/logback-cli.xml
103
+ homepage: http://torquebox.org/4x
102
104
  licenses:
103
105
  - Apache-2.0
104
106
  metadata: {}
@@ -117,8 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
119
  - !ruby/object:Gem::Version
118
120
  version: 1.3.1
119
121
  requirements:
120
- - jar org.projectodd.wunderboss:wunderboss-ruby, 1.x.incremental.174
121
- - jar org.projectodd.wunderboss:wunderboss-wildfly, 1.x.incremental.174
122
+ - jar org.projectodd.wunderboss:wunderboss-ruby, 0.8.0
123
+ - jar org.projectodd.wunderboss:wunderboss-wildfly, 0.8.0
122
124
  rubyforge_project:
123
125
  rubygems_version: 2.1.9
124
126
  signing_key: