KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > defaults > MonitoringComponentAdapter


1 /*****************************************************************************
2  * Copyright (C) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Original code by *
9  *****************************************************************************/

10 package org.picocontainer.defaults;
11
12 import java.io.Serializable JavaDoc;
13
14 import org.picocontainer.ComponentAdapter;
15 import org.picocontainer.ComponentMonitor;
16
17 /**
18  * Abstract {@link ComponentAdapter ComponentAdapter} supporting a
19  * {@link ComponentMonitorStrategy ComponentMonitorStrategy}.
20  * It provides a {@link DelegatingComponentMonitor default ComponentMonitor},
21  * but does not allow to use <code>null</code> for the component monitor.
22  *
23  * @author Mauro Talevi
24  * @version $Revision: $
25  * @see ComponentAdapter
26  * @see ComponentMonitorStrategy
27  * @since 1.2
28  */

29 public abstract class MonitoringComponentAdapter implements ComponentAdapter, ComponentMonitorStrategy, Serializable JavaDoc {
30     private ComponentMonitor componentMonitor;
31
32     /**
33      * Constructs a MonitoringComponentAdapter with a custom monitor
34      * @param monitor the component monitor used by this ComponentAdapter
35      */

36     protected MonitoringComponentAdapter(ComponentMonitor monitor) {
37         if (monitor == null){
38             throw new NullPointerException JavaDoc("monitor");
39         }
40         this.componentMonitor = monitor;
41     }
42
43     /**
44      * Constructs a MonitoringComponentAdapter with a {@link DelegatingComponentMonitor default monitor}.
45      */

46     protected MonitoringComponentAdapter() {
47         this(new DelegatingComponentMonitor());
48     }
49
50
51     public void changeMonitor(ComponentMonitor monitor) {
52         this.componentMonitor = monitor;
53     }
54     
55     /**
56      * Returns the monitor currently used
57      * @return The ComponentMonitor currently used
58      */

59     public ComponentMonitor currentMonitor(){
60         return componentMonitor;
61     }
62
63 }
64
Popular Tags