KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mx > server > registry > MBeanEntry


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.mx.server.registry;
23
24 import java.util.Map JavaDoc;
25
26 import javax.management.ObjectName JavaDoc;
27
28 import org.jboss.mx.server.MBeanInvoker;
29 import org.jboss.mx.server.ServerConstants;
30
31 /**
32  * info@todo this docs
33  *
34  * @see org.jboss.mx.server.registry.MBeanRegistry
35  * @see org.jboss.mx.server.MBeanServerImpl
36  *
37  * @author <a HREF="mailto:juha@jboss.org">Juha Lindfors</a>.
38  * @version $Revision: 37459 $
39  */

40 public class MBeanEntry
41    implements ServerConstants
42 {
43    // Attributes ----------------------------------------------------
44

45    /**
46     * The registered object name of the mbean
47     */

48    private ObjectName JavaDoc objectName = null;
49
50    /**
51     * The class name of the mbean
52     */

53    private String JavaDoc resourceClassName = null;
54
55    /**
56     * The object used to invoke the mbean
57     */

58    private MBeanInvoker invoker = null;
59
60    /**
61     * The mbean registered
62     */

63    private Object JavaDoc resource = null;
64
65    /**
66     * The context classloader of the mbean
67     */

68    private ClassLoader JavaDoc cl = null;
69
70    /**
71     * The value map of the mbean
72     */

73    private Map JavaDoc valueMap = null;
74
75    // Constructors --------------------------------------------------
76

77    /**
78     * Construct a new mbean registration entry.
79     *
80     * @param objectName the name with which the mbean is registered
81     * @param invoker the dynamic mbean used to invoke the mbean
82     * @param resource the mbean
83     * @param valueMap any other information to include in the registration
84     */

85    public MBeanEntry(ObjectName JavaDoc objectName, MBeanInvoker invoker,
86                      Object JavaDoc resource, Map JavaDoc valueMap)
87    {
88       this.objectName = objectName;
89       this.invoker = invoker;
90       this.resourceClassName = resource.getClass().getName();
91       this.resource = resource;
92       this.valueMap = valueMap;
93
94       // Adrian: Unpack the classloader because this is used alot
95
if (valueMap != null)
96          this.cl = (ClassLoader JavaDoc) valueMap.get(CLASSLOADER);
97    }
98
99    // Public --------------------------------------------------------
100

101    /**
102     * Retrieve the object name with the mbean is registered.
103     *
104     * @return the object name
105     */

106    public ObjectName JavaDoc getObjectName()
107    {
108       return objectName;
109    }
110
111    /** A protected method used to set the entry object name when access
112     * to the entry is needed before the ultimate name under which the
113     * mbean is registered is known.
114     *
115     * @param objectName - the object name under which the mbean is registered
116     */

117    protected void setObjectName(ObjectName JavaDoc objectName)
118    {
119       this.objectName = objectName;
120    }
121
122    /**
123     * Retrieve the invoker for the mbean.
124     *
125     * @return the invoker
126     */

127    public MBeanInvoker getInvoker()
128    {
129       return invoker;
130    }
131
132    /**
133     * Retrieve the class name for the mbean.
134     *
135     * @return the class name
136     */

137    public String JavaDoc getResourceClassName()
138    {
139       return resourceClassName;
140    }
141
142    /**
143     * Retrieve the class name for the mbean.
144     *
145     * @param resourceClassName the class name
146     */

147    public void setResourceClassName(String JavaDoc resourceClassName)
148    {
149       this.resourceClassName = resourceClassName;
150    }
151
152    /**
153     * Retrieve the mbean.
154     *
155     * @return the mbean
156     */

157    public Object JavaDoc getResourceInstance()
158    {
159       return resource;
160    }
161
162    /**
163     * Retrieve the context class loader with which to invoke the mbean.
164     *
165     * @return the class loader
166     */

167    public ClassLoader JavaDoc getClassLoader()
168    {
169       return cl;
170    }
171
172    /**
173     * Retrieve a value from the map.
174     *
175     * @return key the key to value
176     * @return the value or null if there is no entry
177     */

178    public Object JavaDoc getValue(String JavaDoc key)
179    {
180       if (valueMap != null)
181          return valueMap.get(key);
182       return null;
183    }
184 }
185
Popular Tags