Search in sources :

Example 91 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project tomcat70 by apache.

the class MemoryUserDatabaseMBean method findGroup.

/**
 * Return the MBean Name for the specified group name (if any);
 * otherwise return <code>null</code>.
 *
 * @param groupname Group name to look up
 */
public String findGroup(String groupname) {
    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.findGroup(groupname);
    if (group == null) {
        return (null);
    }
    try {
        ObjectName oname = MBeanUtils.createObjectName(managedGroup.getDomain(), group);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for group [" + groupname + "]");
        iae.initCause(e);
        throw iae;
    }
}
Also used : Group(org.apache.catalina.Group) MalformedObjectNameException(javax.management.MalformedObjectNameException) UserDatabase(org.apache.catalina.UserDatabase) ObjectName(javax.management.ObjectName)

Example 92 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project tomcat70 by apache.

the class MemoryUserDatabaseMBean method findUser.

/**
 * Return the MBean Name for the specified user name (if any);
 * otherwise return <code>null</code>.
 *
 * @param username User name to look up
 */
public String findUser(String username) {
    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return (null);
    }
    try {
        ObjectName oname = MBeanUtils.createObjectName(managedUser.getDomain(), user);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for user [" + username + "]");
        iae.initCause(e);
        throw iae;
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) User(org.apache.catalina.User) UserDatabase(org.apache.catalina.UserDatabase) ObjectName(javax.management.ObjectName)

Example 93 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project tomcat70 by apache.

the class UserMBean method getGroups.

// ------------------------------------------------------------- Attributes
/**
 * Return the MBean Names of all groups this user is a member of.
 */
public String[] getGroups() {
    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Group> groups = user.getGroups();
    while (groups.hasNext()) {
        Group group = null;
        try {
            group = groups.next();
            ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), group);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for group " + group);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);
}
Also used : Group(org.apache.catalina.Group) MalformedObjectNameException(javax.management.MalformedObjectNameException) User(org.apache.catalina.User) ArrayList(java.util.ArrayList) ObjectName(javax.management.ObjectName)

Example 94 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project tomcat70 by apache.

the class UserMBean method getRoles.

/**
 * Return the MBean Names of all roles assigned to this user.
 */
public String[] getRoles() {
    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Role> roles = user.getRoles();
    while (roles.hasNext()) {
        Role role = null;
        try {
            role = roles.next();
            ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), role);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for role " + role);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);
}
Also used : Role(org.apache.catalina.Role) MalformedObjectNameException(javax.management.MalformedObjectNameException) User(org.apache.catalina.User) ArrayList(java.util.ArrayList) ObjectName(javax.management.ObjectName)

Example 95 with MalformedObjectNameException

use of javax.management.MalformedObjectNameException in project tomcat70 by apache.

the class SlowQueryReportJmx method deregisterJmx.

protected void deregisterJmx() {
    try {
        if (mbeans.remove(poolName) != null) {
            ObjectName oname = getObjectName(getClass(), poolName);
            ManagementFactory.getPlatformMBeanServer().unregisterMBean(oname);
        }
    } catch (MBeanRegistrationException e) {
        log.debug("Jmx deregistration failed.", e);
    } catch (InstanceNotFoundException e) {
        log.debug("Jmx deregistration failed.", e);
    } catch (MalformedObjectNameException e) {
        log.warn("Jmx deregistration failed.", e);
    } catch (RuntimeOperationsException e) {
        log.warn("Jmx deregistration failed.", e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Aggregations

MalformedObjectNameException (javax.management.MalformedObjectNameException)309 ObjectName (javax.management.ObjectName)285 InstanceNotFoundException (javax.management.InstanceNotFoundException)88 MBeanServer (javax.management.MBeanServer)80 MBeanRegistrationException (javax.management.MBeanRegistrationException)75 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)63 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)59 IOException (java.io.IOException)53 ArrayList (java.util.ArrayList)45 ReflectionException (javax.management.ReflectionException)30 MBeanException (javax.management.MBeanException)23 Test (org.testng.annotations.Test)23 CompositeData (javax.management.openmbean.CompositeData)18 Notification (javax.management.Notification)15 MBeanInfo (javax.management.MBeanInfo)14 AttributeNotFoundException (javax.management.AttributeNotFoundException)13 HashMap (java.util.HashMap)11 Map (java.util.Map)11 IntrospectionException (javax.management.IntrospectionException)11 MalformedURLException (java.net.MalformedURLException)10