KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > server > DefaultMBeanRepository


1 /*
2  * Copyright (C) MX4J.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.server;
10
11 import java.util.HashMap JavaDoc;
12 import java.util.Iterator JavaDoc;
13
14 import javax.management.ObjectName JavaDoc;
15
16 /**
17  * Default implementation of the MBeanRepository interface.
18  *
19  * @author <a HREF="mailto:biorn_steedom@users.sourceforge.net">Simone Bordet</a>
20  * @version $Revision: 1.3 $
21  */

22 class DefaultMBeanRepository implements MBeanRepository
23 {
24     private HashMap JavaDoc m_map = new HashMap JavaDoc();
25
26     public MBeanMetaData get(ObjectName JavaDoc name)
27     {
28         return (MBeanMetaData)m_map.get(name);
29     }
30
31     public void put(ObjectName JavaDoc name, MBeanMetaData metadata)
32     {
33         m_map.put(name, metadata);
34     }
35
36     public void remove(ObjectName JavaDoc name)
37     {
38         m_map.remove(name);
39     }
40
41     public int size()
42     {
43         return m_map.size();
44     }
45
46     public Iterator JavaDoc iterator()
47     {
48         return m_map.values().iterator();
49     }
50
51     public Object JavaDoc clone()
52     {
53         try
54         {
55             DefaultMBeanRepository repository = (DefaultMBeanRepository)super.clone();
56             repository.m_map = (HashMap JavaDoc)m_map.clone();
57             return repository;
58         }
59         catch (CloneNotSupportedException JavaDoc ignored)
60         {
61             return null;
62         }
63     }
64 }
65
Popular Tags