Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing Interface in JRuby 9.2.7.0 for JDK11 #5797

Open
Syed-SnapLogic opened this issue Jul 23, 2019 · 1 comment

Comments

@Syed-SnapLogic
Copy link

commented Jul 23, 2019

I am using JRuby 9.2.7.0 on Ubuntu 18.04 64 bit with JDK11.

Can you show me an example of ruby script where we are implementing a java interface and invoking initialize method?

I have following script but in initialize method, the values are of type NilClass.

class MyScript
    # Import the interface required by the Script snap.
    include com.snaplogic.scripting.language.ScriptHook
    attr_reader :log, :input, :output, :error
    def initialize(log, input, output, error)
        puts input.class.name
        # above line outputs NilClass; how to fix it?
        @log = log
        @input = input
        @output = output
        @error = error
    end

    # The "execute()" method is called once when the pipeline is started
    # and allowed to process its inputs or just send data to its outputs.
    def execute()
        while input.hasNext() do
            begin
                # Read the next document, wrap it in a map and write out the wrapper
                doc = input.next()
                wrapper = {
                 "original" => doc
                }
            
                log.info("Executed Ruby script")
                output.write(doc, wrapper)
            
            rescue => e
                log.error("Bad Rublet " + e.message)
                errWrapper = {
                    "errMsg" => e.message
                }
                error.write(errWrapper)
            end
        end
        
        
    end
end

# The Script Snap will look for a ScriptHook object in the "hook"
# variable.  The snap will then call the hook's "execute" method.
$hook = MyScript.new($log, $input, $output, $error)
@enebo

This comment has been minimized.

Copy link
Member

commented Jul 23, 2019

@Syed-SnapLogic Are you sure $input being passed into .new is not nil? Can you print out its value before MyScript.new to make sure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.