org.codehaus.plexus.component.jruby
Class JRubyRuntimeInvoker

java.lang.Object
  extended by org.codehaus.plexus.component.jruby.JRubyRuntimeInvoker
All Implemented Interfaces:
JRubyInvoker

public class JRubyRuntimeInvoker
extends java.lang.Object
implements JRubyInvoker


Constructor Summary
JRubyRuntimeInvoker(org.codehaus.plexus.component.repository.ComponentDescriptor componentDescriptor, org.codehaus.classworlds.ClassRealm classRealm)
          Create a JRubyInvoker that runs under the context of this class loader.
JRubyRuntimeInvoker(java.io.Reader scriptReader)
          Create a reader JRubyInvoker that reads a JRuby script from the given reader.
 
Method Summary
 java.lang.Object invoke()
          Invokes the script after all other values are set.
 java.lang.Object invoke(java.io.OutputStream stdout, java.io.OutputStream stderr)
          Invokes the script after all other values are set.
static void printREStackTrace(org.jruby.exceptions.RaiseException re, java.io.OutputStream errStream)
           
 void putGlobal(java.lang.String key, java.lang.Object value)
          Appends an input value with the given key to the Ruby script by prepending the following code to the Ruby script: $key = value;
 void setAssumeLoop(boolean assumeLoop)
          As per the Ruby command line arg -n.
 void setAssumePrintLoop(boolean assumePrintLoop)
          As per the Ruby command line arg -p.
 void setAutoSplit(boolean autoSplit)
          As per the Ruby command line arg -a.
 void setCurrentDirectory(java.lang.String currentDirectory)
          Sets the current running directory for JRuby.
 void setDebug(boolean debug)
          As per the Ruby command line arg -d.
 void setLibraryPaths(java.lang.String[] libPaths)
          Adds a library as per the Ruby command line arg -I.
 void setProcessLineEnds(boolean processLineEnds)
          As per the Ruby command line arg -l.
 void setReader(java.io.Reader reader)
          The sole way of sending a script to this invoker object.
 void setRequires(java.lang.String[] reqLibs)
          Adds a 'require' file as per the Ruby command line arg -r.
 void setRuntime(org.jruby.Ruby runtime)
          Not required, however if set, the invoker will tear down the runtime before exiting Invoke.
 void setWarning(int warning)
          As per the Ruby command line arg -W#.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRubyRuntimeInvoker

public JRubyRuntimeInvoker(java.io.Reader scriptReader)
Create a reader JRubyInvoker that reads a JRuby script from the given reader.


JRubyRuntimeInvoker

public JRubyRuntimeInvoker(org.codehaus.plexus.component.repository.ComponentDescriptor componentDescriptor,
                           org.codehaus.classworlds.ClassRealm classRealm)
Create a JRubyInvoker that runs under the context of this class loader.

Parameters:
componentDescriptor -
classRealm -
Method Detail

setRuntime

public void setRuntime(org.jruby.Ruby runtime)
Description copied from interface: JRubyInvoker
Not required, however if set, the invoker will tear down the runtime before exiting Invoke. If you plan on changing the state of inkove-returned IRubyObjects, you should set this externally via Ruby.getDefaultInstance(), and tear it down when done via tearDown() method.

Specified by:
setRuntime in interface JRubyInvoker

setReader

public void setReader(java.io.Reader reader)
The sole way of sending a script to this invoker object.

Specified by:
setReader in interface JRubyInvoker
Parameters:
reader -

setAssumeLoop

public void setAssumeLoop(boolean assumeLoop)
As per the Ruby command line arg -n.

Specified by:
setAssumeLoop in interface JRubyInvoker
Parameters:
assumeLoop -

setAssumePrintLoop

public void setAssumePrintLoop(boolean assumePrintLoop)
As per the Ruby command line arg -p.

Specified by:
setAssumePrintLoop in interface JRubyInvoker
Parameters:
assumePrintLoop -

setAutoSplit

public void setAutoSplit(boolean autoSplit)
As per the Ruby command line arg -a.

Specified by:
setAutoSplit in interface JRubyInvoker
Parameters:
autoSplit -

setWarning

public void setWarning(int warning)
As per the Ruby command line arg -W#.

Specified by:
setWarning in interface JRubyInvoker
Parameters:
warning -

setDebug

public void setDebug(boolean debug)
As per the Ruby command line arg -d. (sets $DEBUG to true)

Specified by:
setDebug in interface JRubyInvoker
Parameters:
debug -

setProcessLineEnds

public void setProcessLineEnds(boolean processLineEnds)
As per the Ruby command line arg -l.

Specified by:
setProcessLineEnds in interface JRubyInvoker
Parameters:
processLineEnds -

setLibraryPaths

public void setLibraryPaths(java.lang.String[] libPaths)
Adds a library as per the Ruby command line arg -I.

Specified by:
setLibraryPaths in interface JRubyInvoker
Parameters:
libPath -

setRequires

public void setRequires(java.lang.String[] reqLibs)
Adds a 'require' file as per the Ruby command line arg -r.

Specified by:
setRequires in interface JRubyInvoker
Parameters:
reqLib -

putGlobal

public void putGlobal(java.lang.String key,
                      java.lang.Object value)
Appends an input value with the given key to the Ruby script by prepending the following code to the Ruby script: $key = value;

Specified by:
putGlobal in interface JRubyInvoker
Parameters:
key -
value -

setCurrentDirectory

public void setCurrentDirectory(java.lang.String currentDirectory)
Sets the current running directory for JRuby.

Specified by:
setCurrentDirectory in interface JRubyInvoker

invoke

public java.lang.Object invoke()
                        throws java.io.IOException,
                               org.codehaus.plexus.component.factory.ComponentInstantiationException
Invokes the script after all other values are set.

Specified by:
invoke in interface JRubyInvoker
Returns:
an Object of possibly returned value
Throws:
java.io.IOException
org.codehaus.plexus.component.factory.ComponentInstantiationException

invoke

public java.lang.Object invoke(java.io.OutputStream stdout,
                               java.io.OutputStream stderr)
                        throws java.io.IOException,
                               org.codehaus.plexus.component.factory.ComponentInstantiationException
Invokes the script after all other values are set.

Specified by:
invoke in interface JRubyInvoker
Parameters:
stdout - stream where jruby output to
stderr - stream where jruby errors to
Returns:
a Map of returned values
Throws:
java.io.IOException
org.codehaus.plexus.component.factory.ComponentInstantiationException

printREStackTrace

public static void printREStackTrace(org.jruby.exceptions.RaiseException re,
                                     java.io.OutputStream errStream)


Copyright © 2001-2008 Codehaus. All Rights Reserved.