Search in sources :

Example 11 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project aries by apache.

the class JMXAgentImpl method unregisterMBeans.

/**
     * @see org.apache.aries.jmx.agent.JMXAgent#unregisterMBeans(javax.management.MBeanServer)
     */
public synchronized void unregisterMBeans(final MBeanServer server) {
    for (MBeanHandler mBeanHandler : mbeansHandlers.keySet()) {
        if (mbeansHandlers.get(mBeanHandler) == Boolean.TRUE) {
            try {
                String name = mBeanHandler.getName();
                StandardMBean mbean = mBeanHandler.getMbean();
                if (mbean != null) {
                    logger.log(LogService.LOG_INFO, "Unregistering " + mbean.getMBeanInterface().getName() + " to MBeanServer " + server + " with name " + name);
                    server.unregisterMBean(new ObjectName(name));
                }
            } catch (MBeanRegistrationException e) {
                logger.log(LogService.LOG_ERROR, "Can't unregister MBean", e);
            } catch (InstanceNotFoundException e) {
                logger.log(LogService.LOG_ERROR, "MBean doesn't exist in the repository", e);
            } catch (MalformedObjectNameException e) {
                logger.log(LogService.LOG_ERROR, "Try to unregister with no valid objectname", e);
            } catch (NullPointerException e) {
                logger.log(LogService.LOG_ERROR, "Name of objectname can't be null ", e);
            } catch (Exception e) {
                logger.log(LogService.LOG_ERROR, "Cannot unregister MBean: " + mBeanHandler, e);
            }
        }
    }
    mbeanServers.remove(server);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) StandardMBean(javax.management.StandardMBean) InstanceNotFoundException(javax.management.InstanceNotFoundException) ConfigurationAdminMBeanHandler(org.apache.aries.jmx.cm.ConfigurationAdminMBeanHandler) ProvisioningServiceMBeanHandler(org.apache.aries.jmx.provisioning.ProvisioningServiceMBeanHandler) MBeanHandler(org.apache.aries.jmx.MBeanHandler) PackageStateMBeanHandler(org.apache.aries.jmx.framework.PackageStateMBeanHandler) PermissionAdminMBeanHandler(org.apache.aries.jmx.permissionadmin.PermissionAdminMBeanHandler) BundleStateMBeanHandler(org.apache.aries.jmx.framework.BundleStateMBeanHandler) UserAdminMBeanHandler(org.apache.aries.jmx.useradmin.UserAdminMBeanHandler) FrameworkMBeanHandler(org.apache.aries.jmx.framework.FrameworkMBeanHandler) BundleWiringStateMBeanHandler(org.apache.aries.jmx.framework.wiring.BundleWiringStateMBeanHandler) ServiceStateMBeanHandler(org.apache.aries.jmx.framework.ServiceStateMBeanHandler) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MalformedObjectNameException(javax.management.MalformedObjectNameException) ObjectName(javax.management.ObjectName)

Example 12 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project aries by apache.

the class JMXAgentImpl method unregisterMBean.

/**
     * @see org.apache.aries.jmx.agent.JMXAgent#unregisterMBean(org.apache.aries.jmx.MBeanHandler)
     */
public synchronized void unregisterMBean(final MBeanHandler mBeanHandler) {
    for (MBeanServer server : mbeanServers.keySet()) {
        String name = mBeanHandler.getName();
        try {
            logger.log(LogService.LOG_INFO, "Unregistering mbean " + " to MBeanServer " + server + " with name " + name);
            server.unregisterMBean(new ObjectName(name));
        } catch (MBeanRegistrationException e) {
            logger.log(LogService.LOG_ERROR, "Can't register MBean", e);
        } catch (InstanceNotFoundException e) {
            logger.log(LogService.LOG_ERROR, "MBean doesn't exist in the repository", e);
        } catch (MalformedObjectNameException e) {
            logger.log(LogService.LOG_ERROR, "Try to register with no valid objectname, Stopping registration", e);
            return;
        } catch (NullPointerException e) {
            logger.log(LogService.LOG_ERROR, "Name of objectname can't be null, Stopping registration", e);
            return;
        }
    }
    mbeansHandlers.put(mBeanHandler, Boolean.FALSE);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 13 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project aries by apache.

the class Activator method registerMBeans.

protected void registerMBeans(MBeanServer mbeanServer) {
    // register BlueprintStateMBean to MBean server
    LOGGER.debug("Registering bundle state monitor with MBeanServer: {} with name: {}", mbeanServer, blueprintStateName);
    try {
        StandardMBean blueprintState = new RegistrableStandardEmitterMBean(new BlueprintState(bundleContext), BlueprintStateMBean.class);
        mbeanServer.registerMBean(blueprintState, blueprintStateName);
    } catch (InstanceAlreadyExistsException e) {
        LOGGER.debug("Cannot register BlueprintStateMBean");
    } catch (MBeanRegistrationException e) {
        LOGGER.error("Cannot register BlueprintStateMBean", e);
    } catch (NotCompliantMBeanException e) {
        LOGGER.error("Cannot register BlueprintStateMBean", e);
    }
    // register BlueprintMetadataMBean to MBean server
    LOGGER.debug("Registering bundle metadata monitor with MBeanServer: {} with name: {}", mbeanServer, blueprintMetadataName);
    try {
        StandardMBean blueprintMetadata = new StandardMBean(new BlueprintMetadata(bundleContext), BlueprintMetadataMBean.class);
        mbeanServer.registerMBean(blueprintMetadata, blueprintMetadataName);
    } catch (InstanceAlreadyExistsException e) {
        LOGGER.debug("Cannot register BlueprintMetadataMBean");
    } catch (MBeanRegistrationException e) {
        LOGGER.error("Cannot register BlueprintMetadataMBean", e);
    } catch (NotCompliantMBeanException e) {
        LOGGER.error("Cannot register BlueprintMetadataMBean", e);
    }
}
Also used : StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException)

Example 14 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project aries by apache.

the class MBeanHolder method register.

void register(final MBeanServer server) {
    ObjectInstance instance;
    try {
        instance = server.registerMBean(mbean, requestedObjectName);
        registrations.put(server, instance.getObjectName());
    } catch (InstanceAlreadyExistsException e) {
        log.error("register: Failure registering MBean " + mbean, e);
    } catch (MBeanRegistrationException e) {
        log.error("register: Failure registering MBean " + mbean, e);
    } catch (NotCompliantMBeanException e) {
        log.error("register: Failure registering MBean " + mbean, e);
    }
}
Also used : NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ObjectInstance(javax.management.ObjectInstance) MBeanRegistrationException(javax.management.MBeanRegistrationException)

Example 15 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project geode by apache.

the class ConnectionNotificationFilterImpl method initializeHelperMbean.

private void initializeHelperMbean() {
    try {
        memberInfoWithStatsMBean = new MemberInfoWithStatsMBean(this);
        MBeanServer mbs = getMBeanServer();
        mbs.registerMBean(memberInfoWithStatsMBean, memberInfoWithStatsMBean.getObjectName());
    /*
       * We are not re-throwing these exceptions as failure create/register the GemFireTypesWrapper
       * will not stop the Agent from working. But we are logging it as it could be an indication of
       * some problem. Also not creating Localized String for the exception.
       */
    } catch (OperationsException e) {
        logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_FAILED_TO_INITIALIZE_MEMBERINFOWITHSTATSMBEAN), e);
    } catch (MBeanRegistrationException e) {
        logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_FAILED_TO_INITIALIZE_MEMBERINFOWITHSTATSMBEAN), e);
    } catch (AdminException e) {
        logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_FAILED_TO_INITIALIZE_MEMBERINFOWITHSTATSMBEAN), e);
    }
}
Also used : AdminException(org.apache.geode.admin.AdminException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) OperationsException(javax.management.OperationsException)

Aggregations

MBeanRegistrationException (javax.management.MBeanRegistrationException)48 ObjectName (javax.management.ObjectName)39 MalformedObjectNameException (javax.management.MalformedObjectNameException)35 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)31 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)29 InstanceNotFoundException (javax.management.InstanceNotFoundException)21 MBeanServer (javax.management.MBeanServer)20 StandardMBean (javax.management.StandardMBean)8 IOException (java.io.IOException)7 RuntimeOperationsException (javax.management.RuntimeOperationsException)5 MalformedURLException (java.net.MalformedURLException)4 JMRuntimeException (javax.management.JMRuntimeException)3 MBeanException (javax.management.MBeanException)3 ObjectInstance (javax.management.ObjectInstance)3 PrivilegedActionException (java.security.PrivilegedActionException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ReflectionException (javax.management.ReflectionException)2 Test (org.junit.Test)2 Logger (ch.qos.logback.classic.Logger)1