KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > phoenix > components > manager > Target


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE.txt file.
7  */

8 package org.apache.avalon.phoenix.components.manager;
9
10 import java.util.HashMap JavaDoc;
11 import java.util.Set JavaDoc;
12 import javax.management.modelmbean.ModelMBeanInfo JavaDoc;
13
14 /**
15  * It reprensents a managed object in the managegement space. It is a container for
16  * zero or more management topics and zero or more management lists.
17  *
18  * @author robertsh
19  * @version $$
20  */

21 public class Target
22 {
23     private final String JavaDoc m_name;
24     private final HashMap JavaDoc m_topics;
25     private final Object JavaDoc m_managedResource;
26
27     /**
28      * Creates new Target
29      *
30      * @param name the name for the target
31      * @param managedResource the object that this managedResource represents in the management hierarchy
32      */

33     public Target( final String JavaDoc name,
34                    final Object JavaDoc managedResource )
35     {
36         m_name = name;
37         m_managedResource = managedResource;
38         m_topics = new HashMap JavaDoc();
39     }
40
41     /**
42      * Returns the name of the Target
43      * @return the name
44      */

45     public String JavaDoc getName()
46     {
47         return m_name;
48     }
49
50     /**
51      * Returns the object managed by the target
52      *
53      * @return the managed object
54      */

55     public Object JavaDoc getManagedResource()
56     {
57         return m_managedResource;
58     }
59
60     /**
61      * Topics are a set of attributes and operations relevant to a particular
62      * aspect of an object. A Target must typically have at least one topic in
63      * order to be manageable.
64      *
65      * @param topic
66      */

67     public void addTopic( final ModelMBeanInfo JavaDoc topic )
68     {
69         m_topics.put( topic.getDescription(), topic );
70     }
71
72     /**
73      * Removes a topic for this target
74      * @param name the name of the topic to remove
75      */

76     public void removeTopic( final String JavaDoc name )
77     {
78         m_topics.remove( name );
79     }
80
81     /**
82      * Gets a topic for this Target
83      *
84      * @param name the name of the topic
85      * @return the topic of that name
86      */

87     public ModelMBeanInfo JavaDoc getTopic( final String JavaDoc name )
88     {
89         return (ModelMBeanInfo JavaDoc)m_topics.get( name );
90     }
91
92     /**
93      * Returns the Set of topics for this Target
94      *
95      * @return the Set of topic names
96      */

97     public Set JavaDoc getTopicNames()
98     {
99         return m_topics.keySet();
100     }
101 }
102
Popular Tags