/** * Remove an existing group and destroy the corresponding MBean. * * @param groupname Group name to remove */ public void removeGroup(String groupname) { UserDatabase database = (UserDatabase) this.resource; Group group = database.findGroup(groupname); if (group == null) { return; } try { MBeanUtils.destroyMBean(group); database.removeGroup(group); } catch (Exception e) { IllegalArgumentException iae = new IllegalArgumentException("Exception destroying group [" + groupname + "] MBean"); iae.initCause(e); throw iae; } }
/** * 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; } }