KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > fortress > impl > handler > PrepareHandlerCommand


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.avalon.fortress.impl.handler;
19
20 import org.apache.avalon.framework.logger.Logger;
21 import org.apache.avalon.framework.logger.NullLogger;
22 import org.apache.excalibur.event.command.Command;
23
24 /**
25  * This is the command class to initialize a ComponentHandler
26  *
27  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
28  * @version CVS $Revision: 1.12 $ $Date: 2004/02/28 15:16:25 $
29  */

30 public final class PrepareHandlerCommand implements Command
31 {
32     private final ComponentHandler m_handler;
33     private final Logger m_logger;
34
35     /**
36      * Creation of a new prepare handler command.
37      * @param handler the compoent handler
38      * @param logger the logging channel
39      */

40     public PrepareHandlerCommand( final ComponentHandler handler,
41                                   final Logger logger )
42     {
43         m_handler = handler;
44         m_logger = ( null == logger ) ? new NullLogger() : logger;
45     }
46     
47     /**
48      * Returns a reference to the ComponentHandler being prepared.
49      *
50      * @return The ComponentHandler.
51      */

52     public ComponentHandler getHandler()
53     {
54         return m_handler;
55     }
56
57     /**
58      * Invoke execution of the handler
59      * @exception java.lang.Exception if a handler execution exception occurs
60      */

61     public void execute()
62         throws Exception JavaDoc
63     {
64         try
65         {
66             m_handler.prepareHandler();
67         }
68         catch ( final Exception JavaDoc e )
69         {
70             if ( m_logger.isErrorEnabled() )
71             {
72                 //m_logger.error( "[REMOVE THIS] Could not prepare ComponentHandler for: " + m_handler.getComponentClass().getName(), e );
73
}
74
75             throw e;
76         }
77     }
78 }
79
80
Popular Tags