Thanks, Rony;  this is very timely.  It has direct application to my use of
ooRexx extensions to Eclipse.  

-----Original Message-----
From: Rony G. Flatscher [mailto:[email protected]] 
Sent: Thursday, July 10, 2014 09:10
To: Open Object Rexx Developer Mailing List
Subject: [Oorexx-devel] Redirecting ooRexx' standard files at runtime...

Just a nice feature of ooRexx which might not get really noticed, however at
times may proof to be
*quite* helpful, hence sharing it here.

In ooRexx whenever one outputs to stdout, stderr or inputs from stdin, then
the monitors .output, .error and .input are used. By default these monitors
forward to .stdout, .stderr, and .stdin respectively. Having a monitor
object allows one to exchange the destination object at runtime from within
ooRexx, which might sound "exotic" at first. However, there are problems
that can be solved extremely elegantly, knowing this infrastructure and
behaviour of ooRexx.

A case in question: currently, there is a student who has taken on the task
to create a proof of concept of making ooRexx scripts available to programs,
embedded in HTML texts in a platform independent manner (maybe a possible
presentation for the 2015 International Rexx Symposium). The problem here is
that any ooRexx output and input using standard files does not really yield
visible outputs in the case of stdout and stderr, so testing and developing
has been incredibly hard on the student.

Once he told me about not seeing debug output from ooRexx scripts while
invoking them via JavaScript and the Java-Plugin, however the Java debug
output would be shown in the Java console, I suggested to change the ooRexx
standard files at runtime from within ooRexx to redirect to Java's standard
files (i.e. System.out, System.err, System.in) and gave him a quick hack.

By redirecting ooRexx' .output, .error and .input to Java's standard streams
the output of his ooRexx programs all of a sudden became visible in the Java
console, easying debugging tremendeously for him.

As I foresee a future need for this redirection to Java streams I added a
routine
BSF.redirectTo([Java|ooRexx]) and implemented ooRexx classes that subclass
the ooRexx inputStream and outputStream classes, forwarding the ooRexx
standard input and standard outputs from/to the appropriate Java standard
streams (will be part of BSF.CLS in the next version of BSF4ooRexx). All the
ooRexx-programs themselves remain unchanged, except for the very first one
that needs to call
BSF.redirectTo() once to carry out the redirection to the Java standard
streams.

So, if you ever deploy ooRexx scripts from environments where ooRexx
input/output to/from standard files is not possible for whatever reason,
just use this technique to redirect the ooRexx streams to the hosting
environments ones. If you want to know what methods your replacement stream
classes need to implement, just lookup the classes BSF.inputStream and
BSF.printStream in BSF.CLS in the current beta of BSF4ooRexx.

---rony

P.S.: In ooRexx 4.2 there got two new standard ooRexx streams added that are
named .debugInput and .traceOutput. BSF.redirectTo() also takes care to
redirect these streams in case they are defined in .local.



----------------------------------------------------------------------------
--
Open source business process management suite built on Java and Eclipse Turn
processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows Winner of
BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel



------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to