001// Copyright 2005 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.hivemind.management;
016
017import javax.management.InstanceAlreadyExistsException;
018import javax.management.InstanceNotFoundException;
019import javax.management.JMException;
020import javax.management.MBeanRegistrationException;
021import javax.management.NotCompliantMBeanException;
022import javax.management.ObjectInstance;
023import javax.management.ObjectName;
024
025/**
026 * Service that registers MBeans in the an MBeanServer.
027 * 
028 * @author Achim Huegen
029 * @since 1.1
030 */
031public interface MBeanRegistry
032{
033    /**
034     * Registers a MBean in the MBeanServer
035     * 
036     * @param obj
037     *            the MBean
038     * @param managementInterface
039     *            The ManagementInterface if obj is a Standard MBean Can be null, if obj implements
040     *            DynamicMBean
041     * @param objectname
042     *            ObjectName of the MBean
043     * @throws JMException
044     *             If JMX calls fail
045     */
046    public abstract ObjectInstance registerMBean(Object obj, Class managementInterface,
047            ObjectName objectname) throws InstanceAlreadyExistsException,
048            MBeanRegistrationException, NotCompliantMBeanException;
049
050    /**
051     * Unregisters a MBean from the MBeanServer
052     * 
053     * @param objectname
054     *            ObjectName of the MBean
055     * @throws InstanceNotFoundException
056     * @throws MBeanRegistrationException
057     */
058    public abstract void unregisterMBean(ObjectName objectname) throws InstanceNotFoundException,
059            MBeanRegistrationException;
060}