KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ve > luz > ica > jackass > component > ComponentInfoManager


1 /*
2  * Copyright (c) 2003 by The Jackass Team
3  * Licensed under the Open Software License version 2.0
4  */

5 package ve.luz.ica.jackass.component;
6
7 import java.util.Hashtable JavaDoc;
8 import java.util.Map JavaDoc;
9
10 //import org.apache.commons.logging.Log;
11
//import org.apache.commons.logging.LogFactory;
12

13 /**
14  * ComponentManager handles information about the objects that implement
15  * the components locally. A ComponentManager has a Map that maps the object
16  * proxy references to a ComponentInfo object which stores information about
17  * the object.
18  * <p>
19  * This class is a Singleton. To obtain the singleton object use the static
20  * method getManager.
21  * @author Carlos Arévalo
22  */

23 public final class ComponentInfoManager
24 {
25     //private static Log LOG = LogFactory.getLog(ComponentInfoManager.class);
26

27     private static ComponentInfoManager manager = null;
28
29     private Map JavaDoc components;
30
31     /**
32      * Returns the singlenton ComponentInfoManager
33      * @return the singleton ComponentInfoManager
34      */

35     public static ComponentInfoManager getManager()
36     {
37         if (manager == null)
38         {
39             manager = new ComponentInfoManager();
40         }
41         return manager;
42     }
43
44     /**
45      * Class constructor
46      */

47     private ComponentInfoManager()
48     {
49         components = new Hashtable JavaDoc();
50     }
51
52     /**
53      * Add a ComponentInfo object to the map
54      * @param oid the object ID
55      * @param info the ComponentInfo object
56      */

57     public void addComponentInfo(byte[] oid, ComponentInfo info)
58     {
59         this.components.put(new String JavaDoc(oid), info);
60     }
61
62     /**
63      * Get a ComponentInfo given the proxy reference
64      * @param oid the object ID
65      * @return the ComponentInfo object associated with the given proxy reference
66      */

67     public ComponentInfo getComponentInfo(byte[] oid)
68     {
69         ComponentInfo compInfo = (ComponentInfo) this.components.get(new String JavaDoc(oid));
70         return compInfo;
71     }
72
73     /**
74      * Remove a ComponentInfo from the map
75      * @param oid the object ID
76      */

77     public void removeComponentInfo(byte[] oid)
78     {
79         components.remove(new String JavaDoc(oid));
80     }
81 }
82
Popular Tags