KickJava   Java API By Example, From Geeks To Geeks.

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


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 Mauro Talevi *
9  *****************************************************************************/

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

27 public abstract class MonitoringComponentAdapterFactory implements ComponentAdapterFactory, ComponentMonitorStrategy, Serializable JavaDoc {
28     private ComponentMonitor componentMonitor;
29
30     /**
31      * Constructs a MonitoringComponentAdapterFactory with a custom monitor
32      * @param monitor the ComponentMonitor used by the factory
33      */

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

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

56     public ComponentMonitor currentMonitor(){
57         return componentMonitor;
58     }
59
60 }
61
Popular Tags