torquebox-core 3.2.0-java → 4.0.0.alpha1-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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/bin/torquebox +20 -0
  3. data/lib/resources/logback-cli.xml +12 -0
  4. data/lib/torquebox-core.jar +0 -0
  5. data/lib/torquebox-core.rb +51 -10
  6. data/lib/torquebox/cli.rb +129 -0
  7. data/lib/torquebox/cli/jar.rb +336 -0
  8. data/lib/torquebox/cli/war.rb +140 -0
  9. data/lib/torquebox/codecs.rb +35 -36
  10. data/lib/torquebox/codecs/edn.rb +39 -24
  11. data/lib/torquebox/codecs/json.rb +45 -44
  12. data/lib/torquebox/codecs/marshal.rb +25 -25
  13. data/lib/torquebox/codecs/marshal_base64.rb +26 -25
  14. data/lib/torquebox/codecs/marshal_smart.rb +34 -33
  15. data/lib/torquebox/codecs/text.rb +35 -0
  16. data/lib/torquebox/logger.rb +19 -129
  17. data/lib/torquebox/option_utils.rb +72 -0
  18. data/lib/torquebox/spec_helpers.rb +48 -0
  19. data/lib/torquebox/version.rb +20 -0
  20. data/lib/wunderboss-jars/jboss-logging-3.1.4.GA.jar +0 -0
  21. data/lib/wunderboss-jars/logback-classic-1.1.2.jar +0 -0
  22. data/lib/wunderboss-jars/logback-core-1.1.2.jar +0 -0
  23. data/lib/wunderboss-jars/slf4j-api-1.7.5.jar +0 -0
  24. data/lib/wunderboss-jars/wunderboss-core-1.x.incremental.174.jar +0 -0
  25. data/lib/wunderboss-jars/wunderboss-ruby-1.x.incremental.174.jar +0 -0
  26. data/lib/wunderboss-jars/wunderboss-wildfly-1.x.incremental.174.jar +0 -0
  27. metadata +71 -61
  28. data/lib/gem_hook.rb +0 -18
  29. data/lib/torquebox/component_manager.rb +0 -32
  30. data/lib/torquebox/core.rb +0 -29
  31. data/lib/torquebox/injectors.rb +0 -81
  32. data/lib/torquebox/kernel.rb +0 -47
  33. data/lib/torquebox/msc.rb +0 -98
  34. data/lib/torquebox/registry.rb +0 -52
  35. data/lib/torquebox/scheduled_job.rb +0 -245
  36. data/lib/torquebox/service.rb +0 -77
  37. data/lib/torquebox/service_registry.rb +0 -68
  38. data/licenses/cc0-1.0.txt +0 -121
  39. data/spec/codecs_spec.rb +0 -87
  40. data/spec/injectors_spec.rb +0 -28
  41. data/spec/kernel_spec.rb +0 -47
  42. data/spec/logger_spec.rb +0 -103
  43. data/spec/scheduled_job_spec.rb +0 -57
  44. data/spec/service_registry_spec.rb +0 -52
@@ -0,0 +1,140 @@
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 'torquebox-core'
16
+
17
+ module TorqueBox
18
+ class CLI
19
+ class War < Jar
20
+
21
+ def usage_parameters
22
+ "[options] [rackup_file]"
23
+ end
24
+
25
+ def option_defaults
26
+ super.merge(:war_name => "#{File.basename(Dir.pwd)}.war")
27
+ end
28
+
29
+ def available_options
30
+ super
31
+ .reject { |v| v[:name] == :jar_name }
32
+ .unshift(:name => :war_name,
33
+ :switch => '--name NAME',
34
+ :description => "Name of the war file (default: #{option_defaults[:war_name]})")
35
+ .push(:name => :resource_paths,
36
+ :switch => '--resource-paths PATHS',
37
+ :description => "Paths whose contents will be included at the top-level of the war\
38
+ (default: none)",
39
+ :type => Array)
40
+ .push(:name => :context_path,
41
+ :switch => '--context-path PATH',
42
+ :description => "Deploys the war to the given context path (default: the name of\
43
+ the war)")
44
+ .push(:name => :virtual_host,
45
+ :switch => '--virtual-host HOST',
46
+ :description => "Deploys the war to the named host defined in the WildFly config\
47
+ (default: none)")
48
+ .push(:name => :env,
49
+ :switch => '--env ENVIRONMENT',
50
+ :short => '-e',
51
+ :description => "Environment to run under (default: development)")
52
+ end
53
+
54
+ def run(argv, options)
55
+ unless argv.empty?
56
+ options[:rackup] = argv.shift
57
+ end
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
63
+ jar_options = options.dup
64
+ jar_options.delete(:destination)
65
+ jar_path = super(argv, jar_options)
66
+ begin
67
+ war_path = File.join(options[:destination], options[:war_name])
68
+ war_builder = org.torquebox.core.JarBuilder.new
69
+
70
+ (options[:resource_paths] || []).each do |path|
71
+ @logger.info("Copying contents of {} to war", path)
72
+ add_files(war_builder,
73
+ :file_prefix => path,
74
+ :pattern => "**/*")
75
+ end
76
+
77
+ add_web_xml(war_builder)
78
+ add_jboss_deployment_structure_xml(war_builder)
79
+ add_jboss_web_xml(war_builder, options)
80
+
81
+ war_builder.add_file("WEB-INF/lib/#{File.basename(jar_path)}", jar_path)
82
+
83
+ if File.exist?(war_path)
84
+ @logger.info("Removing {}", war_path)
85
+ FileUtils.rm_f(war_path)
86
+ end
87
+ @logger.info("Writing {}", war_path)
88
+ war_builder.create(war_path)
89
+ ensure
90
+ @logger.info("Removing {}", jar_path)
91
+ FileUtils.rm_f(jar_path)
92
+ end
93
+ end
94
+
95
+ protected
96
+
97
+ def add_web_xml(war_builder)
98
+ unless war_builder.has_entry('WEB-INF/web.xml')
99
+ war_builder.add_string('WEB-INF/web.xml',
100
+ read_base_xml('web.xml'))
101
+ end
102
+ end
103
+
104
+ def add_jboss_deployment_structure_xml(war_builder)
105
+ unless war_builder.has_entry('WEB-INF/jboss-deployment-structure.xml')
106
+ war_builder.add_string('WEB-INF/jboss-deployment-structure.xml',
107
+ read_base_xml('jboss-deployment-structure.xml'))
108
+ end
109
+ end
110
+
111
+ def add_jboss_web_xml(war_builder, options)
112
+ jboss_web = 'WEB-INF/jboss-web.xml'
113
+ context_path = options[:context_path]
114
+ virtual_host = options[:virtual_host]
115
+
116
+ if context_path || virtual_host
117
+ if war_builder.has_entry(jboss_web)
118
+ @logger.warn("context-path or virtual-host specified, but a #{jboss_web} exists in\
119
+ resource-paths. Ignoring options.")
120
+ else
121
+ root_el = context_path ? " <context-root>#{context_path}</context-root>\n" : ''
122
+ host_el = virtual_host ? " <virtual-host>#{virtual_host}</virtual-host>\n" : ''
123
+ war_builder.add_string(jboss_web,
124
+ "<jboss-web>\n#{root_el}#{host_el}</jboss-web>")
125
+ end
126
+ end
127
+ end
128
+
129
+ def read_base_xml(name)
130
+ java.lang.Thread.current_thread
131
+ .context_class_loader
132
+ .resource_as_string("base-xml/#{name}")
133
+ end
134
+
135
+ end
136
+ end
137
+ end
138
+
139
+ TorqueBox::CLI.register_extension('war', TorqueBox::CLI::War.new,
140
+ 'Create a deployable war from an application')
@@ -1,55 +1,44 @@
1
- # Copyright 2008-2013 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
+ # 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.
17
14
 
18
15
  # These codecs don't depend on anything outside Ruby stdlib
19
16
  require 'torquebox/codecs/marshal'
20
17
  require 'torquebox/codecs/marshal_base64'
21
18
  require 'torquebox/codecs/marshal_smart'
19
+ require 'torquebox/codecs/text'
22
20
 
23
21
  # These codecs depend on external gems - attempt to load them
24
22
  # but ignore any load errors and we'll lazily try again later
25
23
  require 'torquebox/codecs/json' rescue nil
26
24
  require 'torquebox/codecs/edn' rescue nil
27
25
 
26
+ java_import org.projectodd.wunderboss.codecs.Codecs
27
+ java_import org.projectodd.wunderboss.codecs.None
28
+
28
29
  module TorqueBox
29
30
  module Codecs
30
31
  class << self
31
32
 
33
+ def add(codec)
34
+ java_codecs.add(codec)
35
+ self
36
+ end
37
+
32
38
  def [](key)
33
- case key
34
- when :edn
35
- # This is only so any issues requiring the edn codec bubble
36
- # up when it gets used
37
- require 'torquebox/codecs/edn' unless defined?(TorqueBox::Codecs::EDN)
38
- TorqueBox::Codecs::EDN
39
- when :json
40
- # This is only so any issues requiring the json codec bubble
41
- # up when it gets used
42
- require 'torquebox/codecs/json' unless defined?(TorqueBox::Codecs::JSON)
43
- TorqueBox::Codecs::JSON
44
- when :marshal
45
- TorqueBox::Codecs::Marshal
46
- when :marshal_base64
47
- MarshalBase64
48
- when :marshal_smart
49
- MarshalSmart
50
- else
51
- raise "Unsupported codec #{key}"
52
- end
39
+ java_codecs.for_content_type(key.to_s) ||
40
+ java_codecs.for_name(key.to_s) ||
41
+ fail("Unsupported codec #{key}")
53
42
  end
54
43
 
55
44
  def encode(data, encoding)
@@ -60,6 +49,16 @@ module TorqueBox
60
49
  self[encoding].decode(data)
61
50
  end
62
51
 
52
+ def java_codecs
53
+ @codecs ||= org.projectodd.wunderboss.codecs.Codecs.new
54
+ end
63
55
  end
64
56
  end
65
57
  end
58
+
59
+ TorqueBox::Codecs.add(TorqueBox::Codecs::EDN.new)
60
+ TorqueBox::Codecs.add(TorqueBox::Codecs::JSON.new)
61
+ TorqueBox::Codecs.add(TorqueBox::Codecs::Marshal.new)
62
+ TorqueBox::Codecs.add(TorqueBox::Codecs::MarshalBase64.new)
63
+ TorqueBox::Codecs.add(TorqueBox::Codecs::MarshalSmart.new)
64
+ TorqueBox::Codecs.add(TorqueBox::Codecs::Text.new)
@@ -1,36 +1,51 @@
1
- # Copyright 2008-2013 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
+ # 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.
17
14
 
18
- require 'edn'
15
+ java_import org.projectodd.wunderboss.codecs.StringCodec
19
16
 
20
17
  module TorqueBox
21
18
  module Codecs
22
- module EDN
23
- class << self
19
+ class EDN < StringCodec
24
20
 
25
- def encode(data)
26
- data.to_edn
27
- end
21
+ def initialize
22
+ super("edn", "application/edn")
23
+ end
28
24
 
29
- def decode(data)
30
- ::EDN.read(data) unless data.nil?
25
+ # @api private
26
+ def require_edn
27
+ # We don't ship our own edn, but can use it if the user
28
+ # installs it.
29
+ unless defined?(::EDN)
30
+ begin
31
+ require 'edn'
32
+ rescue LoadError
33
+ raise RuntimeError.new("Unable to load the edn gem. Verify that "\
34
+ "is installed and in your Gemfile (if using Bundler)")
35
+ end
31
36
  end
37
+ end
32
38
 
39
+ def encode(data)
40
+ require_edn
41
+ data.to_edn
33
42
  end
43
+
44
+ def decode(data)
45
+ require_edn
46
+ ::EDN.read(data) unless data.nil?
47
+ end
48
+
34
49
  end
35
50
  end
36
51
  end
@@ -1,61 +1,62 @@
1
- # Copyright 2008-2013 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
+ # 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.
17
14
 
15
+ java_import org.projectodd.wunderboss.codecs.StringCodec
18
16
 
19
17
  module TorqueBox
20
18
  module Codecs
21
- module JSON
22
- class << self
19
+ class JSON < StringCodec
23
20
 
24
- # @api private
25
- def require_json
26
- # We can't ship our own json, as it may collide with the gem
27
- # requirement for the app.
28
- if !defined?( ::JSON )
29
- begin
30
- require 'json'
31
- rescue LoadError => ex
32
- raise RuntimeError.new( "Unable to load the json gem. Verify that is installed and in your Gemfile (if using Bundler)" )
33
- end
34
- end
35
- end
21
+ def initialize
22
+ super("json", "application/json")
23
+ end
36
24
 
37
- def encode(data)
38
- require_json
25
+ # @api private
26
+ def require_json
27
+ # We can't ship our own json, as it may collide with the gem
28
+ # requirement for the app.
29
+ unless defined?(::JSON)
39
30
  begin
40
- if ( data.respond_to?( :as_json ) )
41
- data = data.as_json
42
- end
43
- ::JSON.fast_generate( data ) unless data.nil?
44
- rescue ::JSON::GeneratorError
45
- ::JSON.dump(data)
31
+ require 'json'
32
+ rescue LoadError
33
+ raise RuntimeError.new("Unable to load the json gem. Verify that "\
34
+ "is installed and in your Gemfile (if using Bundler)")
46
35
  end
47
36
  end
37
+ end
48
38
 
49
- def decode(data)
50
- require_json
51
- begin
52
- ::JSON.parse( data, :symbolize_names => true ) unless data.nil?
53
- rescue ::JSON::ParserError
54
- ::JSON.load(data)
39
+ def encode(data)
40
+ require_json
41
+ begin
42
+ if data.respond_to?(:as_json)
43
+ data = data.as_json
55
44
  end
45
+ ::JSON.fast_generate(data) unless data.nil?
46
+ rescue ::JSON::GeneratorError
47
+ ::JSON.dump(data)
56
48
  end
49
+ end
57
50
 
51
+ def decode(data)
52
+ require_json
53
+ begin
54
+ ::JSON.parse(data, :symbolize_names => true) unless data.nil?
55
+ rescue ::JSON::ParserError
56
+ ::JSON.load(data)
57
+ end
58
58
  end
59
+
59
60
  end
60
61
  end
61
62
  end
@@ -1,35 +1,35 @@
1
- # Copyright 2008-2013 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
+ # 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.
17
14
 
15
+ java_import org.projectodd.wunderboss.codecs.BytesCodec
18
16
 
19
17
  module TorqueBox
20
18
  module Codecs
21
- module Marshal
22
- class << self
19
+ class Marshal < BytesCodec
23
20
 
24
- def encode(data)
25
- ::Marshal.dump(data) unless data.nil?
26
- end
27
-
28
- def decode(data)
29
- ::Marshal.restore(data) unless data.nil?
30
- end
21
+ def initialize
22
+ super("marshal", "application/ruby-marshal")
23
+ end
24
+
25
+ def encode(data)
26
+ ::Marshal.dump(data).to_java_bytes unless data.nil?
27
+ end
31
28
 
29
+ def decode(data)
30
+ ::Marshal.restore(String.from_java_bytes(data)) unless data.nil?
32
31
  end
32
+
33
33
  end
34
34
  end
35
35
  end