torquebox-core 2.0.3-java → 2.1.0-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.
- data/lib/torquebox-core.jar +0 -0
- data/lib/torquebox-core.rb +2 -2
- data/lib/torquebox/injectors.rb +9 -4
- data/lib/torquebox/logger.rb +5 -1
- data/lib/torquebox/service_registry.rb +8 -3
- data/spec/injectors_spec.rb +12 -0
- data/spec/logger_spec.rb +4 -0
- data/spec/service_registry_spec.rb +6 -0
- metadata +10 -10
data/lib/torquebox-core.jar
CHANGED
Binary file
|
data/lib/torquebox-core.rb
CHANGED
data/lib/torquebox/injectors.rb
CHANGED
@@ -21,17 +21,22 @@ module TorqueBox
|
|
21
21
|
module Injectors
|
22
22
|
|
23
23
|
def self.analyze_and_inject(&block)
|
24
|
-
|
24
|
+
fetch( 'runtime-injection-analyzer' ).analyze_and_inject( block )
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def fetch(something)
|
28
28
|
TorqueBox::Registry[something.to_s]
|
29
29
|
end
|
30
|
-
alias_method :inject, :
|
30
|
+
alias_method :inject, :fetch
|
31
|
+
alias_method :__inject__, :fetch
|
31
32
|
|
32
33
|
%w{ msc service cdi jndi queue topic }.each do |type|
|
33
34
|
define_method("inject_#{type}".to_sym) do |key|
|
34
|
-
|
35
|
+
fetch(key)
|
36
|
+
end
|
37
|
+
|
38
|
+
define_method("fetch_#{type}".to_sym) do |key|
|
39
|
+
fetch(key)
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
data/lib/torquebox/logger.rb
CHANGED
@@ -31,13 +31,14 @@ module TorqueBox
|
|
31
31
|
message = progname
|
32
32
|
progname = @category
|
33
33
|
end
|
34
|
+
message = progname if message.nil?
|
34
35
|
super( severity, message, @category, &block )
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
begin
|
39
40
|
org.jboss.logging::Logger
|
40
|
-
rescue
|
41
|
+
rescue ::NameError
|
41
42
|
Logger = FallbackLogger
|
42
43
|
return
|
43
44
|
end
|
@@ -57,12 +58,15 @@ module TorqueBox
|
|
57
58
|
|
58
59
|
def method_missing(method, *args, &block)
|
59
60
|
delegate = method
|
61
|
+
is_boolean = false
|
60
62
|
if method.to_s.end_with?('?')
|
61
63
|
delegate = "#{method.to_s.chop}_enabled?".to_sym
|
64
|
+
is_boolean = true
|
62
65
|
end
|
63
66
|
self.class.class_eval do
|
64
67
|
define_method(method) do |*a, &b|
|
65
68
|
params = [ a[0] || (b && b.call) ].compact
|
69
|
+
params = [""] if params.empty? && !is_boolean
|
66
70
|
@logger.send(delegate, *params)
|
67
71
|
end
|
68
72
|
end
|
@@ -15,6 +15,7 @@
|
|
15
15
|
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
16
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
17
|
|
18
|
+
require 'java'
|
18
19
|
module TorqueBox
|
19
20
|
class ServiceRegistry
|
20
21
|
|
@@ -25,7 +26,7 @@ module TorqueBox
|
|
25
26
|
lookup name, &block
|
26
27
|
end
|
27
28
|
end
|
28
|
-
|
29
|
+
registry
|
29
30
|
end
|
30
31
|
|
31
32
|
# blocks are not allowed on the method named :[]
|
@@ -34,12 +35,12 @@ module TorqueBox
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def self.lookup(name, &block)
|
37
|
-
if
|
38
|
+
if registry.nil?
|
38
39
|
self.blocks[name] << block
|
39
40
|
nil
|
40
41
|
else
|
41
42
|
name = TorqueBox::ServiceRegistry.service_name_for( name ) if name.is_a? String
|
42
|
-
entry =
|
43
|
+
entry = registry.getService( name )
|
43
44
|
return nil unless entry
|
44
45
|
if block_given?
|
45
46
|
yield entry.getValue()
|
@@ -57,6 +58,10 @@ module TorqueBox
|
|
57
58
|
Java::org.jboss.msc.service.ServiceName.parse( name )
|
58
59
|
end
|
59
60
|
|
61
|
+
def self.registry
|
62
|
+
@service_registry
|
63
|
+
end
|
64
|
+
|
60
65
|
end
|
61
66
|
|
62
67
|
end
|
data/spec/injectors_spec.rb
CHANGED
@@ -17,5 +17,17 @@ describe TorqueBox::Injectors do
|
|
17
17
|
inject_topic('this').should == :that
|
18
18
|
end
|
19
19
|
|
20
|
+
it "should return the same thing for all fetch types" do
|
21
|
+
TorqueBox::Registry.merge!('this' => :that)
|
22
|
+
TorqueBox::Registry['this'].should == :that
|
23
|
+
fetch('this').should == :that
|
24
|
+
fetch_msc('this').should == :that
|
25
|
+
fetch_service('this').should == :that
|
26
|
+
fetch_cdi(:this).should == :that
|
27
|
+
fetch_jndi('this').should == :that
|
28
|
+
fetch_queue('this').should == :that
|
29
|
+
fetch_topic('this').should == :that
|
30
|
+
end
|
31
|
+
|
20
32
|
end
|
21
33
|
|
data/spec/logger_spec.rb
CHANGED
@@ -29,6 +29,11 @@ describe TorqueBox::ServiceRegistry do
|
|
29
29
|
@foo.should eql("bar")
|
30
30
|
end
|
31
31
|
|
32
|
+
it "should make the registry available" do
|
33
|
+
TorqueBox::ServiceRegistry.service_registry = @service_registry
|
34
|
+
TorqueBox::ServiceRegistry.registry.should == @service_registry
|
35
|
+
end
|
36
|
+
|
32
37
|
# Mock a JBoss ServiceRegistry backed by a simple member Hash,
|
33
38
|
# @registry, that holds the fixtures for the tests.
|
34
39
|
before(:each) do
|
@@ -44,3 +49,4 @@ describe TorqueBox::ServiceRegistry do
|
|
44
49
|
end
|
45
50
|
|
46
51
|
end
|
52
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: torquebox-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.0
|
5
|
+
version: 2.1.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- The TorqueBox Team
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-26 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -37,17 +37,17 @@ files:
|
|
37
37
|
- lib/torquebox-core.jar
|
38
38
|
- lib/torquebox-core.rb
|
39
39
|
- lib/gem_hook.rb
|
40
|
-
- lib/torquebox/
|
41
|
-
- lib/torquebox/kernel.rb
|
42
|
-
- lib/torquebox/component_manager.rb
|
40
|
+
- lib/torquebox/registry.rb
|
43
41
|
- lib/torquebox/core.rb
|
42
|
+
- lib/torquebox/component_manager.rb
|
43
|
+
- lib/torquebox/kernel.rb
|
44
44
|
- lib/torquebox/service_registry.rb
|
45
45
|
- lib/torquebox/logger.rb
|
46
|
-
- lib/torquebox/
|
47
|
-
- spec/service_registry_spec.rb
|
48
|
-
- spec/logger_spec.rb
|
46
|
+
- lib/torquebox/injectors.rb
|
49
47
|
- spec/injectors_spec.rb
|
50
48
|
- spec/kernel_spec.rb
|
49
|
+
- spec/logger_spec.rb
|
50
|
+
- spec/service_registry_spec.rb
|
51
51
|
homepage: http://torquebox.org/
|
52
52
|
licenses:
|
53
53
|
- lgpl
|
@@ -76,7 +76,7 @@ signing_key:
|
|
76
76
|
specification_version: 3
|
77
77
|
summary: TorqueBox Core Gem
|
78
78
|
test_files:
|
79
|
-
- spec/service_registry_spec.rb
|
80
|
-
- spec/logger_spec.rb
|
81
79
|
- spec/injectors_spec.rb
|
82
80
|
- spec/kernel_spec.rb
|
81
|
+
- spec/logger_spec.rb
|
82
|
+
- spec/service_registry_spec.rb
|