Dynamically Adaptable String Processing

This demo shows how we can change parameters of a system in order to alter the functioning of the system dynamically.

Script

	notifyError = function() {
		java.lang.System.out.println("fn(): -> ERROR in STREAM");
	}

	DASPService    = "org.hpsearch.demo.DASP.DynamicallyAdaptableStringProcessingService";
	DASPServiceLoc = "http://156.56.104.170:10000/axis/services/WSSConnector?wsdl" ; 

	dasp = new WebServiceHandler(DASPService);
	dasp.setEndPointURI(DASPServiceLoc);

	dasp.setParameter("reverse", "NO");

	dasp.setInput("file://c:/Home/services/dasp-10000/input.txt");
	dasp.setOutput("file://c:/Home/services/dasp-10000/output.txt");

	dasp.setErrorHandler("java.io.IOException", "notifyError()");
	dasp.setErrorHandler("java.io.EOFException", "terminate");
	dasp.setErrorHandler("org.hpsearch.demo.DASP.DASPPalindromeException", "setParameter:reverse:YES;resume");

	DASPFlow = new Flow();
	DASPFlow.addStartActivities(dasp);
	DASPFlow.start("1");
	

Results

The DASP service, works in the following way.
  1. Read the parameter reverse. It is set initially to NO and the service just outputs the input strings as it is.
  2. The service checks to see, if the input string is a palindrome. If a palindrome is found it raises the org.hpsearch.demo.DASP.DASPPalindromeException exception.
  3. We catch this error and reset the reverse parameter to YES. The service then outputs the rest of the strings in reverse.
InputOutput
This
file
contains
test
words
and
a
palindrome
Today's
palindrome
is
racecar
And
the
rest
of
the
words
are
reversed
This
file
contains
test
words
and
a
palindrome
Today's
palindrome
is
racecar
dnA
eht
tser
fo
eht
sdrow
era
desrever