org.syrup.workers
Class DefaultWorker

java.lang.Object
  extended byorg.syrup.workers.DefaultWorker

public class DefaultWorker
extends java.lang.Object

The default Worker implementation that executes PTasks taken from a WorkSpace.

Author:
Robbert van Dalen

Constructor Summary
DefaultWorker()
           
 
Method Summary
static void execute(WorkSpace sp, PTaskTemplate template, long totalIterations, long pollInterval)
          Executes PTasks that match a PTaskTemplate by writing them out in XML format.
static int get(WorkSpace sp, PTaskTemplate template, java.io.OutputStream out)
          Get the Contexts that match a PTaskTemplate by writing them out in XML format.
static void main(java.lang.String[] args)
          Start the Worker as a daemon or to execute a Syrup command using System.in and System.out for input and output.
static int match(WorkSpace sp, LogEntryTemplate template, java.io.OutputStream out)
          Return LogEntries that match a LogEntryTemplate by writing them out in XML format.
static int match(WorkSpace sp, PTaskTemplate template, java.io.OutputStream out)
          Return PTasks that match a PTaskTemplate by writing them out in XML format.
static int operate(java.lang.String[] args, java.io.InputStream i, java.io.OutputStream o)
          The main entry to start the Worker as a daemon, or to execute a Syrup command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultWorker

public DefaultWorker()
Method Detail

operate

public static int operate(java.lang.String[] args,
                          java.io.InputStream i,
                          java.io.OutputStream o)
                   throws java.lang.Exception
The main entry to start the Worker as a daemon, or to execute a Syrup command.

Parameters:
args - The command + qualifier.
i - The InputStream to read input from.
o - The OutputStream to write output to.
Returns:
The number of results (matched/stopped PTasks, matched LogEntries)
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Start the Worker as a daemon or to execute a Syrup command using System.in and System.out for input and output.

Parameters:
args - The command + qualifier.
Throws:
java.lang.Exception

match

public static int match(WorkSpace sp,
                        PTaskTemplate template,
                        java.io.OutputStream out)
                 throws java.lang.Exception
Return PTasks that match a PTaskTemplate by writing them out in XML format.

Parameters:
sp - The WorkSpace to be used.
template - The PTaskTemplate to be matched.
out - The OutputStream to write PTasks to.
Returns:
The number of matched PTasks.
Throws:
java.lang.Exception

match

public static int match(WorkSpace sp,
                        LogEntryTemplate template,
                        java.io.OutputStream out)
                 throws java.lang.Exception
Return LogEntries that match a LogEntryTemplate by writing them out in XML format.

Parameters:
sp - The WorkSpace to be used.
template - The LogEntryTemplate to be matched.
out - The OutputStream to write LogEntries to.
Returns:
The number of matched LogEntries.
Throws:
java.lang.Exception

get

public static int get(WorkSpace sp,
                      PTaskTemplate template,
                      java.io.OutputStream out)
               throws java.lang.Exception
Get the Contexts that match a PTaskTemplate by writing them out in XML format.

Parameters:
sp - The WorkSpace to be used.
template - The PTaskTemplate to be matched.
out - The OutputStream to write Contexts to.
Returns:
The number of matched Contexts.
Throws:
java.lang.Exception

execute

public static void execute(WorkSpace sp,
                           PTaskTemplate template,
                           long totalIterations,
                           long pollInterval)
                    throws java.lang.Exception
Executes PTasks that match a PTaskTemplate by writing them out in XML format. This method will continue to execute forever, waiting for new PTasks to be executed until the calling Thread or JVM is stopped.

Parameters:
sp - The WorkSpace to be used.
template - The PTaskTemplate to be matched.
Throws:
java.lang.Exception