Example usage for javax.management MBeanException MBeanException

List of usage examples for javax.management MBeanException MBeanException

Introduction

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

Prototype

public MBeanException(java.lang.Exception e) 

Source Link

Document

Creates an MBeanException that wraps the actual java.lang.Exception.

Usage

From source file:catalina.mbeans.MBeanUtils.java

/**
 * Create, register, and return an MBean for this
 * <code>Engine</code> object.
 *
 * @param engine The Engine to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 *///from  w  ww. j a v  a 2 s .  co  m
public static ModelMBean createMBean(Engine engine) throws Exception {

    String mname = createManagedName(engine);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with " + mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(engine);
    ObjectName oname = createObjectName(domain, engine);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}

From source file:org.apache.tomcat.util.mx.DynamicMBeanProxy.java

/**
 * Invoke a method. Only no param methods are supported at the moment
 * ( init, start, execute, etc ) ( that's the most common pattern we have
 *  in tomcat/ant/etc )//from   www.ja v a  2  s. c om
 *
 * @todo Implement invoke for methods with more arguments.
 */
public Object invoke(String method, Object[] arguments, String[] params)
        throws MBeanException, ReflectionException {
    if (methods == null)
        init();
    Method m = (Method) invokeAttMap.get(method);
    if (m == null)
        return null;

    try {
        log.info(real.getClass().getName() + "invoke " + m.getName());
        return m.invoke(real, NO_ARGS_PARAM);
    } catch (IllegalAccessException ex) {
        throw new MBeanException(ex);
    } catch (InvocationTargetException ex1) {
        throw new MBeanException(ex1);
    }
}

From source file:catalina.mbeans.MBeanUtils.java

/**
 * Create, register, and return an MBean for this
 * <code>Group</code> object.
 *
 * @param group The Group to be managed/*from  w w w.j  av  a 2s.  c o m*/
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(Group group) throws Exception {

    String mname = createManagedName(group);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with " + mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(group);
    ObjectName oname = createObjectName(domain, group);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}

From source file:catalina.mbeans.MBeanUtils.java

/**
 * Create, register, and return an MBean for this
 * <code>Host</code> object.
 *
 * @param host The Host to be managed/*  w  w  w  .  ja v  a2s. c o m*/
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(Host host) throws Exception {

    String mname = createManagedName(host);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with " + mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(host);
    ObjectName oname = createObjectName(domain, host);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}

From source file:catalina.mbeans.MBeanUtils.java

/**
 * Create, register, and return an MBean for this
 * <code>Loader</code> object.
 *
 * @param loader The Loader to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 *//*from   w w  w  .j a  v  a 2 s.  com*/
public static ModelMBean createMBean(Loader loader) throws Exception {

    String mname = createManagedName(loader);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with " + mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(loader);
    ObjectName oname = createObjectName(domain, loader);
    mserver.registerMBean(mbean, oname);
    return (mbean);
}

From source file:catalina.mbeans.MBeanFactory.java

/**
 * Create a new HttpConnector/*from  www .  ja v a 2 s. c  o m*/
 *
 * @param parent MBean Name of the associated parent component
 * @param address The IP address on which to bind
 * @param port TCP port number to listen on
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createHttpConnector(String parent, String address, int port) throws Exception {

    Object retobj = null;

    try {

        // Create a new CoyoteConnector instance
        // use reflection to avoid j-t-c compile-time circular dependencies
        Class cls = Class.forName("org.apache.coyote.tomcat4.CoyoteConnector");
        Constructor ct = cls.getConstructor(null);
        retobj = ct.newInstance(null);
        Class partypes1[] = new Class[1];
        // Set address
        String str = new String();
        partypes1[0] = str.getClass();
        Method meth1 = cls.getMethod("setAddress", partypes1);
        Object arglist1[] = new Object[1];
        arglist1[0] = address;
        meth1.invoke(retobj, arglist1);
        // Set port number
        Class partypes2[] = new Class[1];
        partypes2[0] = Integer.TYPE;
        Method meth2 = cls.getMethod("setPort", partypes2);
        Object arglist2[] = new Object[1];
        arglist2[0] = new Integer(port);
        meth2.invoke(retobj, arglist2);
    } catch (Exception e) {
        throw new MBeanException(e);
    }

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    Server server = ServerFactory.getServer();
    Service service = server.findService(pname.getKeyProperty("name"));
    service.addConnector((Connector) retobj);

    // Return the corresponding MBean name
    ManagedBean managed = registry.findManagedBean("CoyoteConnector");
    ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), (Connector) retobj);
    return (oname.toString());

}

From source file:org.skfiy.typhon.spi.GMConsoleProvider.java

private String transcoding(String userName) throws Exception {
    try {//from  w ww .ja  v a  2s  .c  o  m
        return new String(userName.getBytes("ISO-8859-1"), "UTF-8");
    } catch (Exception e) {
        throw new MBeanException(e);
    }
}

From source file:catalina.mbeans.MBeanUtils.java

/**
 * Create, register, and return an MBean for this
 * <code>Logger</code> object.
 *
 * @param logger The Logger to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 *//* ww  w  .  j  a va 2  s  . c o  m*/
public static ModelMBean createMBean(Logger logger) throws Exception {

    String mname = createManagedName(logger);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with " + mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(logger);
    ObjectName oname = createObjectName(domain, logger);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}

From source file:catalina.mbeans.MBeanUtils.java

/**
 * Create, register, and return an MBean for this
 * <code>Manager</code> object.
 *
 * @param manager The Manager to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 *///from   w  w  w  .jav a 2  s  . c o m
public static ModelMBean createMBean(Manager manager) throws Exception {

    String mname = createManagedName(manager);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with " + mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(manager);
    ObjectName oname = createObjectName(domain, manager);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}

From source file:com.flexive.ejb.mbeans.FxCache.java

/**
 * {@inheritDoc}/* www  .  j ava2 s.co m*/
 */
@Override
public Object invoke(String actionName, Object params[], String signature[])
        throws MBeanException, ReflectionException {
    try {
        if ("get".equals(actionName)) {
            return get((String) params[0], params[1]);
        } else if ("put".equals(actionName)) {
            put((String) params[0], params[1], params[2]);
        } else if ("remove".equals(actionName) && params.length == 1) {
            remove((String) params[0]);
        } else if ("remove".equals(actionName) && params.length == 2) {
            remove((String) params[0], params[1]);
        } else if ("exists".equals(actionName) && params.length == 2) {
            return exists((String) params[0], params[1]);
        } else if ("getKeys".equals(actionName)) {
            return getKeys((String) params[0]);
        } else if ("globalGet".equals(actionName)) {
            return globalGet((String) params[0], params[1]);
        } else if ("globalPut".equals(actionName)) {
            globalPut((String) params[0], params[1], params[2]);
        } else if ("globalRemove".equals(actionName) && params.length == 1) {
            globalRemove((String) params[0]);
        } else if ("globalRemove".equals(actionName) && params.length == 2) {
            globalRemove((String) params[0], params[1]);
        } else if ("globalExists".equals(actionName) && params.length == 2) {
            return globalExists((String) params[0], params[1]);
        } else if ("globalGetKeys".equals(actionName) && params.length == 1) {
            return globalGetKeys((String) params[0]);
        } else if ("getChildrenNames".equals(actionName)) {
            return getChildrenNames((String) params[0]);
        } else if ("reloadEnvironment".equals(actionName)) {
            reloadEnvironment((Integer) params[0]);
        } else if ("create".equals(actionName)) {
            create();
        } else if ("destroy".equals(actionName)) {
            destroy();
        } else if ("setEvictionStrategy".equals(actionName) && params.length == 5) {
            setEvictionStrategy((Integer) params[0], (String) params[1], (Integer) params[2],
                    (Integer) params[3], (Integer) params[4]);
        } else if ("setEvictionStrategy".equals(actionName) && params.length == 6) {
            setEvictionStrategy((Integer) params[0], (String) params[1], (Integer) params[2],
                    (Integer) params[3], (Integer) params[4], (Boolean) params[5]);
        } else if ("cleanupAfterRequest".equals(actionName)) {
            cleanupAfterRequest();
        } else if ("isPathLockedInTx".equals(actionName)) {
            return isPathLockedInTx((String) params[0]);
        } else {
            LOG.warn("Tried to call [" + actionName + "] which is not implemented!");
        }
    } catch (Exception e) {
        LOG.error("Failed to invoke MBean op: " + e.getMessage());
        throw new MBeanException(e);
    }
    return null; //To change body of implemented methods use File | Settings | File Templates.
}