JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-191

Implement win32ole library using one of the available Java-COM bridges

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: JRuby 0.9.0
    • Fix Version/s: win32ole 0.8
    • Component/s: Extensions, HelpWanted
    • Labels:
      None
    • Number of attachments :
      2

      Description

      We would like to be able to support the win32ole library in Ruby, so that applications that depend on it could run without modification in JRuby. The easiest way to do this would be to wire in one of the available COM/OLE libraries that exists for the JVM.

      I would recommend the Jacob library; it's the library Groovy uses in their own OLE support.

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        I would still love to do this for 1.0...but that's probably not possible and there's too much work involved, so perhaps we can build it as a gem after the fact? It seems like a good candidate to be pulled out of the standard JRuby distribution anyway.

        Show
        Charles Oliver Nutter added a comment - I would still love to do this for 1.0...but that's probably not possible and there's too much work involved, so perhaps we can build it as a gem after the fact? It seems like a good candidate to be pulled out of the standard JRuby distribution anyway.
        Hide
        Rui Lopes added a comment -

        This is my kickoff to implement this extension... you can (YMMV) use the following:

        WIN32OLE.new
        WIN32OLE.connect
        WIN32OLE.each
        WIN32OLE.* (calls method, or gets property value of the underline COM object)
        WIN32OLE.*= (idem for setting a property)

        It has at least one caveat, I don't known how to hook into thread termination to call ComThread.Release(), so the examples\use_explorer_shell_windows.rb seems to hang at the end.

        Under the hood, it uses the Jacob library, though, you'll need to patch it with the attached file.

        I'm not going to implement anything else until I get feedback from you guys! Why? because with only these features it does all I need it to do.

        Best regards,
        Rui Lopes

        Show
        Rui Lopes added a comment - This is my kickoff to implement this extension... you can (YMMV) use the following: WIN32OLE.new WIN32OLE.connect WIN32OLE.each WIN32OLE.* (calls method, or gets property value of the underline COM object) WIN32OLE.*= (idem for setting a property) It has at least one caveat, I don't known how to hook into thread termination to call ComThread.Release(), so the examples\use_explorer_shell_windows.rb seems to hang at the end. Under the hood, it uses the Jacob library, though, you'll need to patch it with the attached file. I'm not going to implement anything else until I get feedback from you guys! Why? because with only these features it does all I need it to do. Best regards, Rui Lopes
        Hide
        Rui Lopes added a comment - - edited

        I forgot the change to this inside WIN32OLE class:

            private IRubyObject jacobToRuby(Variant value) {
                if (value == null || value.isNull())
                    return getRuntime().getNil();
                Object object = value.toJavaObject();
                if (object instanceof Dispatch)
                	return new WIN32OLE(getRuntime(), getType(), (Dispatch) object);
                return JavaUtil.convertJavaToRuby(getRuntime(), object);
          }
        
        Show
        Rui Lopes added a comment - - edited I forgot the change to this inside WIN32OLE class: private IRubyObject jacobToRuby(Variant value) { if (value == null || value.isNull()) return getRuntime().getNil(); Object object = value.toJavaObject(); if (object instanceof Dispatch) return new WIN32OLE(getRuntime(), getType(), (Dispatch) object); return JavaUtil.convertJavaToRuby(getRuntime(), object); }
        Hide
        Charles Oliver Nutter added a comment -

        Wow Rui, I hadn't even noticed you started looking at this. Can we get a followup and try to make this go for 1.1? Even if it's only a partial support for the WIN32OLE library, it would be great to have it!

        Show
        Charles Oliver Nutter added a comment - Wow Rui, I hadn't even noticed you started looking at this. Can we get a followup and try to make this go for 1.1? Even if it's only a partial support for the WIN32OLE library, it would be great to have it!
        Hide
        Charles Oliver Nutter added a comment -

        Removing target release from issues that fit any of the following criteria:

        • No known way to fix them
        • Java integration enhancements out of scope for 1.1 release
        • Other out of scope issues for 1.1
        Show
        Charles Oliver Nutter added a comment - Removing target release from issues that fit any of the following criteria: No known way to fix them Java integration enhancements out of scope for 1.1 release Other out of scope issues for 1.1
        Hide
        Roger Pack added a comment -

        Any update on win32ole for jruby?

        Show
        Roger Pack added a comment - Any update on win32ole for jruby?
        Hide
        Charles Oliver Nutter added a comment -

        Roger: No, unfortunately not. Tom Enebo has experimented with "sort of" implementing win32ole on top of Jacob, but I don't know how far he got. Everyone seems to get a little ways in and then lose interest.

        We'd really love for someone to tackle this and give us something we could commit. I really don't think it would be all that hard to do.

        Show
        Charles Oliver Nutter added a comment - Roger: No, unfortunately not. Tom Enebo has experimented with "sort of" implementing win32ole on top of Jacob, but I don't know how far he got. Everyone seems to get a little ways in and then lose interest. We'd really love for someone to tackle this and give us something we could commit. I really don't think it would be all that hard to do.
        Hide
        Brian McDevitt added a comment -

        I've taken Rui Lopes project and updated it to use the JRuby annotations instead of the call backs. Comments and suggestions welcome. Check out the code at http://github.com/bpmcd/win32ole

        Show
        Brian McDevitt added a comment - I've taken Rui Lopes project and updated it to use the JRuby annotations instead of the call backs. Comments and suggestions welcome. Check out the code at http://github.com/bpmcd/win32ole
        Hide
        Hiro Asari added a comment -

        Can we promote this library a bit? I tested it wee bit on VMWare, but we obviously need more eyes on it. Perhaps we can include it in 1.5 RC1.

        If you're working with Brian's repo, be advised that the maven project properties need some tweaking (jruby.jar path, that is).

        Show
        Hiro Asari added a comment - Can we promote this library a bit? I tested it wee bit on VMWare, but we obviously need more eyes on it. Perhaps we can include it in 1.5 RC1. If you're working with Brian's repo, be advised that the maven project properties need some tweaking (jruby.jar path, that is).
        Hide
        Roger Pack added a comment -

        looks like the jruby-win32ole gem is the new standard here...

        http://stackoverflow.com/questions/3340119/win32ole-gem-for-jruby

        Show
        Roger Pack added a comment - looks like the jruby-win32ole gem is the new standard here... http://stackoverflow.com/questions/3340119/win32ole-gem-for-jruby
        Hide
        Charles Oliver Nutter added a comment -

        After a herculean effort by Tom Enebo, we now have the jruby-win32ole gem! It targets Ruby 1.9.2's win32ole API, and may not be complete...but it's largely there, and we can call this bug resolved.

        Any missing or broken parts of win32ole should be filed as new issues.

        Thanks also to Audentes Technology LLC, who funded Tom's work.

        Show
        Charles Oliver Nutter added a comment - After a herculean effort by Tom Enebo, we now have the jruby-win32ole gem! It targets Ruby 1.9.2's win32ole API, and may not be complete...but it's largely there, and we can call this bug resolved. Any missing or broken parts of win32ole should be filed as new issues. Thanks also to Audentes Technology LLC, who funded Tom's work.
        Hide
        Roger Pack added a comment -

        it's working well for me so far

        Show
        Roger Pack added a comment - it's working well for me so far
        Hide
        Charles Oliver Nutter added a comment -

        Thanks for the update Roger! Let us know if you run into any issues, and just file bugs for win32ole in JRuby's tracker (there are versions listed for it now).

        Show
        Charles Oliver Nutter added a comment - Thanks for the update Roger! Let us know if you run into any issues, and just file bugs for win32ole in JRuby's tracker (there are versions listed for it now).
        Hide
        Roger Pack added a comment -

        I hope it gets incorporated soon, as currently I have to work around this message:

        C:\dev\ruby\sensible-cinema>java -client -Xmx500m -Xss1024k -Djruby.memory.max=500m -Djruby.stack.max=1024k -cp "./vendor/cache/jruby-complete-1.5.5.jar" org.jruby.Main bin\sensible-cinema
        Loading Sensible Cinema...
        !!!! Missing jruby-win32ole gem: jruby -S gem install jruby-win32ole
        file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem jruby-win32ole (>= 0) (Gem::LoadError)

        from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems.rb:211:in `activate'
        from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems.rb:1056:in `gem'
        from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/jruby/win32ole/stub.rb:3
        from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/jruby/win32ole/stub.rb:31:in `require'
        from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext/win32ole_ext.rb:1
        from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext/win32ole_ext.rb:31:in `require'
        from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext.rb:1
        from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext.rb:1:in `each'
        from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext.rb:1
        from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext.rb:31:in `require'
        from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi.rb:4
        from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi.rb:31:in `require'
        from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from bin\sensible-cinema:16

        (even though I have the jruby-win32ole gem's lib dir in my $ by creating a fake
        'win32ole.rb' file that does
        require 'jruby-win32ole'
        Cheers!

        Show
        Roger Pack added a comment - I hope it gets incorporated soon, as currently I have to work around this message: C:\dev\ruby\sensible-cinema>java -client -Xmx500m -Xss1024k -Djruby.memory.max=500m -Djruby.stack.max=1024k -cp "./vendor/cache/jruby-complete-1.5.5.jar" org.jruby.Main bin\sensible-cinema Loading Sensible Cinema... !!!! Missing jruby-win32ole gem: jruby -S gem install jruby-win32ole file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem jruby-win32ole (>= 0) (Gem::LoadError) from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems.rb:211:in `activate' from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems.rb:1056:in `gem' from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/jruby/win32ole/stub.rb:3 from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/shared/jruby/win32ole/stub.rb:31:in `require' from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext/win32ole_ext.rb:1 from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext/win32ole_ext.rb:31:in `require' from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext.rb:1 from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext.rb:1:in `each' from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext.rb:1 from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi/core_ext.rb:31:in `require' from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi.rb:4 from C:/dev/ruby/sensible-cinema/vendor/cache/rdp-ruby-wmi-0.3.1/lib/ruby-wmi.rb:31:in `require' from file:/C:/dev/ruby/sensible-cinema/vendor/cache/jruby-complete-1.5.5.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from bin\sensible-cinema:16 (even though I have the jruby-win32ole gem's lib dir in my $ by creating a fake 'win32ole.rb' file that does require 'jruby-win32ole' Cheers!
        Hide
        Thomas E Enebo added a comment -

        Roger why aren't you just installing the gem? It should work fine in 1.5.5 once installed.

        Show
        Thomas E Enebo added a comment - Roger why aren't you just installing the gem? It should work fine in 1.5.5 once installed.
        Hide
        Roger Pack added a comment -

        This is me distributing an app using the jruby-complete-1.5.5.jar...I'm not sure why it required what it does though.

        Show
        Roger Pack added a comment - This is me distributing an app using the jruby-complete-1.5.5.jar...I'm not sure why it required what it does though.

          People

          • Assignee:
            Thomas E Enebo
            Reporter:
            Charles Oliver Nutter
          • Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: