package org.globus.cog.util;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;

/**
 * Utility class to read a stream and report when a pattern is found
 * @author wozniak
 */
public class StreamProcessor extends Streamer {

    /**
       Object to notify when pattern is found
     */
    Object object;
    
    String pattern;
    
    boolean matched = false;
    
    public StreamProcessor(InputStream istream, OutputStream ostream, 
                           Object object, String pattern) { 
        super(istream, ostream);
        this.object = object;
        this.pattern = pattern;
        
        setName("StreamProcessor["+pattern+"]");
    }
    
    public void run() {
        status = Status.ACTIVE;
        matched = false;
        
        BufferedReader reader = 
            new BufferedReader(new InputStreamReader(istream));
        PrintStream writer = 
            new PrintStream(new BufferedOutputStream(ostream));
        
        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                if (line.contains(pattern)) {
                    writer.flush();
                    matched = true;
                    synchronized(object) { 
                        object.notify();
                    }
                }
                else 
                    writer.println(line);
            }
            writer.flush();
        }
        catch (IOException e) {
            status = Status.FAILED;
            e.printStackTrace();
        }
        status = Status.COMPLETED;
    }
    
    public boolean matched() {
        return matched;
    }
}

@@ -239,16 +239,49 @@
 tream;%0A%0A
+import org.apache.log4j.Logger;%0A%0A
 /**%0A * U
@@ -417,16 +417,98 @@
 amer %7B%0A%0A
+    public static final Logger logger = Logger.getLogger(StreamProcessor.class);%0A%0A
     /**%0A
@@ -580,21 +580,17 @@
 object;%0A
-    
 %0A
+
     Stri
@@ -601,21 +601,17 @@
 attern;%0A
-    
 %0A
+
     bool
@@ -631,20 +631,16 @@
  false;%0A
-    
 %0A    pub
@@ -701,17 +701,16 @@
 ostream,
- 
 %0A       
@@ -761,17 +761,16 @@
 ttern) %7B
- 
 %0A       
@@ -857,25 +857,17 @@
 attern;%0A
-        
 %0A
+
         
@@ -907,27 +907,56 @@
 n+%22%5D%22);%0A
+        logger.debug(getName());%0A
     %7D%0A
-    
 %0A
+
     publ
@@ -1028,24 +1028,16 @@
  false;%0A
-        
 %0A       
@@ -1056,25 +1056,24 @@
 der reader =
- 
 %0A           
@@ -1153,17 +1153,16 @@
 writer =
- 
 %0A       
@@ -1222,17 +1222,9 @@
 ));%0A
-        
 %0A
+
     
@@ -1478,17 +1478,16 @@
 bject) %7B
- 
 %0A       
@@ -1516,24 +1516,55 @@
 t.notify();%0A
+                        break;%0A
             
@@ -1611,17 +1611,16 @@
     else
- 
 %0A       
@@ -1858,20 +1858,16 @@
 ;%0A    %7D%0A
-    
 %0A    pub

Add logging