You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2003/03/13 06:48:12 UTC
cvs commit: avalon-excalibur/thread/src/java/org/apache/excalibur/thread/impl WorkerThread.java
leif 2003/03/12 21:48:11
Modified: thread/src/java/org/apache/avalon/excalibur/thread/impl
BasicThreadPool.java SimpleWorkerThread.java
thread/src/java/org/apache/excalibur/thread/impl
WorkerThread.java
Log:
Make it possible to control whether or not debug output of the worker threads
can be configured from the log config file. This can be necessary to track down
problems in the threads. Worker output can be disabled as it has its own channel.
Revision Changes Path
1.9 +1 -1 avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/BasicThreadPool.java
Index: BasicThreadPool.java
===================================================================
RCS file: /home/cvs/avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/BasicThreadPool.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BasicThreadPool.java 4 Mar 2003 14:34:38 -0000 1.8
+++ BasicThreadPool.java 13 Mar 2003 05:48:11 -0000 1.9
@@ -161,7 +161,7 @@
}
final SimpleWorkerThread thread =
new SimpleWorkerThread( this, getThreadGroup(), name, context );
- ContainerUtil.enableLogging( thread, m_logger );
+ ContainerUtil.enableLogging( thread, m_logger.getChildLogger( "worker" ) );
return thread;
}
1.6 +12 -5 avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/SimpleWorkerThread.java
Index: SimpleWorkerThread.java
===================================================================
RCS file: /home/cvs/avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/SimpleWorkerThread.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SimpleWorkerThread.java 7 Feb 2003 16:08:55 -0000 1.5
+++ SimpleWorkerThread.java 13 Mar 2003 05:48:11 -0000 1.6
@@ -99,14 +99,21 @@
super.preExecute();
ThreadContext.setThreadContext( m_context );
}
-
+
protected void debug( final String message )
{
- if( false )
+ if ( m_logger.isDebugEnabled() )
{
- final String output = getName() + ": " + message;
- m_logger.debug( output );
- //System.out.println( output );
+ m_logger.debug( getName() + ": " + message );
+ }
+ }
+
+ protected void debug( final String message, final Throwable t )
+ {
+ if ( m_logger.isDebugEnabled() )
+ {
+ m_logger.debug( getName() + ": " + message, t );
}
}
}
+
1.5 +20 -9 avalon-excalibur/thread/src/java/org/apache/excalibur/thread/impl/WorkerThread.java
Index: WorkerThread.java
===================================================================
RCS file: /home/cvs/avalon-excalibur/thread/src/java/org/apache/excalibur/thread/impl/WorkerThread.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WorkerThread.java 7 Feb 2003 16:09:05 -0000 1.4
+++ WorkerThread.java 13 Mar 2003 05:48:11 -0000 1.5
@@ -79,11 +79,6 @@
private boolean m_alive;
/**
- * The name of thread.
- */
- private final String m_name;
-
- /**
* The thread pool this thread is associated with.
*/
private final AbstractThreadPool m_pool;
@@ -105,14 +100,14 @@
throw new NullPointerException( "pool" );
}
- m_name = name;
+ setName( name );
m_work = null;
m_alive = true;
m_pool = pool;
setDaemon( false );
}
-
+
/**
* The main execution loop.
*/
@@ -146,7 +141,7 @@
catch( final Throwable throwable )
{
// Error thrown while working.
- debug( "error caught: " + throwable );
+ debug( "error caught", throwable );
m_threadControl.finish( throwable );
}
finally
@@ -194,7 +189,6 @@
{
//TODO: Thread name setting should reuse the
//ThreadContext code if ThreadContext used.
- Thread.currentThread().setName( m_name );
}
/**
@@ -269,6 +263,23 @@
if( false )
{
final String output = getName() + ": " + message;
+ System.out.println( output );
+ }
+ }
+
+ /**
+ * Write a debug message.
+ * A Noop oin this implementation. Subclasses can overide
+ * to actually do some logging.
+ *
+ * @param message the message to write out.
+ * @param throwable the throwable to write out with the message.
+ */
+ protected void debug( final String message, final Throwable throwable )
+ {
+ if( false )
+ {
+ final String output = getName() + ": " + message + ": " + throwable;
System.out.println( output );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org