Author: psmith
Date: Sun Jun 17 20:30:49 2007
New Revision: 548189

URL: http://svn.apache.org/viewvc?view=rev&rev=548189
Log:
Adds an option that determines whether a new thread, or the existing thread
is used to import the events into the Receiver. By default the behaviour remains
unchanged with a new Thread created to manage the import.

The new Thread that is created has a custom Thread name to differentiate it 
from other threads.


Modified:
    
logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java

Modified: 
logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java?view=diff&rev=548189&r1=548188&r2=548189
==============================================================================
--- 
logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java
 (original)
+++ 
logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java
 Sun Jun 17 20:30:49 2007
@@ -192,6 +192,8 @@
   private Reader reader;
   private String timestampPatternText;
 
+private boolean useCurrentThread;
+
   public LogFilePatternReceiver() {
     keywords.add(TIMESTAMP);
     keywords.add(LOGGER);
@@ -800,7 +802,7 @@
    * Read and process the log file.
    */
   public void activateOptions() {
-    new Thread(new Runnable() {
+    Runnable runnable = new Runnable() {
       public void run() {
         initialize();
         while (reader == null) {
@@ -826,6 +828,31 @@
           getLogger().info("stream closed");
         }
       }
-    }).start();
+    };
+    if(useCurrentThread) {
+        runnable.run();
+    }else {
+        new Thread(runnable, "LogFilePatternReceiver-"+getName()).start();
+    }
   }
+
+     /**
+      * When true, this property uses the current Thread to perform the import,
+      * otherwise when false (the default), a new Thread is created and 
started to manage
+      * the import.
+      * @return
+      */ 
+    public final boolean isUseCurrentThread() {
+        return useCurrentThread;
+    }
+
+    /**
+     * Sets whether the current Thread or a new Thread is created to perform 
the import,
+     * the default being false (new Thread created).
+     * 
+     * @param useCurrentThread
+     */
+    public final void setUseCurrentThread(boolean useCurrentThread) {
+        this.useCurrentThread = useCurrentThread;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to