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

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,36 +1,37 @@
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
  require 'base64'
19
16
 
17
+ java_import org.projectodd.wunderboss.codecs.StringCodec
18
+
20
19
  module TorqueBox
21
20
  module Codecs
22
- module MarshalBase64
23
- class << self
21
+ class MarshalBase64 < StringCodec
24
22
 
25
- def encode(data)
26
- Base64.encode64(::Marshal.dump(data)) unless data.nil?
27
- end
23
+ def initialize
24
+ super("marshal_base64", "application/ruby-marshal-base64")
25
+ end
28
26
 
29
- def decode(data)
30
- ::Marshal.restore(Base64.decode64(data)) unless data.nil?
31
- end
32
-
27
+ def encode(data)
28
+ Base64.encode64(::Marshal.dump(data)) unless data.nil?
33
29
  end
30
+
31
+ def decode(data)
32
+ ::Marshal.restore(Base64.decode64(data)) unless data.nil?
33
+ end
34
+
34
35
  end
35
36
  end
36
37
  end
@@ -1,49 +1,50 @@
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
  require 'base64'
19
16
 
17
+ java_import org.projectodd.wunderboss.codecs.StringCodec
18
+
20
19
  module TorqueBox
21
20
  module Codecs
22
- module MarshalSmart
23
- class << self
21
+ class MarshalSmart < StringCodec
22
+
23
+ def initialize
24
+ super("marshal_smart", "application/ruby-marshal-smart")
25
+ end
24
26
 
25
- # @api private
26
- MARSHAL_MARKER = "_|marshalled|_"
27
+ # @api private
28
+ MARSHAL_MARKER = "_|marshalled|_"
27
29
 
28
- def encode(object)
29
- case object
30
- when String, Numeric, true, false, nil
30
+ def encode(object)
31
+ case object
32
+ when String, Numeric, true, false, nil
33
+ object
34
+ else
35
+ if object.respond_to?(:java_object)
31
36
  object
32
37
  else
33
- if object.respond_to?(:java_object)
34
- object
35
- else
36
- MARSHAL_MARKER + Base64.encode64(::Marshal.dump(object))
37
- end
38
+ MARSHAL_MARKER + Base64.encode64(::Marshal.dump(object))
38
39
  end
39
40
  end
41
+ end
40
42
 
41
- def decode(object)
42
- if object.is_a?(String) && object.start_with?(MARSHAL_MARKER)
43
- object = ::Marshal.load(Base64.decode64(object.sub(MARSHAL_MARKER, '')))
44
- end
45
- object
43
+ def decode(object)
44
+ if object.is_a?(String) && object.start_with?(MARSHAL_MARKER)
45
+ object = ::Marshal.load(Base64.decode64(object.sub(MARSHAL_MARKER, '')))
46
46
  end
47
+ object
47
48
  end
48
49
 
49
50
  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
+ java_import org.projectodd.wunderboss.codecs.StringCodec
16
+
17
+ module TorqueBox
18
+ module Codecs
19
+ class Text < StringCodec
20
+
21
+ def initialize
22
+ super("text", "text/plain")
23
+ end
24
+
25
+ def encode(data)
26
+ data.to_s
27
+ end
28
+
29
+ def decode(data)
30
+ data
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -1,137 +1,27 @@
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 'logger'
19
15
 
20
16
  module TorqueBox
21
-
22
- # @api private
23
- class FallbackLogger < ::Logger
24
-
25
- attr_accessor :formatter
26
-
27
- def initialize name = nil
28
- super(ENV['TORQUEBOX_FALLBACK_LOGFILE'] || $stderr)
29
- @category = name || (TORQUEBOX_APP_NAME if defined? TORQUEBOX_APP_NAME) || "TorqueBox"
30
- @formatter = ::Logger::Formatter.new
31
- end
32
-
33
- def add(severity, message, progname, &block)
34
- if ( message.nil? && block.nil? )
35
- message = progname
36
- progname = @category
37
- end
38
- message = progname if message.nil?
39
- super( severity, message, @category, &block )
40
- end
41
-
42
- # Allow our logger to be used for env['rack.errors']
43
- def puts(message)
44
- info message.to_s
45
- end
46
- def write(message)
47
- info message.strip
48
- end
49
- def flush
50
- end
51
- end
52
-
53
- begin
54
- org.jboss.logging::Logger
55
- rescue ::NameError
56
- Logger = FallbackLogger
57
- end
58
-
59
17
  class Logger
18
+ class << self
19
+ attr_reader :log_level
60
20
 
61
- attr_accessor :formatter
62
-
63
- def initialize name = nil
64
- category = name || (TORQUEBOX_APP_NAME if defined? TORQUEBOX_APP_NAME) || "TorqueBox"
65
- @logger = org.jboss.logging::Logger.getLogger( category.to_s.gsub('::','.') )
66
- @formatter = ::Logger::Formatter.new
67
- end
68
-
69
- [:warn?, :error?, :fatal?].each do |method|
70
- define_method(method) { true }
71
- end
72
-
73
- def info?
74
- @logger.info_enabled?
75
- end
76
-
77
- def debug?
78
- @logger.debug_enabled?
79
- end
80
-
81
- def trace?
82
- @logger.trace_enabled?
83
- end
84
-
85
- # The minimum log level to actually log, with debug being the lowest
86
- # and fatal the highest
87
- attr_accessor :level
88
-
89
- def add(severity, message, progname, &block)
90
- severities = ['debug', 'info', 'warn', 'error', 'fatal']
91
- # default to warn for unknown log level since jboss logger
92
- # doesn't support unknown
93
- delegate = severity > (severities.length - 1) ? 'warn' : severities[severity]
94
- params = params_for_logger([message, progname], block)
95
- @logger.send(delegate, *params)
96
- end
97
-
98
- # @!method debug(message)
99
- # @param [String] message The message to log
100
- # @!method info(message)
101
- # @param [String] message The message to log
102
- # @!method warn(message)
103
- # @param [String] message The message to log
104
- # @!method error(message)
105
- # @param [String] message The message to log
106
- # @!method fatal(message)
107
- # @param [String] message The message to log
108
- def method_missing(method, *args, &block)
109
- delegate = method
110
- self.class.class_eval do
111
- define_method(method) do |*a, &b|
112
- params = params_for_logger(a, b)
113
- params = [""] if params.empty?
114
- @logger.send(delegate, *params)
115
- end
21
+ def log_level=(level)
22
+ @log_level = level
23
+ org.projectodd.wunderboss.WunderBoss.log_level = level
116
24
  end
117
- self.send(method, *args, &block)
118
25
  end
119
-
120
- # Allow our logger to be used for env['rack.errors']
121
- def puts(message)
122
- info message.to_s
123
- end
124
- def write(message)
125
- info message.strip
126
- end
127
- def flush
128
- end
129
-
130
- private
131
-
132
- def params_for_logger(args, block)
133
- [ args[0] || (block && block.call) ].compact
134
- end
135
-
136
- end unless defined?(TorqueBox::Logger)
26
+ end
137
27
  end
@@ -0,0 +1,72 @@
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 'set'
16
+
17
+ module TorqueBox
18
+ module OptionUtils
19
+ protected
20
+
21
+ def validate_options(options, valid_keys)
22
+ options.keys.each do |key|
23
+ unless valid_keys.include?(key)
24
+ fail ArgumentError.new("#{key} is not a valid option")
25
+ end
26
+ end
27
+ end
28
+
29
+ def opts_to_hash(opts_class)
30
+ org.projectodd.wunderboss.Option.optsFor(opts_class).reduce({}) do |hash, entry|
31
+ hash[entry.name.to_sym] = entry
32
+ hash
33
+ end
34
+ end
35
+
36
+ def opts_to_set(opts_class)
37
+ Set.new(opts_to_hash(opts_class).keys)
38
+ end
39
+
40
+ def optset(*things)
41
+ set = Set.new
42
+ things.each do |thing|
43
+ if thing.is_a?(Symbol)
44
+ set << thing
45
+ elsif thing.is_a?(Enumerable)
46
+ set += thing
47
+ else
48
+ set += opts_to_set(thing)
49
+ end
50
+ end
51
+ set
52
+ end
53
+
54
+ def option_defaults(opts_class)
55
+ org.projectodd.wunderboss.Option.optsFor(opts_class).reduce({}) do |hash, entry|
56
+ hash[entry.name.to_sym] = entry.defaultValue
57
+ hash
58
+ end
59
+ end
60
+
61
+ def extract_options(options, opts_class)
62
+ opts_hash = opts_to_hash(opts_class)
63
+ extracted_options = {}
64
+ options.each_pair do |key, value|
65
+ if opts_hash.include?(key)
66
+ extracted_options[opts_hash[key]] = value.is_a?(Symbol) ? value.to_s : value
67
+ end
68
+ end
69
+ extracted_options
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,48 @@
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
+ require 'tempfile'
17
+
18
+ module TorqueBox
19
+ # @api private
20
+ class SpecHelpers
21
+
22
+ def self.boot_marker_env_key
23
+ "TORQUEBOX_SPEC_BOOT_MARKER"
24
+ end
25
+
26
+ def self.set_boot_marker
27
+ boot_marker = Tempfile.new('tb_spec_boot_marker')
28
+ ENV[boot_marker_env_key] = boot_marker.path
29
+ boot_marker.close
30
+ boot_marker.unlink
31
+ end
32
+
33
+ def self.clear_boot_marker
34
+ if ENV[boot_marker_env_key]
35
+ FileUtils.rm_f(ENV[boot_marker_env_key])
36
+ ENV[boot_marker_env_key] = nil
37
+ end
38
+ end
39
+
40
+ def self.booted
41
+ File.open(ENV[boot_marker_env_key], "w") {} if ENV[boot_marker_env_key]
42
+ end
43
+
44
+ def self.booted?
45
+ File.exist?(ENV[boot_marker_env_key])
46
+ end
47
+ end
48
+ end