Class: Closure::BeanShell
- Inherits:
-
Object
- Object
- Closure::BeanShell
- Defined in:
- lib/closure/beanshell.rb
Overview
Closure Script will manage a single BeanShell to run the Java tools. This way we don’t pay the Java startup costs on every compile job.
Constant Summary
- PROMPT =
/^bsh % $\Z/
- JAR =
File.join(Closure.base_path, 'beanshell', 'bsh-core-2.0b4.jar')
Instance Method Summary (collapse)
-
- (BeanShell) initialize(classpath = [])
constructor
A new instance of BeanShell.
-
- run(command)
Run any Java command that BeanShell supports.
Constructor Details
- (BeanShell) initialize(classpath = [])
A new instance of BeanShell
26 27 28 29 30 |
# File 'lib/closure/beanshell.rb', line 26 def initialize(classpath=[]) @semaphore = Mutex.new @classpath = classpath $cmdin = nil end |
Instance Method Details
- run(command)
Run any Java command that BeanShell supports. Recovers from error conditions when the Java process is killed.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/closure/beanshell.rb', line 34 def run(command) begin return execute command rescue Errno::EPIPE # Shut down broken pipe; another will be started. $stderr.print "#{self.class}: restarting Java.\n" $pipe.close $pipe = nil end # This "second chance" will not rescue the error. execute command end |