KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import javax.management.InstanceAlreadyExistsException JavaDoc;
28 import javax.management.InstanceNotFoundException JavaDoc;
29 import javax.management.MBeanRegistrationException JavaDoc;
30 import javax.management.NotCompliantMBeanException JavaDoc;
31 import javax.management.ObjectInstance JavaDoc;
32 import javax.management.ObjectName JavaDoc;
33
34 /**
35  * Implementations of this interface can be plugged into the MBeanServer,
36  * to control the registration and deregistration of MBeans. <p>
37  *
38  * The registry can expose itself for management under the object name
39  * defined the name defined in {@link ServerConstants}
40  * When this is the case, the MBeanServer will perform the
41  * register/unregister operations dynamically.
42  *
43  * @author <a HREF="mailto:juha@jboss.org">Juha Lindfors</a>.
44  * @author <a HREF="mailto:trevor@protocool.com">Trevor Squires</a>.
45  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
46  * @version $Revision: 37459 $
47  *
48  * @see MBeanEntry
49  */

50 public interface MBeanRegistry
51 {
52    /**
53     * Register an mbean.<p>
54     *
55     * This method is invoked by the MBeanServer for
56     * createMBean() and registerMBean().<p>
57     *
58     * The object name passed maybe unqualified.<p>
59     *
60     * The map is a user definable string to value object map for holding
61     * information against a registered object. This map may contain metadata
62     * related to the registration, such as registration date/time, classloader
63     * references, etc. <p>
64     *
65     * Pass {@link org.jboss.mx.server.ServerConstants#JMI_DOMAIN JMI_DOMAIN} in
66     * both the key and values of the values map to get access to the reserved
67     * domain. It is removed from the map during registration to save memory.<p>
68     *
69     * Pass {@link ServerConstants#CLASSLOADER CLASSLOADER} in the values map to
70     * set the context classloader<p>
71     *
72     * Other values are user definable and can be retrieved using the
73     * getValue(ObjectName,String) method.
74     *
75     * @param object the mbean to register.
76     * @param name the object name to assign to the mbean.
77     * @param valueMap a map of other information to include in the
78     * registry
79     *
80     * @return an object instance for the registered mbean
81     *
82     * @exception InstanceAlreadyExistsException when the object name
83     * is already registered.
84     * @exception MBeanRegistrationException when an exception is raised
85     * during preRegister for the mbean.
86     * @exception NotCompliantMBeanException when the passed object is
87     * a valid mbean.
88     */

89    ObjectInstance JavaDoc registerMBean(Object JavaDoc object, ObjectName JavaDoc name, Map JavaDoc valueMap)
90       throws InstanceAlreadyExistsException JavaDoc,
91              MBeanRegistrationException JavaDoc,
92              NotCompliantMBeanException JavaDoc;
93
94    /**
95     * Unregister an mbean. <p>
96     *
97     * This method is invoked by the MBeanServer for
98     * unregisterMBean().<p>
99     *
100     * The object name passed maybe unqualified.<p>
101     *
102     * MBeans in JMImplementation cannot be unregistered
103     *
104     * @param name the mbean to unregister.
105     *
106     * @exception InstanceNotFoundException when the object name is
107     * not registered.
108     * @exception MBeanRegistrationException when an exception is raised
109     * during preDeregister for the mbean.
110     */

111    void unregisterMBean(ObjectName JavaDoc name)
112       throws InstanceNotFoundException JavaDoc, MBeanRegistrationException JavaDoc;
113
114    /**
115     * Retrieve the registration for an object name.<p>
116     *
117     * This method is invoked by the MBeanServer for
118     * methods passing an ObjectName that are not covered in other methods.<p>
119     *
120     * The object name passed maybe unqualified.
121     *
122     * @param name the object name to retrieve
123     *
124     * @return the mbean's registration
125     *
126     * @exception InstanceNotFoundException when the object name is not
127     * registered.
128     */

129    public MBeanEntry get(ObjectName JavaDoc name)
130       throws InstanceNotFoundException JavaDoc;
131    
132    /**
133     * Retrieve the default domain for this registry.<p>
134     *
135     * @return the default domain
136     */

137    String JavaDoc getDefaultDomain();
138    
139    /**
140     * Retrieve the domains for this registry.<p>
141     *
142     * @return the domains
143     */

144    String JavaDoc[] getDomains();
145
146    /**
147     * Retrieve the object instance for an object name.
148     *
149     * @param name the object name of the mbean
150     * @return the object instance
151     * @exception InstanceNotFoundException when the object name is not
152     * registered
153     */

154    public ObjectInstance JavaDoc getObjectInstance(ObjectName JavaDoc name)
155       throws InstanceNotFoundException JavaDoc;
156
157    /**
158     * Retrieve a value from the registration.
159     *
160     * @param name the object name of the mbean
161     * @param key the key to the value
162     * @return the value or null if there is no such value
163     * @exception InstanceNotFoundException when the object name is not
164     * registered
165     */

166    public Object JavaDoc getValue(ObjectName JavaDoc name, String JavaDoc key)
167       throws InstanceNotFoundException JavaDoc;
168
169    /**
170     * Test whether an object name is registered. <p>
171     *
172     * This method is invoked by the MBeanServer for
173     * isRegistered().<p>
174     *
175     * The object name passed maybe unqualified.
176     *
177     * @param name the object name
178     * @return true when the object name is registered, false otherwise
179     */

180    boolean contains(ObjectName JavaDoc name);
181
182    /**
183     * Return a List of MBeanEntry objects with ObjectNames that match the
184     * specified pattern. <p>
185     *
186     * This method is invoked by the MBeanServer for
187     * queryMBeans() and queryNames().
188     *
189     * @param pattern the pattern to match
190     * @return a List of entries matching the pattern
191     */

192    public List JavaDoc findEntries(ObjectName JavaDoc pattern);
193    
194    /**
195     * Retrieve the number of mbeans registered.<p>
196     *
197     * This method is invoked by the MBeanServer for
198     * getMBeanCount().
199     *
200     * @return the number of mbeans registered.
201     */

202    int getSize();
203
204    /**
205     * Invoked before the MBean server instance is released. Implementing
206     * this method lets the registry to process any clean up before the
207     * MBean server is shut down.
208     */

209    void releaseRegistry();
210
211 }
212
Popular Tags