Example usage for javax.management MBeanException getMessage

List of usage examples for javax.management MBeanException getMessage

Introduction

In this page you can find the example usage for javax.management MBeanException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.flexive.shared.mbeans.FxCacheProxy.java

private FxCacheException newMBeanException(MBeanException e) {
    return new FxCacheException(
            "Cache error invoking the managed bean: " + e.getMessage() + ", TargetException: "
                    + (e.getTargetException() == null ? "(unknown)" : e.getTargetException().getMessage()),
            e.getTargetException());/*  ww  w .  j  av a  2  s .c  om*/
}

From source file:com.flexive.shared.mbeans.FxCacheProxy.java

private FxBackingCache getBackingCache() {
    try {/*from  ww  w  .j a  v a2s .  c  o m*/
        return (FxBackingCache) server.getAttribute(name, "FxCache");
    } catch (MBeanException e) {
        throw new RuntimeException(
                "Cache error invoking the managed bean: " + e.getMessage() + ", TargetException: "
                        + (e.getTargetException() == null ? "(unknown)" : e.getTargetException().getMessage()));
    } catch (AttributeNotFoundException e) {
        throw new RuntimeException("Attribute FxCache not found in managed cache bean: " + e.getMessage());
    } catch (InstanceNotFoundException e) {
        throw new RuntimeException("No FxCache instance found!");
    } catch (ReflectionException e) {
        throw new RuntimeException(
                "Could not invoke operation on FxCache (reflection error): " + e.getMessage());
    }
}

From source file:org.josso.agent.SSOAgentMBean.java

public void addPartnerApp(String id, String vhost, String context, String[] ignoredWebResources) {

    if (context == null) {
        logger.warn("Tryint to add 'null' context as partner app.");
        return;/* w  w w. ja v a 2s  .c o  m*/
    }

    if (ignoredWebResources == null) {
        ignoredWebResources = new String[0];
    }

    SSOAgent a = getSSOAgent();
    SSOAgentConfiguration cfg = a.getConfiguration();
    cfg.addSSOPartnerApp(id, vhost, context, ignoredWebResources, null);

    List papps = cfg.getSsoPartnerApps();

    for (int i = 0; i < papps.size(); i++) {
        SSOPartnerAppConfig papp = (SSOPartnerAppConfig) papps.get(i);
        if (papp.getContext().equals(context)) {

            // Send a JMX notification, use parent ObjectName instance (oname).
            Notification n = new SSOAgentMBeanNotification(JOSSO_AGENT_EVENT_ADD_PARTNER_APP, oname, _seq++);
            n.setUserData(papp);

            try {
                this.sendNotification(n);
                return;

            } catch (MBeanException e) {
                logger.warn("Can't send JMX notificatin : \n" + e.getMessage(), e);
            }
        }
    }

}

From source file:org.josso.agent.SSOAgentMBean.java

public void removePartnerApp(String context) {

    if (context == null) {
        logger.warn("Trying to remove 'null' context");
        return;//  w ww. ja v  a  2 s .  c o m
    }
    SSOAgent a = getSSOAgent();
    a.getConfiguration().removeSSOPartnerApp(context);
    try {
        // Send a JMX notification, use parent ObjectName instance (oname).
        Notification n = new SSOAgentMBeanNotification(JOSSO_AGENT_EVENT_REMOVE_PARTNER_APP, oname, _seq++);
        n.setUserData(context);
        this.sendNotification(n);

    } catch (MBeanException e) {
        logger.warn("Can't send JMX notificatin : \n" + e.getMessage(), e);
    }
}

From source file:org.josso.gateway.event.security.SSOEventManagerMBean.java

/**
 * This method will be invoked by the outer class when sending SSO Events.
 *
 * @param event/*from   ww w  . java  2 s.c om*/
 */
public void fireJMXSSOEvent(Notification event) {
    try {

        sendNotification(event);

        if (logger.isDebugEnabled())
            logger.debug("Sent notification : " + event);
    } catch (MBeanException e) {
        logger.error("Can't send JMX Notification : " + e.getMessage(), e);
    }
}

From source file:org.springframework.jmx.access.MBeanClientInterceptor.java

/**
 * Route the invocation to the configured managed resource. Correctly routes JavaBean property
 * access to {@code MBeanServerConnection.get/setAttribute} and method invocation to
 * {@code MBeanServerConnection.invoke}.
 * @param invocation the {@code MethodInvocation} to re-route
 * @return the value returned as a result of the re-routed invocation
 * @throws Throwable an invocation error propagated to the user
 *///  w  w  w .  j ava2s  .c o  m
@Nullable
protected Object doInvoke(MethodInvocation invocation) throws Throwable {
    Method method = invocation.getMethod();
    try {
        Object result;
        if (this.invocationHandler != null) {
            result = this.invocationHandler.invoke(invocation.getThis(), method, invocation.getArguments());
        } else {
            PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
            if (pd != null) {
                result = invokeAttribute(pd, invocation);
            } else {
                result = invokeOperation(method, invocation.getArguments());
            }
        }
        return convertResultValueIfNecessary(result, new MethodParameter(method, -1));
    } catch (MBeanException ex) {
        throw ex.getTargetException();
    } catch (RuntimeMBeanException ex) {
        throw ex.getTargetException();
    } catch (RuntimeErrorException ex) {
        throw ex.getTargetError();
    } catch (RuntimeOperationsException ex) {
        // This one is only thrown by the JMX 1.2 RI, not by the JDK 1.5 JMX code.
        RuntimeException rex = ex.getTargetException();
        if (rex instanceof RuntimeMBeanException) {
            throw ((RuntimeMBeanException) rex).getTargetException();
        } else if (rex instanceof RuntimeErrorException) {
            throw ((RuntimeErrorException) rex).getTargetError();
        } else {
            throw rex;
        }
    } catch (OperationsException ex) {
        if (ReflectionUtils.declaresException(method, ex.getClass())) {
            throw ex;
        } else {
            throw new InvalidInvocationException(ex.getMessage());
        }
    } catch (JMException ex) {
        if (ReflectionUtils.declaresException(method, ex.getClass())) {
            throw ex;
        } else {
            throw new InvocationFailureException("JMX access failed", ex);
        }
    } catch (IOException ex) {
        if (ReflectionUtils.declaresException(method, ex.getClass())) {
            throw ex;
        } else {
            throw new MBeanConnectFailureException("I/O failure during JMX access", ex);
        }
    }
}

From source file:org.wso2.carbon.analytics.common.jmx.agent.JmxAgentWebInterface.java

/**
 * @param mBean    : The name of the MBean
 * @param url      : The URL for the JMX server
 * @param userName : The User name for the JMX server
 * @param password : The password for the JMX server
 * @return : The set of attributes in a MBean
 * @throws MalformedObjectNameException/*  w  w w  .  jav a 2 s.  c  o m*/
 * @throws IntrospectionException
 * @throws InstanceNotFoundException
 * @throws IOException
 * @throws ReflectionException
 */
public String[][] getMBeanAttributeInfo(String mBean, String url, String userName, String password)
        throws MalformedObjectNameException, IntrospectionException, InstanceNotFoundException, IOException,
        ReflectionException {

    JMXConnector jmxc = getJmxConnector(url, userName, password);

    MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
    ObjectName mBeanName = new ObjectName(mBean);

    MBeanAttributeInfo[] attrs = mbsc.getMBeanInfo(mBeanName).getAttributes();

    ArrayList<String[]> strAttrs = new ArrayList<String[]>();

    for (MBeanAttributeInfo info : attrs) {

        //check the suitability of the attribute
        try {
            Object result = mbsc.getAttribute(mBeanName, info.getName());

            //if this is an instance of a primary data type supported by cassandra
            if (result instanceof String || result instanceof Integer || result instanceof Double
                    || result instanceof Long || result instanceof Boolean || result instanceof Float) {
                strAttrs.add(new String[] { info.getName() });
            }

            //if this is a composite data type
            if (result instanceof CompositeData) {
                CompositeData cd = (CompositeData) result;
                ArrayList<String> keys = new ArrayList<String>();
                //add the attribute name
                keys.add(info.getName());
                for (String key : cd.getCompositeType().keySet()) {
                    //check whether the key returns a primary data type
                    Object attrValue = cd.get(key);
                    if (attrValue instanceof String || attrValue instanceof Integer
                            || attrValue instanceof Double || attrValue instanceof Long
                            || attrValue instanceof Boolean || attrValue instanceof Float) {
                        keys.add(key);
                    }
                }
                //if this composite data object has keys which returns attributes with
                // primary data types
                if (keys.size() > 1) {
                    strAttrs.add(keys.toArray(new String[keys.size()]));
                }
            }
        } catch (MBeanException e) {
            log.error("Removed the attribute " + info.getName() + " of " + mBean + " from the UI list due to: "
                    + e.getMessage());
        } catch (AttributeNotFoundException e) {
            log.error("Removed the attribute " + info.getName() + " of " + mBean + " from the UI list due to: "
                    + e.getMessage());
        } catch (UnmarshalException e) {
            log.error("Removed the attribute " + info.getName() + " of " + mBean + " from the UI list due to: "
                    + e.getMessage());
        } catch (RuntimeOperationsException e) {
            log.error("Removed the attribute " + info.getName() + " of " + mBean + " from the UI list due to: "
                    + e.getMessage());

        } catch (RuntimeMBeanException e) {
            log.error("Removed the attribute " + info.getName() + " of " + mBean + " from the UI list due to: "
                    + e.getMessage());
        } catch (ReflectionException e) {
            log.error("Removed the attribute " + info.getName() + " of " + mBean + " from the UI list due to: "
                    + e.getMessage());
        } catch (Exception e) {
            log.error("Removed the attribute " + info.getName() + " of " + mBean + " from the UI list due to: "
                    + e.getMessage());
        }
    }

    //close the connection
    jmxc.close();

    return strAttrs.toArray(new String[strAttrs.size()][]);
}