FileDocCategorySizeDatePackage
GroupMBean.javaAPI DocGlassfish v2 API6869Fri May 04 22:32:10 BST 2007org.apache.catalina.mbeans

GroupMBean

public class GroupMBean extends com.sun.org.apache.commons.modeler.BaseModelMBean

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

author
Craig R. McClanahan
version
$Revision: 1.5 $ $Date: 2007/05/05 05:32:09 $

Fields Summary
protected MBeanServer
mserver
The MBeanServer in which we are registered.
protected com.sun.org.apache.commons.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();
        registry = MBeanUtils.createRegistry();
    
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);