Hi Eric,

The default IEntityGroup implementation, 
o.j.p.groups.EntityGroupImpl, caches its member keys.  As a 
result, once an EntityGroupImpl leaks out of an 
externally-managed service, it is vulnerable to becoming out 
of sync with its store.  I think the easiest approach is to 
extend EntityGroupImpl to delegate member queries 
(contains(), getMemberEntities() and getMemberGroups()) to 
the local group service and have your group store 
instantiate instances of this class.  I'm attaching an 
example of this approach.

    Dan

Eric Dalquist wrote:
> I'm writing a JDBC based group store to go against a set of tables with 
> group information maintained by another group. I have everything working 
> but can't figure out some of the caching issues. Data will be added and 
> removed from the tables by an external process. The service is 
> configured as externally managed and has caching disabled. Even so I get 
> failures (null pointers) in groups manager if groups or members are 
> removed from the DB and groups/members that are added don't show up 
> until the portal is restarted.
> 
> Any help configuring this would be much appreciated.
> 
> -Eric


-- 
You are currently subscribed to [email protected] as: [EMAIL 
PROTECTED]
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/uportal-dev
/* Copyright 2004 The JA-SIG Collaborative.  All rights reserved.
*  See license distributed with this file and
*  available online at http://www.uportal.org/license.html
*/

package edu.columbia.ais.portal.groups;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.jasig.portal.groups.EntityGroupImpl;
import org.jasig.portal.groups.GroupsException;
import org.jasig.portal.groups.IEntityGroup;
import org.jasig.portal.groups.IGroupMember;

/**
 * @author Dan Ellentuck
 * @version $Revision$
 * @see org.jasig.portal.groups.IEntityGroup
 * 
 * An [EMAIL PROTECTED] IEntityGroup} that delegates member queries 
(contains(), 
 * getMemberEntities() and getMemberGroups()) to the local group store.
 */
public class SqlGroupImpl extends EntityGroupImpl implements IEntityGroup  {

    /**
     * @param groupKey
     * @param entityType
     * @throws GroupsException
     */
    public SqlGroupImpl(String groupKey, Class entityType) throws 
GroupsException {
        super(groupKey, entityType);
    }
    /**
     * Checks if <code>GroupMember</code> gm is a member of this.
     * @return boolean
     * @param gm org.jasig.portal.groups.IGroupMember
     */
    public boolean contains(IGroupMember gm) throws GroupsException
    {
        return getLocalGroupService().contains(this,gm);
    }

    /**
     * Returns an <code>Iterator</code> over the entities in our member
     * <code>Collection</code>.
     * @return java.util.Iterator
     */
    protected java.util.Iterator getMemberEntities() throws GroupsException
    {
        List<IGroupMember> memberEntities = new ArrayList<IGroupMember>();
        for ( Iterator itr=getMembers(); itr.hasNext(); )
        {
            IGroupMember member = (IGroupMember) itr.next();
            if ( member.isEntity() )
                { memberEntities.add(member); }
        }
        return memberEntities.iterator();
    }
    /**
     * Returns an <code>Iterator</code> over the entities in our member
     * <code>Collection</code>.
     * @return java.util.Iterator
     */
    protected java.util.Iterator getMemberGroups() throws GroupsException
    {
        List<IGroupMember> memberGroups = new ArrayList<IGroupMember>();
        for ( Iterator itr=getMembers(); itr.hasNext(); )
        {
            IGroupMember member = (IGroupMember) itr.next();
            if ( member.isGroup() )
                { memberGroups.add(member); }
        }
        return memberGroups.iterator();
    }
    /**
     * Returns an <code>Iterator</code> over the <code>GroupMembers</code> in 
our
     * member <code>Collection</code>.
     * @return java.util.Iterator
     */
    public java.util.Iterator getMembers() throws GroupsException
    {
        return getLocalGroupService().findMembers(this);
    }
    
}

Reply via email to