You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Marcus Crafter <cr...@managesoft.com> on 2003/06/17 14:45:54 UTC
[patch] CommandManager and exceptions
Hi All,
Hope all is well!
At the moment the CommandManager silently drops Exceptions thrown from
within Command objects.
Below is a patch that fixes this, but relies on the developer setting a
Logger object on the CommandManager instance itself, the same as the
ThreadManager.
Just wanted to check with everyone that the patch looks ok ? If so, please
let me know and I'll ahead and check it in.
Cheers,
Marcus
Index: command/CommandManager.java
===================================================================
RCS file: /home/cvs/avalon-excalibur/event/src/java/org/apache/excalibur/event/command/CommandManager.java,v
retrieving revision 1.30
diff -u -r1.30 CommandManager.java
--- command/CommandManager.java 12 Jun 2003 22:43:36 -0000 1.30
+++ command/CommandManager.java 17 Jun 2003 12:40:10 -0000
@@ -56,6 +56,8 @@
import java.util.Map;
import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.NullLogger;
import org.apache.commons.collections.Buffer;
import org.apache.commons.collections.UnboundedFifoBuffer;
import org.apache.excalibur.event.*;
@@ -90,12 +92,14 @@
//
CommandManager commandManager = new CommandManager();
+ commandManager.enableLogging( getLogger().getChildLogger("commandmanager") );
threadManager.register( commandManager );
* </pre>
*
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
*/
-public class CommandManager implements EventPipeline, Disposable, EnqueuePredicate
+public class CommandManager extends AbstractLogEnabled
+ implements EventPipeline, Disposable, EnqueuePredicate
{
private final Queue m_queue;
private final HashMap m_signalHandlers;
@@ -118,6 +122,9 @@
m_failureHandler = NullCommandFailureHandler.SHARED_INSTANCE;
m_queue.setEnqueuePredicate(this);
m_isAccepting = true;
+
+ // if no logger is set ensure a valid one is there.
+ enableLogging( new NullLogger() );
}
/**
@@ -294,7 +301,10 @@
}
catch( Exception e )
{
- // ignore for now
+ if ( getLogger().isWarnEnabled() )
+ {
+ getLogger().warn( "Command.execute() failed", e );
+ }
}
command.m_numExecutions++;
--
.....
,,$$$$$$$$$, Marcus Crafter
;$' '$$$$: Computer Systems Engineer
$: $$$$: ManageSoft GmbH
$ o_)$$$: 82-84 Mainzer Landstrasse
;$, _/\ &&:' 60327 Frankfurt Germany
' /( &&&
\_&&&&'
&&&&.
&&&&&&&:
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: [patch] CommandManager and exceptions
Posted by Marcus Crafter <cr...@managesoft.com>.
On Tue, Jun 17, 2003 at 09:17:56AM -0400, Peter Royal wrote:
> >let me know and I'll ahead and check it in.
>
> looks good to me.
Thanks mate, just checked it in.
Cheers,
Marcus
--
.....
,,$$$$$$$$$, Marcus Crafter
;$' '$$$$: Computer Systems Engineer
$: $$$$: ManageSoft GmbH
$ o_)$$$: 82-84 Mainzer Landstrasse
;$, _/\ &&:' 60327 Frankfurt Germany
' /( &&&
\_&&&&'
&&&&.
&&&&&&&:
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: [patch] CommandManager and exceptions
Posted by Peter Royal <pr...@apache.org>.
On Tuesday, June 17, 2003, at 08:45 AM, Marcus Crafter wrote:
> At the moment the CommandManager silently drops Exceptions thrown from
> within Command objects.
eek, bad! bad!
> Below is a patch that fixes this, but relies on the developer setting a
> Logger object on the CommandManager instance itself, the same as the
> ThreadManager.
>
> Just wanted to check with everyone that the patch looks ok ? If so,
> please
> let me know and I'll ahead and check it in.
looks good to me.
-pete
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org