FileDocCategorySizeDatePackage
GroupMBean.javaAPI DocApache Tomcat 6.0.145951Fri Jul 20 04:20:34 BST 2007org.apache.catalina.mbeans

GroupMBean

public class GroupMBean extends org.apache.tomcat.util.modeler.BaseModelMBean

A ModelMBean implementation for the org.apache.catalina.Group component.

author
Craig R. McClanahan
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
protected org.apache.tomcat.util.modeler.Registry
registry
The configuration information registry for our managed beans.
protected MBeanServer
mserver
The MBeanServer in which we are registered.
protected org.apache.tomcat.util.modeler.ManagedBean
managed
The ManagedBean information describing this MBean.
Constructors Summary
public GroupMBean()
Construct a ModelMBean with default ModelMBeanInfo information.

exception
MBeanException if the initializer of an object throws an exception
exception
RuntimeOperationsException if an IllegalArgumentException occurs


        super();

    
Methods Summary
public voidaddRole(java.lang.String rolename)
Add a new {@link Role} to those this group belongs to.

param
rolename Role name of the new role


        Group group = (Group) this.resource;
        if (group == null) {
            return;
        }
        Role role = group.getUserDatabase().findRole(rolename);
        if (role == null) {
            throw new IllegalArgumentException
                ("Invalid role name '" + rolename + "'");
        }
        group.addRole(role);

    
public java.lang.String[]getRoles()
Return the MBean Names of all authorized roles for this group.



    // ------------------------------------------------------------- Attributes


                    
       

        Group group = (Group) this.resource;
        ArrayList results = new ArrayList();
        Iterator roles = group.getRoles();
        while (roles.hasNext()) {
            Role role = null;
            try {
                role = (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 ((String[]) results.toArray(new String[results.size()]));

    
public java.lang.String[]getUsers()
Return the MBean Names of all users that are members of this group.


        Group group = (Group) this.resource;
        ArrayList results = new ArrayList();
        Iterator users = group.getUsers();
        while (users.hasNext()) {
            User user = null;
            try {
                user = (User) users.next();
                ObjectName oname =
                    MBeanUtils.createObjectName(managed.getDomain(), user);
                results.add(oname.toString());
            } catch (MalformedObjectNameException e) {
                IllegalArgumentException iae = new IllegalArgumentException
                    ("Cannot create object name for user " + user);
                iae.initCause(e);
                throw iae;
            }
        }
        return ((String[]) results.toArray(new String[results.size()]));

    
public voidremoveRole(java.lang.String rolename)
Remove a {@link Role} from those this group belongs to.

param
rolename Role name of the old role


        Group group = (Group) this.resource;
        if (group == null) {
            return;
        }
        Role role = group.getUserDatabase().findRole(rolename);
        if (role == null) {
            throw new IllegalArgumentException
                ("Invalid role name '" + rolename + "'");
        }
        group.removeRole(role);