Search in sources :

Example 41 with InstanceAlreadyExistsException

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

the class JMXAgentImpl method registerMBeans.

/**
     * @see org.apache.aries.jmx.agent.JMXAgent#registerMBeans(javax.management.MBeanServer)
     */
public synchronized void registerMBeans(final MBeanServer server) {
    for (MBeanHandler mbeanHandler : mbeansHandlers.keySet()) {
        if (mbeansHandlers.get(mbeanHandler) == Boolean.TRUE) {
            String name = mbeanHandler.getName();
            StandardMBean mbean = mbeanHandler.getMbean();
            if (mbean != null) {
                try {
                    logger.log(LogService.LOG_INFO, "Registering " + mbean.getMBeanInterface().getName() + " to MBeanServer " + server + " with name " + name);
                    server.registerMBean(mbean, new ObjectName(name));
                } catch (InstanceAlreadyExistsException e) {
                    logger.log(LogService.LOG_ERROR, "MBean is already registered", e);
                } catch (MBeanRegistrationException e) {
                    logger.log(LogService.LOG_ERROR, "Can't register MBean", e);
                } catch (NotCompliantMBeanException e) {
                    logger.log(LogService.LOG_ERROR, "MBean is not compliant MBean", e);
                } catch (MalformedObjectNameException e) {
                    logger.log(LogService.LOG_ERROR, "Try to register with no valid objectname", e);
                } catch (NullPointerException e) {
                    logger.log(LogService.LOG_ERROR, "Name of objectname can't be null", e);
                }
            }
        }
    }
    mbeanServers.put(server, Boolean.TRUE);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) 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) ObjectName(javax.management.ObjectName)

Example 42 with InstanceAlreadyExistsException

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

the class JMXAgentImpl method registerMBean.

/**
     * @see org.apache.aries.jmx.agent.JMXAgent#registerMBean(org.apache.aries.jmx.MBeanHandler)
     */
public synchronized void registerMBean(final MBeanHandler mBeanHandler) {
    for (MBeanServer server : mbeanServers.keySet()) {
        String name = mBeanHandler.getName();
        StandardMBean mbean = mBeanHandler.getMbean();
        try {
            logger.log(LogService.LOG_INFO, "Registering " + mbean.getMBeanInterface().getName() + " to MBeanServer " + server + " with name " + name);
            server.registerMBean(mbean, new ObjectName(name));
        } catch (InstanceAlreadyExistsException e) {
            logger.log(LogService.LOG_ERROR, "MBean is already registered", e);
        } catch (MBeanRegistrationException e) {
            logger.log(LogService.LOG_ERROR, "Can't register MBean", e);
        } catch (NotCompliantMBeanException e) {
            logger.log(LogService.LOG_ERROR, "MBean is not compliant MBean, Stopping registration", e);
            return;
        } 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.TRUE);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 43 with InstanceAlreadyExistsException

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

the class ManagementAgent method registerAccessControlMBean.

private void registerAccessControlMBean() {
    try {
        AccessControlMBean acc = new AccessControlMBean();
        ObjectName accessControlMBeanON = new ObjectName(ResourceConstants.OBJECT_NAME_ACCESSCONTROL);
        MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
        Set<ObjectName> names = platformMBeanServer.queryNames(accessControlMBeanON, null);
        if (names.isEmpty()) {
            try {
                platformMBeanServer.registerMBean(acc, accessControlMBeanON);
                logger.info("Registered AccessControlMBean on " + accessControlMBeanON);
            } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
                throw new GemFireConfigException("Error while configuring accesscontrol for jmx resource", e);
            }
        }
    } catch (MalformedObjectNameException e) {
        throw new GemFireConfigException("Error while configuring accesscontrol for jmx resource", e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) GemFireConfigException(org.apache.geode.GemFireConfigException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) AccessControlMBean(org.apache.geode.management.internal.security.AccessControlMBean) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer)

Example 44 with InstanceAlreadyExistsException

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

the class MBeanJMXAdapter method registerMBean.

/**
   * This method will register an MBean in GemFire domain. Even if the client provides a domain name
   * it will be ignored and GemFire domain name will be used.
   * 
   * This method checks the local Filter for registering the MBean. If filtered the MBean wont be
   * registered. Although the filter will remember the filtered MBean and register it once the
   * filter is removed.
   * 
   * @param object
   * @param objectName
   * @return modifed ObjectName
   */
public ObjectName registerMBean(Object object, ObjectName objectName, boolean isGemFireMBean) {
    ObjectName newObjectName = objectName;
    try {
        if (!isGemFireMBean) {
            String member = getMemberNameOrId(distMember);
            String objectKeyProperty = objectName.getKeyPropertyListString();
            newObjectName = ObjectName.getInstance(OBJECTNAME__PREFIX + objectKeyProperty + KEYVAL_SEPARATOR + "member=" + member);
        }
        mbeanServer.registerMBean(object, newObjectName);
        this.localGemFireMBean.put(newObjectName, object);
    } catch (InstanceAlreadyExistsException e) {
        throw new ManagementException(e);
    } catch (MBeanRegistrationException e) {
        throw new ManagementException(e);
    } catch (NotCompliantMBeanException e) {
        throw new ManagementException(e);
    } catch (MalformedObjectNameException e) {
        throw new ManagementException(e);
    } catch (NullPointerException e) {
        throw new ManagementException(e);
    }
    return newObjectName;
}
Also used : ManagementException(org.apache.geode.management.ManagementException) MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 45 with InstanceAlreadyExistsException

use of javax.management.InstanceAlreadyExistsException in project ddf by codice.

the class Geocoding method registerMbean.

private void registerMbean() {
    ObjectName objectName = null;
    MBeanServer mBeanServer = null;
    try {
        objectName = new ObjectName(Geocoding.class.getName() + ":service=geocoding");
        mBeanServer = ManagementFactory.getPlatformMBeanServer();
    } catch (MalformedObjectNameException e) {
        LOGGER.info("Unable to create Geocoding Configuration MBean.", e);
    }
    if (mBeanServer != null) {
        try {
            try {
                mBeanServer.registerMBean(this, objectName);
                LOGGER.debug("Registered Geocoding Configuration MBean under object name: {}", objectName.toString());
            } catch (InstanceAlreadyExistsException e) {
                // Try to remove and re-register
                mBeanServer.unregisterMBean(objectName);
                mBeanServer.registerMBean(this, objectName);
                LOGGER.debug("Re-registered Geocoding Configuration MBean");
            }
        } catch (Exception e) {
            //objectName is not always non-null because new ObjectName(...) can throw an exception
            LOGGER.info("Could not register MBean [{}].", objectName != null ? objectName.toString() : Geocoding.class.getName(), e);
        }
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) GeoEntryExtractionException(org.codice.ddf.spatial.geocoding.GeoEntryExtractionException) MalformedObjectNameException(javax.management.MalformedObjectNameException) GeoEntryIndexingException(org.codice.ddf.spatial.geocoding.GeoEntryIndexingException) GeoNamesRemoteDownloadException(org.codice.ddf.spatial.geocoding.GeoNamesRemoteDownloadException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer)

Aggregations

InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)49 ObjectName (javax.management.ObjectName)38 MalformedObjectNameException (javax.management.MalformedObjectNameException)30 MBeanRegistrationException (javax.management.MBeanRegistrationException)29 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)28 MBeanServer (javax.management.MBeanServer)25 InstanceNotFoundException (javax.management.InstanceNotFoundException)14 ObjectInstance (javax.management.ObjectInstance)8 IOException (java.io.IOException)6 StandardMBean (javax.management.StandardMBean)6 Test (org.junit.Test)3 MalformedURLException (java.net.MalformedURLException)2 CacheException (javax.cache.CacheException)2 JMRuntimeException (javax.management.JMRuntimeException)2 MBeanException (javax.management.MBeanException)2 ReflectionException (javax.management.ReflectionException)2 RuntimeOperationsException (javax.management.RuntimeOperationsException)2 Logger (ch.qos.logback.classic.Logger)1 JMXConfigurator (ch.qos.logback.classic.jmx.JMXConfigurator)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1