Search in sources :

Example 6 with Logger

use of mx4j.log.Logger in project geode by apache.

the class MX4JModelMBean method sendAttributeChangeNotification.

public void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException, RuntimeOperationsException {
    if (notification == null)
        throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_NOTIFICATION_CANNOT_BE_NULL.toLocalizedString()));
    getAttributeChangeBroadcaster().sendNotification(notification);
    Logger modelMBeanLogger = getModelMBeanLogger(notification.getType());
    if (modelMBeanLogger != null)
        if (modelMBeanLogger.isEnabledFor(Logger.DEBUG))
            modelMBeanLogger.debug("ModelMBean log: " + new Date() + " - " + notification);
    Logger logger = getLogger();
    if (logger.isEnabledFor(Logger.DEBUG))
        logger.debug("Attribute change notification " + notification + " sent");
}
Also used : Logger(mx4j.log.Logger) FileLogger(mx4j.log.FileLogger) MBeanLogger(mx4j.log.MBeanLogger) Date(java.util.Date) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 7 with Logger

use of mx4j.log.Logger in project geode by apache.

the class MX4JModelMBean method setManagedResource.

public void setManagedResource(Object resource, String resourceType) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException {
    if (resource == null)
        throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_MANAGED_RESOURCE_CANNOT_BE_NULL.toLocalizedString()));
    if (!isResourceTypeSupported(resourceType))
        throw new InvalidTargetObjectTypeException(resourceType);
    Logger logger = getLogger();
    if (logger.isEnabledFor(Logger.DEBUG))
        logger.debug("Setting managed resource to be: " + resource);
    m_managedResource = resource;
}
Also used : InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) Logger(mx4j.log.Logger) FileLogger(mx4j.log.FileLogger) MBeanLogger(mx4j.log.MBeanLogger) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 8 with Logger

use of mx4j.log.Logger in project geode by apache.

the class MX4JModelMBean method getPersistPolicy.

private int getPersistPolicy(Descriptor descriptor, Descriptor mbean) {
    Logger logger = getLogger();
    String persist = (String) descriptor.getFieldValue("persistPolicy");
    if (persist == null && mbean != null)
        persist = (String) mbean.getFieldValue("persistPolicy");
    if (persist == null) {
        if (logger.isEnabledFor(Logger.TRACE))
            logger.trace("No persist policy defined, assuming Never");
        return PERSIST_NEVER;
    } else {
        if (persist.equals("Never")) {
            if (logger.isEnabledFor(Logger.TRACE))
                logger.trace("Persist never");
            return PERSIST_NEVER;
        } else if (persist.equals("OnUpdate")) {
            if (logger.isEnabledFor(Logger.TRACE))
                logger.trace("Persist on update");
            return PERSIST_ON_UPDATE;
        } else if (persist.equals("OnTimer")) {
            if (logger.isEnabledFor(Logger.TRACE))
                logger.trace("Persist on update");
            return PERSIST_ON_TIMER;
        } else if (persist.equals("NoMoreOftenThan")) {
            if (logger.isEnabledFor(Logger.TRACE)) {
                Long period = getFieldTimeValue(descriptor, mbean, "persistPeriod");
                logger.trace("Persist no more often than " + period);
            }
            return PERSIST_NO_MORE_OFTEN_THAN;
        } else {
            // Garbage, assuming Never
            if (logger.isEnabledFor(Logger.TRACE))
                logger.trace("Invalid persist policy, assuming persist never");
            return PERSIST_NEVER;
        }
    }
}
Also used : Logger(mx4j.log.Logger) FileLogger(mx4j.log.FileLogger) MBeanLogger(mx4j.log.MBeanLogger)

Example 9 with Logger

use of mx4j.log.Logger in project geode by apache.

the class MX4JModelMBean method resolveTargetObject.

private Object resolveTargetObject(Descriptor descriptor) throws MBeanException {
    Logger logger = getLogger();
    Object target = descriptor.getFieldValue("targetObject");
    if (logger.isEnabledFor(Logger.TRACE))
        logger.trace("targetObject is: " + target);
    if (target == null) {
        target = getManagedResource();
    } else {
        String targetObjectType = (String) descriptor.getFieldValue("targetObjectType");
        if (logger.isEnabledFor(Logger.TRACE))
            logger.trace("targetObjectType is: " + targetObjectType);
        if (targetObjectType == null) {
            // Not defined, assume object reference
            targetObjectType = OBJECT_RESOURCE_TYPE;
        }
        if (!isResourceTypeSupported(targetObjectType))
            throw new MBeanException(new InvalidTargetObjectTypeException(targetObjectType));
    }
    return target;
}
Also used : MBeanException(javax.management.MBeanException) Logger(mx4j.log.Logger) FileLogger(mx4j.log.FileLogger) MBeanLogger(mx4j.log.MBeanLogger) InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException)

Example 10 with Logger

use of mx4j.log.Logger in project geode by apache.

the class MX4JModelMBean method getAttributes.

public AttributeList getAttributes(String[] attributes) {
    if (attributes == null)
        throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_ATTRIBUTE_NAMES_CANNOT_BE_NULL.toLocalizedString()));
    Logger logger = getLogger();
    AttributeList list = new AttributeList();
    for (int i = 0; i < attributes.length; ++i) {
        String attrName = attributes[i];
        Attribute attribute = null;
        try {
            Object value = getAttribute(attrName);
            attribute = new Attribute(attrName, value);
            list.add(attribute);
        } catch (Exception x) {
            if (logger.isEnabledFor(Logger.TRACE))
                logger.trace("getAttribute for attribute " + attrName + " failed", x);
        // And go on with the next attribute
        }
    }
    return list;
}
Also used : Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) Logger(mx4j.log.Logger) FileLogger(mx4j.log.FileLogger) MBeanLogger(mx4j.log.MBeanLogger) AttributeNotFoundException(javax.management.AttributeNotFoundException) ServiceNotFoundException(javax.management.ServiceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ReflectionException(javax.management.ReflectionException) InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) RuntimeErrorException(javax.management.RuntimeErrorException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MalformedObjectNameException(javax.management.MalformedObjectNameException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) ListenerNotFoundException(javax.management.ListenerNotFoundException) ImplementationException(mx4j.ImplementationException) RuntimeOperationsException(javax.management.RuntimeOperationsException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Aggregations

FileLogger (mx4j.log.FileLogger)19 Logger (mx4j.log.Logger)19 MBeanLogger (mx4j.log.MBeanLogger)19 RuntimeOperationsException (javax.management.RuntimeOperationsException)10 MBeanException (javax.management.MBeanException)9 Descriptor (javax.management.Descriptor)7 MalformedObjectNameException (javax.management.MalformedObjectNameException)6 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 AttributeNotFoundException (javax.management.AttributeNotFoundException)5 InstanceNotFoundException (javax.management.InstanceNotFoundException)5 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)5 ReflectionException (javax.management.ReflectionException)5 RuntimeErrorException (javax.management.RuntimeErrorException)5 ServiceNotFoundException (javax.management.ServiceNotFoundException)5 ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)5 ListenerNotFoundException (javax.management.ListenerNotFoundException)4 MBeanRegistrationException (javax.management.MBeanRegistrationException)4 ModelMBeanAttributeInfo (javax.management.modelmbean.ModelMBeanAttributeInfo)4 ImplementationException (mx4j.ImplementationException)4