/** * Remove an existing role and destroy the corresponding MBean. * * @param rolename Role name to remove */ public void removeRole(String rolename) { UserDatabase database = (UserDatabase) this.resource; Role role = database.findRole(rolename); if (role == null) { return; } try { MBeanUtils.destroyMBean(role); database.removeRole(role); } catch (Exception e) { IllegalArgumentException iae = new IllegalArgumentException("Exception destroying role [" + rolename + "] MBean"); iae.initCause(e); throw iae; } }
/** * Return the MBean Name for the specified role name (if any); otherwise return <code>null</code>. * * @param rolename Role name to look up */ public String findRole(String rolename) { UserDatabase database = (UserDatabase) this.resource; Role role = database.findRole(rolename); if (role == null) { return (null); } try { ObjectName oname = MBeanUtils.createObjectName(managedRole.getDomain(), role); return (oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for role [" + rolename + "]"); iae.initCause(e); throw iae; } }