Module: JRubyNotify

Defined in:
lib/jruby-notify.rb,
lib/jruby-notify/notify.rb,
lib/jruby-notify/listener.rb

Defined Under Namespace

Classes: Listener, Notify

Constant Summary collapse

VERSION =
'0.4.0'
FILE_CREATED =
1
FILE_DELETED =
2
FILE_MODIFIED =
4
FILE_RENAMED =
8
FILE_ANY =
FILE_CREATED | FILE_DELETED | FILE_MODIFIED | FILE_RENAMED

Class Method Summary collapse

Class Method Details

.define_library_pathObject

Defines the environment to be able to load the native JNotify libraries



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/jruby-notify.rb', line 35

def self.define_library_path
  library_path = java.lang.System.get_property('java.library.path')
  return if library_path =~ /jnotify/i

  jnotify_library_path = File.expand_path(File.join(File.dirname(__FILE__), 'jnotify', 'shared'))
  new_library_path = [jnotify_library_path, library_path].join(java.io.File.pathSeparator)
  java.lang.System.set_property('java.library.path', new_library_path)

  field = java.lang.Class.for_name('java.lang.ClassLoader').get_declared_field('sys_paths')
  if field
    field.accessible = true
    field.set(java.lang.Class.for_name('java.lang.System').get_class_loader, nil)
  end
end

.supported?Boolean

Tests if the native library can be loaded

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
# File 'lib/jruby-notify.rb', line 21

def self.supported?
  define_library_path
  begin
    Java::NetContentobjectsJNotify::JNotify
    true
  rescue NameError
    false
  end
end