|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jasig.portal.groups.GroupMemberImpl
org.jasig.portal.groups.EntityGroupImpl
public class EntityGroupImpl
Reference implementation for IEntityGroup.
Groups do not keep references to their members but instead cache
member keys. The members are cached externally. The rules
for controlling access to the key caches are a bit obscure, but you
should understand them before writing code that updates groups.
Access to the caches themselves is synchronized via the cache
getters and setters. All requests to get group members and to add or
remove group members ultimately go through these methods. The
mutating methods, addMember() and removeMember()
however, do a copy-on-write. That is, they first make a copy of the
cache, add or remove the member key, and then replace the original
cache with the copy. This permits multiple read and write threads to run
concurrently without throwing ConcurrentModificationExceptions.
But it still leaves open the danger of data races because nothing in
this class guarantees serialized write access. You must impose this
from without, either via explicit locking (GroupService.getLockableGroup())
or by synchronizing access from the caller.
IEntityGroup| Field Summary | |
|---|---|
protected IIndividualGroupService |
localGroupService
|
| Constructor Summary | |
|---|---|
EntityGroupImpl(String groupKey,
Class entityType)
EntityGroupImpl |
|
| Method Summary | |
|---|---|
void |
addMember(IGroupMember gm)
Adds IGroupMember gm to our member Map and conversely,
adds this to gm's group Map, after checking that the
addition does not violate group rules. |
protected boolean |
areMemberKeysInitialized()
|
protected void |
clearPendingUpdates()
Clear out caches for pending adds and deletes of group members. |
boolean |
contains(IGroupMember gm)
Checks if GroupMember gm is a member of this. |
boolean |
deepContains(IGroupMember gm)
Checks recursively if GroupMember gm is a member of this. |
void |
delete()
Delegates to the factory. |
boolean |
equals(Object obj)
Answers if Object o is an IGroupMember that refers to the same underlying
entity(ies) as this. |
HashMap |
getAddedMembers()
|
Iterator |
getAllEntities()
Returns an Iterator over the Set of this
IEntityGroup's recursively-retrieved members that are
IEntities. |
Iterator |
getAllMembers()
Returns an Iterator over the Set of recursively-retrieved
IGroupMembers that are members of this IEntityGroup. |
protected CompositeEntityIdentifier |
getCompositeEntityIdentifier()
Returns the EntityIdentifier cast to a
CompositeEntityIdentifier so that its service nodes
can be pushed and popped. |
String |
getCreatorID()
Returns the name of the group creator. |
String |
getDescription()
Returns the group description, which may be null. |
Iterator |
getEntities()
Returns an Iterator over this IEntityGroup's
members that are IEntities. |
EntityIdentifier |
getEntityIdentifier()
|
String |
getEntityKey()
Returns the key of the underyling entity. |
Class |
getEntityType()
Returns the entity type of this groups's leaf members. |
String |
getGroupID()
|
Class |
getLeafType()
Returns the entity type of this groups's members. |
protected IIndividualGroupService |
getLocalGroupService()
|
String |
getLocalKey()
Returns the key from the group service of origin. |
protected Iterator |
getMemberEntities()
Returns an Iterator over the entities in our member
Collection. |
IEntityGroup |
getMemberGroupNamed(String name)
Returns the named member IEntityGroup. |
protected Iterator |
getMemberGroups()
Returns an Iterator over the groups in our member
Collection. |
Iterator |
getMembers()
Returns an Iterator over the GroupMembers in our
member Collection. |
String |
getName()
Returns the group name. |
HashMap |
getRemovedMembers()
|
protected GroupService |
getService()
|
Name |
getServiceName()
Returns the Name of the group service of origin. |
Class |
getType()
Returns this object's type for purposes of caching and locking, as opposed to the underlying entity type. |
boolean |
hasAdds()
Answers if there are any added memberships not yet committed to the database. |
boolean |
hasDeletes()
Answers if there are any deleted memberships not yet committed to the database. |
int |
hashCode()
Generates a hash code for the receiver. |
boolean |
hasMembers()
Default implementation, overridden on EntityGroupImpl. |
boolean |
isDirty()
Answers if there are any added or deleted memberships not yet committed to the database. |
boolean |
isEditable()
Answers if this IEntityGroup can be changed or deleted. |
boolean |
isGroup()
|
protected void |
primAddMember(IGroupMember gm)
Adds the IGroupMember key to the appropriate member key
cache by copying the cache, adding to the copy, and then replacing the
original with the copy. |
protected Set |
primGetAllEntities(Set entities)
Returns the Set of IEntities in our member Collection
and, recursively, in the Collections of our members. |
protected Set |
primGetAllMembers(Set s)
Returns the Set of IGroupMembers in our member
Collection and, recursively, in the Collections
of our members. |
protected void |
primRemoveMember(IGroupMember gm)
Removes the IGroupMember key from the appropriate key cache, by
copying the cache, removing the key from the copy and replacing the original
with the copy. |
void |
primSetName(String newName)
|
void |
removeMember(IGroupMember gm)
Removes IGroupMember gm from our member Map and,
conversely, remove this from gm's group Map. |
void |
setCreatorID(String newCreatorID)
|
void |
setDescription(String newDescription)
|
void |
setLocalGroupService(IIndividualGroupService newIndividualGroupService)
Sets the group service of origin. |
void |
setName(String newName)
We used to check duplicate sibling names but no longer do. |
void |
setServiceName(Name newServiceName)
Sets the service Name of the group service of origin. |
String |
toString()
Returns a String that represents the value of this object. |
void |
update()
Delegate to the factory. |
void |
updateMembers()
Delegate to the factory. |
| Methods inherited from class org.jasig.portal.groups.GroupMemberImpl |
|---|
addGroup, castAndCopyHashSet, getAllContainingGroups, getCacheKey, getCompositeGroupService, getContainingGroups, getKey, getUnderlyingEntityIdentifier, isDeepMemberOf, isEntity, isKnownEntityType, isMemberOf, primGetAllContainingGroups, removeGroup, setGroupKeysInitialized |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.jasig.portal.groups.IGroupMember |
|---|
getAllContainingGroups, getContainingGroups, getKey, getUnderlyingEntityIdentifier, isDeepMemberOf, isEntity, isMemberOf |
| Field Detail |
|---|
protected IIndividualGroupService localGroupService
| Constructor Detail |
|---|
public EntityGroupImpl(String groupKey,
Class entityType)
throws GroupsException
GroupsException| Method Detail |
|---|
public void addMember(IGroupMember gm)
throws GroupsException
IGroupMember gm to our member Map and conversely,
adds this to gm's group Map, after checking that the
addition does not violate group rules. Remember that we have added it so we can
update the database if necessary.
addMember in interface IEntityGroupgm - org.jasig.portal.groups.IGroupMember
GroupsException - is thrown if the member is a group and
this group already has a group with the same name or if the addition
of the group creates a circular reference.protected boolean areMemberKeysInitialized()
protected void clearPendingUpdates()
public boolean contains(IGroupMember gm)
throws GroupsException
GroupMember gm is a member of this.
contains in interface IGroupMembercontains in class GroupMemberImplgm - org.jasig.portal.groups.IGroupMember
GroupsException
public boolean deepContains(IGroupMember gm)
throws GroupsException
GroupMember gm is a member of this.
deepContains in interface IGroupMemberdeepContains in class GroupMemberImplgm - org.jasig.portal.groups.IGroupMember
GroupsException
public void delete()
throws GroupsException
delete in interface IEntityGroupGroupsException - if the delete cannot be performed.public boolean equals(Object obj)
IGroupMemberIGroupMember that refers to the same underlying
entity(ies) as this.
equals in interface IGroupMemberequals in class Objectobj - the Object to compare with
Hashtablepublic HashMap getAddedMembers()
public Iterator getAllEntities()
throws GroupsException
Iterator over the Set of this
IEntityGroup's recursively-retrieved members that are
IEntities.
getAllEntities in interface IGroupMembergetAllEntities in class GroupMemberImplGroupsException
public Iterator getAllMembers()
throws GroupsException
Iterator over the Set of recursively-retrieved
IGroupMembers that are members of this IEntityGroup.
getAllMembers in interface IGroupMembergetAllMembers in class GroupMemberImplGroupsExceptionprotected CompositeEntityIdentifier getCompositeEntityIdentifier()
EntityIdentifier cast to a
CompositeEntityIdentifier so that its service nodes
can be pushed and popped.
public String getCreatorID()
IEntityGroup
getCreatorID in interface IEntityGrouppublic String getDescription()
IEntityGroup
getDescription in interface IEntityGroup
public Iterator getEntities()
throws GroupsException
Iterator over this IEntityGroup's
members that are IEntities.
getEntities in interface IGroupMembergetEntities in class GroupMemberImplGroupsExceptionpublic EntityIdentifier getEntityIdentifier()
getEntityIdentifier in interface IBasicEntitypublic String getEntityKey()
public Class getEntityType()
getEntityType in interface IGroupMemberEntityTypespublic String getGroupID()
public Class getLeafType()
getLeafType in interface IGroupMemberEntityTypesprotected IIndividualGroupService getLocalGroupService()
public String getLocalKey()
getLocalKey in interface IEntityGroup
protected Iterator getMemberEntities()
throws GroupsException
Iterator over the entities in our member
Collection.
GroupsException
public IEntityGroup getMemberGroupNamed(String name)
throws GroupsException
IEntityGroup.
getMemberGroupNamed in interface IGroupMembergetMemberGroupNamed in class GroupMemberImplname - java.lang.String
GroupsException
protected Iterator getMemberGroups()
throws GroupsException
Iterator over the groups in our member
Collection.
GroupsException
public Iterator getMembers()
throws GroupsException
Iterator over the GroupMembers in our
member Collection.
getMembers in interface IGroupMembergetMembers in class GroupMemberImplGroupsExceptionpublic String getName()
IEntityGroup
getName in interface IEntityGrouppublic HashMap getRemovedMembers()
protected GroupService getService()
throws GroupsException
GroupsExceptionpublic Name getServiceName()
getServiceName in interface IEntityGrouppublic Class getType()
getType in interface IGroupMembergetType in class GroupMemberImplpublic boolean hasAdds()
public boolean hasDeletes()
public int hashCode()
hashCode in interface IGroupMemberhashCode in class GroupMemberImplHashtable
public boolean hasMembers()
throws GroupsException
GroupMemberImpl
hasMembers in interface IGroupMemberhasMembers in class GroupMemberImplGroupsExceptionpublic boolean isDirty()
public boolean isEditable()
throws GroupsException
IEntityGroup can be changed or deleted.
isEditable in interface IEntityGroupGroupsExceptionpublic boolean isGroup()
isGroup in interface IGroupMemberisGroup in class GroupMemberImpl
protected void primAddMember(IGroupMember gm)
throws GroupsException
IGroupMember key to the appropriate member key
cache by copying the cache, adding to the copy, and then replacing the
original with the copy. At this point, gm does not yet
have this in its containing group cache. That cache entry
is not added until update(), when changes are committed to the store.
gm - org.jasig.portal.groups.IGroupMember
GroupsException
protected Set primGetAllEntities(Set entities)
throws GroupsException
Set of IEntities in our member Collection
and, recursively, in the Collections of our members.
entities - a Set that IEntity-GroupMembers are added to.
GroupsException
protected Set primGetAllMembers(Set s)
throws GroupsException
Set of IGroupMembers in our member
Collection and, recursively, in the Collections
of our members.
s - java.lang.Set - a Set that members are added to.
GroupsException
protected void primRemoveMember(IGroupMember gm)
throws GroupsException
IGroupMember key from the appropriate key cache, by
copying the cache, removing the key from the copy and replacing the original
with the copy. At this point, gm still has this
in its containing groups cache. That cache entry is not removed until update(),
when changes are committed to the store.
gm - org.jasig.portal.groups.IGroupMember
GroupsExceptionpublic void primSetName(String newName)
newName - java.lang.String
public void removeMember(IGroupMember gm)
throws GroupsException
IGroupMember gm from our member Map and,
conversely, remove this from gm's group Map. Remember that we
have removed it so we can update the database, if necessary.
removeMember in interface IEntityGroupgm - org.jasig.portal.groups.IGroupMember
GroupsExceptionpublic void setCreatorID(String newCreatorID)
setCreatorID in interface IEntityGroupnewCreatorID - java.lang.Stringpublic void setDescription(String newDescription)
setDescription in interface IEntityGroupnewDescription - java.lang.String
public void setLocalGroupService(IIndividualGroupService newIndividualGroupService)
throws GroupsException
IEntityGroup
setLocalGroupService in interface IEntityGroupnewIndividualGroupService - IIndividualGroupService
GroupsException
public void setName(String newName)
throws GroupsException
setName in interface IEntityGroupnewName - java.lang.String
GroupsException
public void setServiceName(Name newServiceName)
throws GroupsException
GroupsExceptionpublic String toString()
toString in class Object
public void update()
throws GroupsException
update in interface IEntityGroupGroupsException - if the update cannot be performed.
public void updateMembers()
throws GroupsException
updateMembers in interface IEntityGroupGroupsException - if the update cannot be performed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||