Skip to content

Instantly share code, notes, and snippets.

@mlooney
Created October 26, 2010 16:57
Show Gist options
  • Save mlooney/647287 to your computer and use it in GitHub Desktop.
Save mlooney/647287 to your computer and use it in GitHub Desktop.
// Locate update methods
Method subscriptionMethod = null;
ArrayList<Method> updateMethods = new ArrayList<Method>();
for (Method method : subscriber.getClass().getMethods())
{
if ((method.getName().equals("update")) &&
(Modifier.isPublic(method.getModifiers())))
{
updateMethods.add(method);
}
}
// none found
if (updateMethods.size() == 0)
{
String message = "Subscriber object does not provide a public method by name 'update'";
throw new EPSubscriberException(message);
}
@nicksieger
Copy link

Declare method signatures for ruby methods and use become_java! on the Ruby class?

@mlooney
Copy link
Author

mlooney commented Oct 26, 2010

Wow! example?

@mlooney
Copy link
Author

mlooney commented Oct 26, 2010

Booo! jruby sucks!

1.1.6 fwiw

lib/temp_subscriber.rb:9: undefined method `add_method_signature' for TempSubscriber:Class (NoMethodError)
from lib/temp_subscriber.rb:5:in `require'
from cep.rb:5



require 'java'
require 'jruby/core_ext'
class TempSubscriber
  def update(f, cid)
    puts "avg temp is #{f} for customer #{cid}. woo!"
  end
end
TempSubscriber.add_method_signature("update", [java.lang.Void::TYPE, java.lang.Float::TYPE, java.lang.String.java_class])
TempSubscriber.become_java!

@mlooney
Copy link
Author

mlooney commented Oct 26, 2010

durr. 1.1.6 < 1.6.*

@nicksieger
Copy link

hmm. out of date examples? does java_signature work? what about jrubyc? see http://github.com/nicksieger/java-from-ruby-examples/blob/master/compile/compile.rb for example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment