jmx 0.7 → 0.8

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.
@@ -0,0 +1,8 @@
1
+ !.gitignore
2
+ build
3
+ dist
4
+ *.orig
5
+ *.rej
6
+ *~
7
+ nbproject/private
8
+ pkg
@@ -0,0 +1,24 @@
1
+ == 0.1
2
+
3
+ - Initial release
4
+
5
+ == 0.2
6
+
7
+ - Ruby-created mbeans can now specify r_attribute, rw_attribute, and w_attributes (by Jay McGaffigan)
8
+ - More rdocs
9
+
10
+ == 0.5
11
+
12
+ - Use 'java_import' instead of 'import' to play nice with Rake
13
+ - Use hash of hash in Thread.current so multiple beans don't add each others crud (by bpardee)
14
+
15
+ == 0.6
16
+
17
+ See https://github.com/enebo/jmxjr/issues for details
18
+ - 2: MBean attributes shouldn't be tied to MBean instance variables.
19
+ - 3: MBeans created by another MBean don't have attributes/operations show up
20
+ - 4: Extended MBeans don't have parents operations/attributes.
21
+
22
+ == 0.7
23
+
24
+ - 5: JMX::MBeanProxy#method_missing is broken (removed method_missing. dead)
@@ -12,4 +12,5 @@ lib/jmx/version.rb
12
12
  samples/memory.rb
13
13
  test/jmx_attribute_test.rb
14
14
  test/jmx_client_test.rb
15
+ test/jmx_mangling_test.rb
15
16
  test/jmx_server_test.rb
data/Rakefile CHANGED
@@ -1,27 +1,9 @@
1
- MANIFEST = FileList["Manifest.txt", "Rakefile", "README.md", "LICENSE.txt", "lib/**/*", "samples/*","test/**/*"]
1
+ require 'rake/testtask'
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
2
4
 
3
- file "Manifest.txt" => :manifest
4
- task :manifest do
5
- File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
6
- end
7
- Rake::Task['manifest'].invoke # Always regen manifest, so Hoe has up-to-date list of files
8
-
9
- $LOAD_PATH << 'lib'
10
- require 'jmx/version'
11
- begin
12
- require 'hoe'
13
- Hoe.new("jmx", JMX::VERSION) do |p|
14
- p.rubyforge_name = "jruby-extras"
15
- p.url = "http://github.com/enebo/jmxjr"
16
- p.author = "Thomas Enebo & Jay McGaffigan"
17
- p.email = "tom.enebo@gmail.com"
18
- p.summary = "Package for interacting/creating Java Management Extensions"
19
- p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
20
- p.description = "Install this gem and require 'jmx' to load the library."
21
- end.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
22
- rescue LoadError
23
- puts "You need Hoe installed to be able to package this gem"
24
- rescue => e
25
- p e.backtrace
26
- puts "ignoring error while loading hoe: #{e.to_s}"
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.test_files = FileList['test/*_test.rb']
8
+ t.verbose = true
27
9
  end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "jmx/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'jmx'
7
+ s.version = JMX::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = 'Thomas E. Enebo'
10
+ s.email = 'tom.enebo@gmail.com'
11
+ s.homepage = 'http://github.com/enebo/jmx'
12
+ s.summary = %q{Access and create MBeans in a friendly Ruby syntax}
13
+ s.description = %q{Access and create MBeans in a friendly Ruby syntax}
14
+
15
+ s.rubyforge_project = "jmx"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ s.has_rdoc = true
22
+ end
data/lib/jmx.rb CHANGED
@@ -84,6 +84,8 @@ module JMX
84
84
  # name back to the caller.
85
85
  def self.parent_for(java_class_fqn)
86
86
  java_class_fqn.split(".").inject(MBeans) do |parent, segment|
87
+ # const_defined? will crash later if we don't remove $
88
+ segment.gsub!('$', 'Dollar') if segment =~ /\$/
87
89
  # Note: We are boned if java class name is lower cased
88
90
  return [parent, segment] if segment =~ /^[A-Z]/
89
91
 
@@ -92,7 +92,7 @@ module JMX
92
92
  return object_name if object_name.kind_of? ObjectName
93
93
 
94
94
  ObjectName.new object_name
95
- rescue
95
+ rescue Exception
96
96
  raise ArgumentError.new("Invalid ObjectName #{$!.message}")
97
97
  end
98
98
  end
@@ -1,3 +1,3 @@
1
1
  module JMX
2
- VERSION = "0.7"
2
+ VERSION = "0.8"
3
3
  end
@@ -0,0 +1,6 @@
1
+ javac.classpath=
2
+ main.file=main.rb
3
+ ruby.includejava=false
4
+ source.encoding=UTF-8
5
+ src.dir=lib
6
+ test.src.dir=test
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://www.netbeans.org/ns/project/1">
3
+ <type>org.netbeans.modules.ruby.rubyproject</type>
4
+ <configuration>
5
+ <data xmlns="http://www.netbeans.org/ns/ruby-project/1">
6
+ <name>jmxjr</name>
7
+ <source-roots>
8
+ <root id="src.dir"/>
9
+ </source-roots>
10
+ <test-roots>
11
+ <root id="test.src.dir"/>
12
+ </test-roots>
13
+ </data>
14
+ </configuration>
15
+ </project>
@@ -10,8 +10,7 @@ memory = client["java.lang:type=Memory"]
10
10
 
11
11
  Thread.new do
12
12
  puts "Enter 'gc' to garbage collect or anything else to quit"
13
- while (command = gets.chomp)
14
- break if command != "gc"
13
+ while gets.chomp == "gc"
15
14
  memory.gc
16
15
  end
17
16
 
@@ -5,12 +5,12 @@ require 'rmi'
5
5
  require 'jmx'
6
6
 
7
7
  PORT = 9999
8
- $registry = RMIRegistry.new PORT
9
8
 
10
9
  class JMXConnectorClientTest < Test::Unit::TestCase
11
10
  URL = "service:jmx:rmi:///jndi/rmi://localhost:#{PORT}/jmxrmi"
12
11
 
13
12
  def setup
13
+ @registry = RMIRegistry.new PORT
14
14
  @connector = JMX::MBeanServerConnector.new(URL, JMX::MBeanServer.new)
15
15
  @connector.start
16
16
  @client = JMX::connect(:port => PORT)
@@ -18,6 +18,7 @@ class JMXConnectorClientTest < Test::Unit::TestCase
18
18
 
19
19
  def teardown
20
20
  @connector.stop
21
+ @registry.stop
21
22
  end
22
23
 
23
24
  def test_invalid_mbean_name
@@ -0,0 +1,18 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
2
+
3
+ require 'test/unit'
4
+ require 'jmx'
5
+
6
+ class JMXConnectorClientTest < Test::Unit::TestCase
7
+ def test_that_mbeans_parent_for_handles_classes_with_dollar_sign
8
+ bean_module, class_name = JMX::MBeans.parent_for("evil.dollar.Pre$Middle$Post")
9
+ assert_equal(JMX::MBeans::Evil::Dollar, bean_module)
10
+ assert_equal("PreDollarMiddleDollarPost", class_name)
11
+ end
12
+
13
+ def test_mbeans_parent_for
14
+ bean_module, class_name = JMX::MBeans.parent_for("com.example.JavaClass")
15
+ assert_equal(JMX::MBeans::Com::Example, bean_module)
16
+ assert_equal("JavaClass", class_name)
17
+ end
18
+ end
metadata CHANGED
@@ -1,72 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jmx
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: "0.7"
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 8
8
+ version: "0.8"
6
9
  platform: ruby
7
10
  authors:
8
- - Thomas Enebo & Jay McGaffigan
11
+ - Thomas E. Enebo
9
12
  autorequire:
10
13
  bindir: bin
11
14
  cert_chain: []
12
15
 
13
- date: 2011-04-12 00:00:00 -05:00
16
+ date: 2012-04-20 00:00:00 -05:00
14
17
  default_executable:
15
18
  dependencies: []
16
19
 
17
- description: Install this gem and require 'jmx' to load the library.
20
+ description: Access and create MBeans in a friendly Ruby syntax
18
21
  email: tom.enebo@gmail.com
19
22
  executables: []
20
23
 
21
24
  extensions: []
22
25
 
23
- extra_rdoc_files:
24
- - Manifest.txt
25
- - LICENSE.txt
26
+ extra_rdoc_files: []
27
+
26
28
  files:
27
- - Manifest.txt
28
- - Rakefile
29
- - README.md
30
- - LICENSE.txt
31
- - lib/jmx.rb
32
- - lib/rmi.rb
33
- - lib/jmx/dynamic_mbean.rb
34
- - lib/jmx/notifier.rb
35
- - lib/jmx/server.rb
36
- - lib/jmx/version.rb
37
- - samples/memory.rb
38
- - test/jmx_attribute_test.rb
39
- - test/jmx_client_test.rb
40
- - test/jmx_server_test.rb
41
- - .gemtest
29
+ - .gitignore
30
+ - History.txt
31
+ - LICENSE.txt
32
+ - Manifest.txt
33
+ - README.md
34
+ - Rakefile
35
+ - jmx.gemspec
36
+ - lib/jmx.rb
37
+ - lib/jmx/dynamic_mbean.rb
38
+ - lib/jmx/server.rb
39
+ - lib/jmx/version.rb
40
+ - lib/rmi.rb
41
+ - nbproject/private/private.xml
42
+ - nbproject/project.properties
43
+ - nbproject/project.xml
44
+ - samples/memory.rb
45
+ - test/jmx_attribute_test.rb
46
+ - test/jmx_client_test.rb
47
+ - test/jmx_mangling_test.rb
48
+ - test/jmx_server_test.rb
42
49
  has_rdoc: true
43
- homepage: http://github.com/enebo/jmxjr
50
+ homepage: http://github.com/enebo/jmx
44
51
  licenses: []
45
52
 
46
53
  post_install_message:
47
- rdoc_options:
48
- - --main
49
- - README.txt
54
+ rdoc_options: []
55
+
50
56
  require_paths:
51
- - lib
57
+ - lib
52
58
  required_ruby_version: !ruby/object:Gem::Requirement
53
- none: false
54
59
  requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
58
65
  required_rubygems_version: !ruby/object:Gem::Requirement
59
- none: false
60
66
  requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: "0"
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
64
72
  requirements: []
65
73
 
66
- rubyforge_project: jruby-extras
67
- rubygems_version: 1.5.1
74
+ rubyforge_project: jmx
75
+ rubygems_version: 1.3.6
68
76
  signing_key:
69
77
  specification_version: 3
70
- summary: Package for interacting/creating Java Management Extensions
71
- test_files: []
72
-
78
+ summary: Access and create MBeans in a friendly Ruby syntax
79
+ test_files:
80
+ - test/jmx_attribute_test.rb
81
+ - test/jmx_client_test.rb
82
+ - test/jmx_mangling_test.rb
83
+ - test/jmx_server_test.rb
data/.gemtest DELETED
File without changes
@@ -1,31 +0,0 @@
1
- module JMX
2
- module RubyNotificationEmitter
3
- java_import javax.management.MBeanNotificationInfo
4
-
5
- include javax.management.NotificationEmitter
6
-
7
- def listeners
8
- @listener ||= {}
9
- end
10
-
11
- # NotificationListener listener, NotificationFilter filter, Object handback
12
- def addNotificationListener(listener, filter, handback)
13
- listeners[listener] = [filter, handback]
14
- end
15
-
16
- def getNotificationInfo
17
- [].to_java MBeanNotificationInfo
18
- end
19
-
20
- # NotificationListener listener, NotificationFilter filter, Object handback
21
- def removeNotificationListener(listener, filter=nil, handback=nil)
22
- found = false
23
- listeners.delete_if do |clistener, (cfilter, chandback)|
24
- v = listener == clistener && filter == cfilter && handback == chandback
25
- found = true if v
26
- v
27
- end
28
- raise javax.management.ListenerNotFoundException.new unless found
29
- end
30
- end
31
- end