Created
October 26, 2010 16:57
-
-
Save mlooney/647287 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} |
Wow! example?
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!
durr. 1.1.6 < 1.6.*
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
Declare method signatures for ruby methods and use become_java! on the Ruby class?