Author: bdaw
Date: 2009-11-04 17:30:01 -0500 (Wed, 04 Nov 2009)
New Revision: 905
Added:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/GroupSearch.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RelationshipSearch.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RoleSearch.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RoleTypeSearch.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/Search.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/UserSearch.java
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAPICacheProviderImpl.java
idm/trunk/idm-cache/src/test/java/org/jboss/identity/idm/cache/
idm/trunk/idm-cache/src/test/java/org/jboss/identity/idm/cache/APICacheProviderTestCase.java
idm/trunk/idm-cache/src/test/resources/jboss-cache.xml
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/AbstractSearch.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/GroupSearchImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RelationshipSearchImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RoleSearchImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RoleTypeSearchImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/UserSearchImpl.java
idm/trunk/idm-testsuite/src/test/resources/jboss-cache.xml
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/APICacheProvider.java
idm/trunk/idm-cache/pom.xml
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/IdentitySearchCriteriaImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/query/AbstractQuery.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/query/UserQueryImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/configuration/IdentitySessionConfigurationContext.java
idm/trunk/idm-testsuite/src/test/resources/test-identity-config.xml
Log:
- API cache
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/APICacheProvider.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/APICacheProvider.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/APICacheProvider.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -21,11 +21,7 @@
*/
package org.jboss.identity.idm.cache;
-import org.jboss.identity.idm.api.Attribute;
-import org.jboss.identity.idm.api.Group;
-import org.jboss.identity.idm.api.IdentitySearchCriteria;
-import org.jboss.identity.idm.api.Role;
-import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.*;
import org.jboss.identity.idm.api.query.GroupQuery;
import org.jboss.identity.idm.api.query.RoleQuery;
import org.jboss.identity.idm.api.query.UserQuery;
@@ -43,7 +39,16 @@
public interface APICacheProvider
{
+
/**
+ * Initialize provider.
+ * @param properties
+ */
+ void initialize(Map<String, String> properties);
+
+ void invalidate(String ns);
+
+ /**
* Generate realm namespace.
*
* @param realmId - if null will generate root namespace
@@ -92,6 +97,8 @@
void putGroups(String ns, IdentitySearchCriteria criteria, Collection<Group>
groups);
+ Collection<Group> getGroups(String ns, IdentitySearchCriteria criteria);
+
void invalidateGroups(String ns);
void putGroupCount(String ns, String groupType, int count);
@@ -100,57 +107,106 @@
void invalidateGroupCount(String ns, String groupType);
+ //
+ void putRole(String ns, Role role);
+ Role getRole(String ns, Role role);
+
+ void removeRole(String ns, Role role);
+
+ void putRoleType(String ns, RoleType roleType);
+
+ RoleType getRoleType(String ns, RoleType roleType);
+
+ void removeRoleType(String ns, RoleType roleType);
+
+
// Attribute
void putAttributes(String ns, String id, Map<String, Attribute> attributes);
Map<String, Attribute> getAttributes(String ns, String id);
+ void invalidateAttributes(String ns, String id);
+ void invalidateAttributes(String ns);
+
+ // Properties
+ void putProperties(String ns, Role role, Map<String, String> properties);
+
+ Map<String, String> getProperties(String ns, Role role);
+
+ void invalidateRoleProperties(String ns, Role role);
+
+ void invalidateRoleProperties(String ns);
+
+ void putProperties(String ns, RoleType roleType, Map<String, String>
properties);
+
+ Map<String, String> getProperties(String ns, RoleType roleType);
+
+ void invalidateRoleTypeProperties(String ns, RoleType roleType);
+
+ void invalidateRoleTypeProperties(String ns);
+
+
+ // Searches
+
+ void invalidateAllSearches(String ns);
+
+ void putUserSearch(String ns, UserSearch search, Collection<User> results);
+
+ Collection<User> getUserSearch(String ns, UserSearch search);
+
+ void putGroupSearch(String ns, GroupSearch search, Collection<Group> results);
+
+ Collection<Group> getGroupSearch(String ns, GroupSearch search);
+
+ void putRelationshipSearch(String ns, RelationshipSearch search, Boolean result);
+
+ Boolean getRelationshipSearch(String ns, RelationshipSearch search);
+
+ void putRoleSearch(String ns, RoleSearch search, Collection<Role> results);
+
+ Collection<Role> getRoleSearch(String ns, RoleSearch search);
+
+ void putRoleTypeSearch(String ns, RoleTypeSearch search, Collection<RoleType>
results);
+
+ Collection<RoleType> getRoleTypeSearch(String ns, RoleTypeSearch search);
+
+
// Queries
+ void invalidateAllQueries(String ns);
+
void putUserQuery(String ns, UserQuery q, Collection<User> results);
- void putUserQueryList(String ns, UserQuery q, List<User> results);
-
void putUserQueryUnique(String ns, UserQuery q, User user);
- Collection<User> getUserQuery(String ns, UserQuery q, Collection<User>
results);
+ Collection<User> getUserQuery(String ns, UserQuery q);
- List<User> getUserQueryList(String ns, UserQuery q, List<User> results);
+ User getUserQueryUnique(String ns, UserQuery q);
- User getUserQueryUnique(String ns, UserQuery q, User user);
-
void invalidateUserQueries(String ns);
//
void putGroupQuery(String ns, GroupQuery q, Collection<Group> results);
- void putGroupQueryList(String ns, GroupQuery q, List<Group> results);
-
void putGroupQueryUnique(String ns, GroupQuery q, Group group);
- Collection<Group> getGroupQuery(String ns, GroupQuery q, Collection<Group>
results);
+ Collection<Group> getGroupQuery(String ns, GroupQuery q);
- List<Group> getGroupQueryList(String ns, GroupQuery q, List<Group>
results);
+ Group getGroupQueryUnique(String ns, GroupQuery q);
- Group getGroupQueryUnique(String ns, GroupQuery q, Group group);
-
void invalidateGroupQueries(String ns);
//
void putRoleQuery(String ns, RoleQuery q, Collection<Role> results);
- void putRoleQueryList(String ns, RoleQuery q, List<Role> results);
-
void putRoleQueryUnique(String ns, RoleQuery q, Role role);
- Collection<Role> getRoleQuery(String ns, RoleQuery q, Collection<Role>
results);
+ Collection<Role> getRoleQuery(String ns, RoleQuery q);
- List<Role> getRoleQueryList(String ns, RoleQuery q, List<Role> results);
+ Role getRoleQueryUnique(String ns, RoleQuery q);
- Role getRoleQueryUnique(String ns, RoleQuery q, Role role);
-
void invalidateRoleQueries(String ns);
}
Added: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/GroupSearch.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/GroupSearch.java
(rev 0)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/GroupSearch.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,30 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.cache;
+
+import java.io.Serializable;
+
+public interface GroupSearch extends Search
+{
+}
Added:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RelationshipSearch.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RelationshipSearch.java
(rev 0)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RelationshipSearch.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,29 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.cache;
+
+public interface RelationshipSearch extends Search
+{
+
+}
Added: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RoleSearch.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RoleSearch.java
(rev 0)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RoleSearch.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,30 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.cache;
+
+import java.io.Serializable;
+
+public interface RoleSearch extends Search
+{
+}
Added: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RoleTypeSearch.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RoleTypeSearch.java
(rev 0)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/RoleTypeSearch.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,30 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.cache;
+
+import java.io.Serializable;
+
+public interface RoleTypeSearch extends Search
+{
+}
Added: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/Search.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/Search.java
(rev 0)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/Search.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,37 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.cache;
+
+import org.jboss.identity.idm.api.IdentitySearchCriteria;
+
+import java.io.Serializable;
+
+public interface Search extends Serializable
+{
+
+ IdentitySearchCriteria getSearchCriteria();
+
+ void setSearchCriteria(IdentitySearchCriteria searchCriteria);
+
+}
Added: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/UserSearch.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/UserSearch.java
(rev 0)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/UserSearch.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,28 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.identity.idm.cache;
+
+import java.io.Serializable;
+
+public interface UserSearch extends Search
+{
+}
Modified: idm/trunk/idm-cache/pom.xml
===================================================================
--- idm/trunk/idm-cache/pom.xml 2009-11-03 14:33:23 UTC (rev 904)
+++ idm/trunk/idm-cache/pom.xml 2009-11-04 22:30:01 UTC (rev 905)
@@ -34,11 +34,16 @@
<version>${project.version}</version>
</dependency>
-
<dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
- <version>3.0.2.GA</version>
+ <version>3.2.1.GA</version>
</dependency>
</dependencies>
Added:
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAPICacheProviderImpl.java
===================================================================
---
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAPICacheProviderImpl.java
(rev 0)
+++
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAPICacheProviderImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,1066 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.identity.idm.impl.cache;
+
+import org.jboss.identity.idm.cache.*;
+import org.jboss.identity.idm.api.*;
+import org.jboss.identity.idm.api.query.UserQuery;
+import org.jboss.identity.idm.api.query.GroupQuery;
+import org.jboss.identity.idm.api.query.RoleQuery;
+import org.jboss.identity.idm.impl.api.model.GroupId;
+import org.jboss.cache.*;
+
+import java.util.Map;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+
+/**
+ *
+ */
+public class JBossCacheAPICacheProviderImpl implements APICacheProvider
+{
+ //TODO: dobule check if invalidate methods remove everything that is needed...
+
+ private static Logger log =
Logger.getLogger(JBossCacheAPICacheProviderImpl.class.getName());
+
+ private Cache cache;
+
+ public static final String CONFIG_FILE_OPTION = "cache.configFile";
+
+ public static final String NODE_OBJECT_KEY = "object";
+
+ public static final String NODE_QUERY_KEY = "query";
+
+ public static final String NODE_QUERY_UNIQUE_KEY = "query_unique";
+
+ public static final String NODE_MAIN_ROOT = "IDM_ROOT";
+
+ public static final String NODE_USERS = "USERS";
+
+ public static final String NODE_USERS_COUNT = "USERS_COUNT";
+
+ public static final String NODE_USERS_QUERIES = "USERS_QUERIES";
+
+ public static final String NODE_USERS_CRITERIA = "USERS_CRITERIA";
+
+ public static final String NODE_USERS_SEARCHES = "USERS_SEARCHES";
+
+ public static final String NODE_GROUPS = "GROUPS";
+
+ public static final String NODE_GROUPS_COUNT = "GROUPS_COUNT";
+
+ public static final String NODE_GROUPS_QUERIES = "GROUPS_QUERIES";
+
+ public static final String NODE_GROUPS_CRITERIA = "GROUPS_CRITERIA";
+
+ public static final String NODE_GROUPS_SEARCHES = "GROUPS_SEARCHES";
+
+ public static final String NODE_ROLES = "ROLES";
+
+ public static final String NODE_ROLE_TYPES = "ROLE_TYPES";
+
+ public static final String NODE_ROLE_QUERIES = "ROLE_QUERIES";
+
+ public static final String NODE_ATTRIBUTES = "ATTRIBUTES";
+
+ public static final String NODE_ROLE_PROPERTIES = "NODE_ROLE_PROPERTIES";
+
+ public static final String NODE_ROLE_TYPE_PROPERTIES =
"NODE_ROLE_TYPE_PROPERTIES";
+
+ public static final String NODE_ROLE_SEARCHES = "NODE_ROLE_SEARCHES";
+
+ public static final String NODE_ROLE_TYPE_SEARCHES =
"NODE_ROLE_TYPE_SEARCHES";
+
+ public static final String NODE_RELATIONSHIP_SEARCHES =
"NODE_ROLE_TYPE_SEARCHES";
+
+ private Fqn getNamespacedFqn(String ns)
+ {
+ return Fqn.fromElements("NODE_MAIN_ROOT", ns);
+ }
+
+ private Fqn getFqn(String ns, String node, Object o)
+ {
+ return Fqn.fromElements(getNamespacedFqn(ns), node, o);
+ }
+
+ private Fqn getFqn(String ns, String node)
+ {
+ return Fqn.fromElements(getNamespacedFqn(ns), node);
+ }
+
+ public void initialize(Map<String, String> properties)
+ {
+ CacheFactory factory = new DefaultCacheFactory();
+
+ String config = properties.get(CONFIG_FILE_OPTION);
+
+ if (config == null)
+ {
+ throw new IllegalArgumentException("Cannot find '" +
CONFIG_FILE_OPTION + "' in passed properties. Failed to initialize" +
+ "cache provider.");
+ }
+
+ this.cache = factory.createCache(config);
+
+ this.cache.create();
+ this.cache.start();
+
+ }
+
+ Cache getCache()
+ {
+ return cache;
+ }
+
+
+ public void invalidate(String ns)
+ {
+ cache.getRoot().removeChild(getNamespacedFqn(ns));
+ }
+
+ public String getNamespace(String realmId)
+ {
+ return realmId;
+ }
+
+ public String getNamespace(String realmId, String sessionId)
+ {
+ return realmId + "/" + sessionId;
+ }
+
+ public void putUser(String ns, User user)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS, user.getId());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+
+ ioNode.put(NODE_OBJECT_KEY, user);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User stored in cache: " + user.getId());
+ }
+ }
+
+ public User getUser(String ns, String id)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS, id);
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ User user = (User)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User found in cache: id=" +
user.getId());
+ }
+
+ return user;
+ }
+
+ return null;
+ }
+
+ public void removeUser(String ns, String id)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS, id);
+
+ getCache().getRoot().removeChild(nodeFqn);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User removed from cache: id= " + id);
+ }
+ }
+
+ public void putUsers(String ns, IdentitySearchCriteria criteria,
Collection<User> users)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS_CRITERIA, criteria.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableCollection(users));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User criteria search stored in cache:
users.size()=" + users.size() +
+ "; criteria.hash()=" + criteria.hashCode());
+ }
+ }
+
+ public Collection<User> getUsers(String ns, IdentitySearchCriteria criteria)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS_CRITERIA, criteria.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Collection<User> users =
(Collection<User>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User criteria search found in cache:
users.size()=" + users.size() +
+ "; criteria.hash()=" + criteria.hashCode());
+ }
+
+ return users;
+ }
+
+ return null;
+ }
+
+ public void invalidateUsers(String ns)
+ {
+ getCache().getRoot().removeChild(Fqn.fromElements(getNamespacedFqn(ns),
NODE_USERS));
+ getCache().getRoot().removeChild(Fqn.fromElements(getNamespacedFqn(ns),
NODE_USERS_COUNT));
+ getCache().getRoot().removeChild(Fqn.fromElements(getNamespacedFqn(ns),
NODE_USERS_CRITERIA));
+ getCache().getRoot().removeChild(Fqn.fromElements(getNamespacedFqn(ns),
NODE_USERS_QUERIES));
+ }
+
+ public void putUserCount(String ns, int count)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS_COUNT);
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, count);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Users count stored in cache: " + count);
+ }
+ }
+
+ public int getUserCount(String ns)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS_COUNT);
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ int count = -1;
+ Integer i = (Integer)node.get(NODE_OBJECT_KEY);
+ if (i != null)
+ {
+ count = i.intValue();
+ }
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User count found in cache: " +
count);
+ }
+
+ return count;
+ }
+
+ return -1;
+ }
+
+ public void invalidateUserCount(String ns)
+ {
+ getCache().getRoot().removeChild(Fqn.fromElements(getNamespacedFqn(ns),
NODE_USERS_COUNT));
+ }
+
+ public void putGroup(String ns, Group group)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS, group.getId());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, group);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group stored in cache: " +
group.getId());
+ }
+ }
+
+ public Group getGroup(String ns, String groupType, String groupName)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS, GroupId.parseId(groupName, groupType));
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Group group = (Group)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group found in cache: id=" +
group.getId());
+ }
+
+ return group;
+ }
+
+ return null;
+ }
+
+ public void removeGroup(String ns, String groupType, String groupName)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS, GroupId.parseId(groupName, groupType));
+
+ getCache().getRoot().removeChild(nodeFqn);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group removed from cache: id= " +
GroupId.parseId(groupName, groupType));
+ }
+ }
+
+ public void putGroups(String ns, IdentitySearchCriteria criteria,
Collection<Group> groups)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS_CRITERIA, criteria.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableCollection(groups));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group criteria search stored in cache:
groups.size()=" + groups.size() +
+ "; criteria.hash()=" + criteria.hashCode());
+ }
+ }
+
+ public Collection<Group> getGroups(String ns, IdentitySearchCriteria criteria)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS_CRITERIA, criteria.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Collection<Group> groups =
(Collection<Group>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group criteria search found in cache:
groups.size()=" + groups.size() +
+ "; criteria.hash()=" + criteria.hashCode());
+ }
+
+ return groups;
+ }
+
+ return null;
+ }
+
+ public void invalidateGroups(String ns)
+ {
+ getCache().getRoot().removeChild(Fqn.fromElements(getNamespacedFqn(ns),
NODE_GROUPS));
+ getCache().getRoot().removeChild(Fqn.fromElements(getNamespacedFqn(ns),
NODE_GROUPS_COUNT));
+ getCache().getRoot().removeChild(Fqn.fromElements(getNamespacedFqn(ns),
NODE_GROUPS_CRITERIA));
+ getCache().getRoot().removeChild(Fqn.fromElements(getNamespacedFqn(ns),
NODE_GROUPS_QUERIES));
+ }
+
+ public void putGroupCount(String ns, String groupType, int count)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS_COUNT, groupType);
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, count);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group count stored in cache: type=" +
groupType + "; count=" + count);
+ }
+ }
+
+ public int getGroupCount(String ns, String groupType)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS_COUNT, groupType);
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ int count = -1;
+ Integer i = (Integer)node.get(NODE_OBJECT_KEY);
+ if (i != null)
+ {
+ count = i.intValue();
+ }
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group count found in cache:
groupType=" + groupType + "; count=" + count);
+ }
+
+ return count;
+ }
+
+ return -1;
+ }
+
+ public void invalidateGroupCount(String ns, String groupType)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_GROUPS_COUNT, groupType));
+ }
+
+ public void putRole(String ns, Role role)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLES, role.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+
+ ioNode.put(NODE_OBJECT_KEY, role);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Role stored in cache: " + role);
+ }
+ }
+
+ public Role getRole(String ns, Role role)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLES, role.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Role result = (Role)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Role found in cache: id=" + result);
+ }
+
+ return result;
+ }
+
+ return null;
+ }
+
+ public void removeRole(String ns, Role role)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_ROLES, role.hashCode()));
+ }
+
+ public void putRoleType(String ns, RoleType role)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_TYPES, role.getName());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+
+ ioNode.put(NODE_OBJECT_KEY, role);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "RoleType stored in cache: name=" +
role.getName());
+ }
+ }
+
+ public RoleType getRoleType(String ns, RoleType role)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_TYPES, role.getName());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ RoleType result = (RoleType)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "RoleType found in cache: name=" +
role.getName());
+ }
+
+ return result;
+ }
+
+ return null;
+ }
+
+ public void removeRoleType(String ns, RoleType roleType)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_ROLE_TYPES, roleType.getName()));
+ }
+
+ public void putAttributes(String ns, String id, Map<String, Attribute>
attributes)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ATTRIBUTES, id);
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableMap(attributes));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Attributes stored in cache: id=" + id +
"; attributes.size()=" + attributes.size());
+ }
+ }
+
+ public Map<String, Attribute> getAttributes(String ns, String id)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ATTRIBUTES, id);
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Map<String, Attribute> attributes = (Map<String,
Attribute>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Attributes search found in cache:
attributes.size()=" + attributes.size() +
+ "; id=" + id);
+ }
+
+ return attributes;
+ }
+
+ return null;
+ }
+
+ public void invalidateAttributes(String ns, String id)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_ATTRIBUTES, id));
+ }
+
+ public void invalidateAttributes(String ns)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_ATTRIBUTES));
+ }
+
+ public void putProperties(String ns, Role role, Map<String, String> properties)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_PROPERTIES, role.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableMap(properties));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Role properties stored in cache: role=" +
role + "; properties.size()=" + properties.size());
+ }
+ }
+
+ public Map<String, String> getProperties(String ns, Role role)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_PROPERTIES, role.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Map<String, String> props = (Map<String,
String>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Role properties found in cache:
properties.size()=" + props.size() +
+ "; role=" + role);
+ }
+
+ return props;
+ }
+
+ return null;
+ }
+
+ public void invalidateRoleProperties(String ns, Role role)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_ROLE_PROPERTIES, role.hashCode()));
+ }
+
+ public void invalidateRoleProperties(String ns)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_ROLE_PROPERTIES));
+ }
+
+ public void putProperties(String ns, RoleType roleType, Map<String, String>
properties)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_TYPE_PROPERTIES, roleType.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableMap(properties));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "RoleType properties stored in cache:
roleType=" + roleType + "; properties.size()=" + properties.size());
+ }
+ }
+
+ public Map<String, String> getProperties(String ns, RoleType roleType)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_TYPE_PROPERTIES, roleType.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Map<String, String> props = (Map<String,
String>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "RoleType properties found in cache:
properties.size()=" + props.size() +
+ "; roleType=" + roleType);
+ }
+
+ return props;
+ }
+
+ return null;
+ }
+
+ public void invalidateRoleTypeProperties(String ns, RoleType roleType)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_ROLE_PROPERTIES,
roleType.hashCode()));
+ }
+
+ public void invalidateRoleTypeProperties(String ns)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_ROLE_PROPERTIES));
+ }
+
+ public void invalidateAllSearches(String ns)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_USERS_SEARCHES));
+ cache.getRoot().removeChild(getFqn(ns, NODE_GROUPS_SEARCHES));
+ cache.getRoot().removeChild(getFqn(ns, NODE_RELATIONSHIP_SEARCHES));
+ cache.getRoot().removeChild(getFqn(ns, NODE_ROLE_SEARCHES));
+ cache.getRoot().removeChild(getFqn(ns, NODE_ROLE_TYPE_SEARCHES));
+ }
+
+ public void putUserSearch(String ns, UserSearch search, Collection<User>
results)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS_SEARCHES, search.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableCollection(results));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User search stored in cache:
results.size()=" + results.size());
+ }
+ }
+
+ public Collection<User> getUserSearch(String ns, UserSearch search)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS_SEARCHES, search.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Collection<User> props =
(Collection<User>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User search found in cache:
properties.size()=" + props.size());
+ }
+
+ return props;
+ }
+
+ return null;
+ }
+
+ public void putGroupSearch(String ns, GroupSearch search, Collection<Group>
results)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS_SEARCHES, search.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableCollection(results));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group search stored in cache:
results.size()=" + results.size());
+ }
+ }
+
+ public Collection<Group> getGroupSearch(String ns, GroupSearch search)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS_SEARCHES, search.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Collection<Group> results =
(Collection<Group>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group search found in cache:
results.size()=" + results.size());
+ }
+
+ return results;
+ }
+
+ return null;
+ }
+
+ public void putRelationshipSearch(String ns, RelationshipSearch search, Boolean
result)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_RELATIONSHIP_SEARCHES, search.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, result);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Relationship search stored in cache:
result=" + result);
+ }
+ }
+
+ public Boolean getRelationshipSearch(String ns, RelationshipSearch search)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_RELATIONSHIP_SEARCHES, search.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Boolean result = (Boolean)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Relationship search found in cache:
properties.size()=" + result);
+ }
+
+ return result;
+ }
+
+ return null;
+ }
+
+ public void putRoleSearch(String ns, RoleSearch search, Collection<Role>
results)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_SEARCHES, search.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY,Collections.unmodifiableCollection(results));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Role search stored in cache:
results.size()=" + results.size());
+ }
+ }
+
+ public Collection<Role> getRoleSearch(String ns, RoleSearch search)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_SEARCHES, search.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Collection<Role> results =
(Collection<Role>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Role search found in cache:
results.size()=" + results.size());
+ }
+
+ return results;
+ }
+
+ return null;
+ }
+
+ public void putRoleTypeSearch(String ns, RoleTypeSearch search,
Collection<RoleType> results)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_TYPE_SEARCHES, search.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableCollection(results));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "RoleType search stored in cache:
results.size()=" + results.size());
+ }
+ }
+
+ public Collection<RoleType> getRoleTypeSearch(String ns, RoleTypeSearch search)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_TYPE_SEARCHES, search.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Collection<RoleType> results =
(Collection<RoleType>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "RoleType search found in cache:
results.size()=" + results.size());
+ }
+
+ return results;
+ }
+
+ return null;
+ }
+
+ public void invalidateAllQueries(String ns)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_USERS_QUERIES));
+ cache.getRoot().removeChild(getFqn(ns, NODE_GROUPS_QUERIES));
+ cache.getRoot().removeChild(getFqn(ns, NODE_ROLE_QUERIES));
+
+ }
+
+ public void putUserQuery(String ns, UserQuery q, Collection<User> results)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS_QUERIES, q.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_QUERY_KEY, results);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User query stored in cache:
q.hashCode()=" + q.hashCode() + "; results.size()=" + results.size());
+ }
+ }
+
+ public void putUserQueryUnique(String ns, UserQuery q, User user)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS_QUERIES, q.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_QUERY_UNIQUE_KEY, user);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User query stored in cache:
q.hashCode()=" + q.hashCode() + "; user=" + user);
+ }
+ }
+
+ public Collection<User> getUserQuery(String ns, UserQuery q)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS_QUERIES, q.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Collection<User> users =
(Collection<User>)node.get(NODE_QUERY_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User query found in cache:
users.size()=" + users.size() +
+ "; query.hash()=" + q.hashCode());
+ }
+
+ return users;
+ }
+
+ return null;
+ }
+
+ public User getUserQueryUnique(String ns, UserQuery q)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_USERS_QUERIES, q.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ User users = (User)node.get(NODE_QUERY_UNIQUE_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "User query found in cache: user=" +
users);
+ }
+
+ return users;
+ }
+
+ return null;
+ }
+
+ public void invalidateUserQueries(String ns)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_USERS_QUERIES));
+ }
+
+ public void putGroupQuery(String ns, GroupQuery q, Collection<Group> results)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS_QUERIES, q.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_QUERY_KEY, Collections.unmodifiableCollection(results));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group query stored in cache:
q.hashCode()=" + q.hashCode() + "; results.size()=" + results.size());
+ }
+ }
+
+ public void putGroupQueryUnique(String ns, GroupQuery q, Group group)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS_QUERIES, q.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_QUERY_UNIQUE_KEY, group);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group query stored in cache:
q.hashCode()=" + q.hashCode() + "; group=" + group);
+ }
+ }
+
+ public Collection<Group> getGroupQuery(String ns, GroupQuery q)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS_QUERIES, q.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Collection<Group> groups =
(Collection<Group>)node.get(NODE_QUERY_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group query found in cache:
groups.size()=" + groups.size() +
+ "; query.hash()=" + q.hashCode());
+ }
+
+ return groups;
+ }
+
+ return null;
+ }
+
+ public Group getGroupQueryUnique(String ns, GroupQuery q)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_GROUPS_QUERIES, q.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Group group = (Group)node.get(NODE_QUERY_UNIQUE_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Group query found in cache: group=" +
group);
+ }
+
+ return group;
+ }
+
+ return null;
+ }
+
+ public void invalidateGroupQueries(String ns)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_GROUPS_QUERIES));
+ }
+
+ public void putRoleQuery(String ns, RoleQuery q, Collection<Role> results)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_QUERIES, q.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_QUERY_KEY, results);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Role query stored in cache:
q.hashCode()=" + q.hashCode() + "; results.size()=" + results.size());
+ }
+ }
+ public void putRoleQueryUnique(String ns, RoleQuery q, Role role)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_QUERIES, q.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_QUERY_UNIQUE_KEY, role);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Role query stored in cache:
q.hashCode()=" + q.hashCode() + "; role=" + role);
+ }
+ }
+
+ public Collection<Role> getRoleQuery(String ns, RoleQuery q)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_QUERIES, q.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Collection<Role> roles =
(Collection<Role>)node.get(NODE_QUERY_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Role query found in cache:
users.size()=" + roles.size() +
+ "; query.hash()=" + q.hashCode());
+ }
+
+ return roles;
+ }
+
+ return null;
+ }
+
+ public Role getRoleQueryUnique(String ns, RoleQuery q)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_ROLE_QUERIES, q.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Role role = (Role)node.get(NODE_QUERY_UNIQUE_KEY);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Role query found in cache: role=" +
role);
+ }
+
+ return role;
+ }
+
+ return null;
+ }
+
+ public void invalidateRoleQueries(String ns)
+ {
+ cache.getRoot().removeChild(getFqn(ns, NODE_ROLE_QUERIES));
+ }
+}
Added:
idm/trunk/idm-cache/src/test/java/org/jboss/identity/idm/cache/APICacheProviderTestCase.java
===================================================================
---
idm/trunk/idm-cache/src/test/java/org/jboss/identity/idm/cache/APICacheProviderTestCase.java
(rev 0)
+++
idm/trunk/idm-cache/src/test/java/org/jboss/identity/idm/cache/APICacheProviderTestCase.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,73 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.cache;
+
+import junit.framework.TestCase;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import org.jboss.identity.idm.impl.cache.JBossCacheAPICacheProviderImpl;
+import org.jboss.identity.idm.impl.api.model.SimpleUser;
+import org.jboss.identity.idm.api.User;
+
+
+public class APICacheProviderTestCase extends TestCase
+{
+
+ public void testSimple() throws Exception
+ {
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(JBossCacheAPICacheProviderImpl.CONFIG_FILE_OPTION,
"jboss-cache.xml");
+ APICacheProvider cache = new JBossCacheAPICacheProviderImpl();
+ cache.initialize(props);
+
+ String ns = "toto";
+
+ User u1 = new SimpleUser("u1");
+ User u2 = new SimpleUser("u2");
+ User u3 = new SimpleUser("u3");
+
+ assertNull(cache.getUser(ns, "u1"));
+ assertNull(cache.getUser(ns, "u2"));
+ assertNull(cache.getUser(ns, "u3"));
+
+ cache.putUser(ns, u1);
+ cache.putUser(ns, u3);
+
+ assertNotNull(cache.getUser(ns, "u1"));
+ assertNull(cache.getUser(ns, "u2"));
+ assertNotNull(cache.getUser(ns, "u3"));
+
+ cache.invalidateUsers(ns);
+
+ assertNull(cache.getUser(ns, "u1"));
+ assertNull(cache.getUser(ns, "u2"));
+ assertNull(cache.getUser(ns, "u3"));
+
+
+
+
+ }
+
+}
Added: idm/trunk/idm-cache/src/test/resources/jboss-cache.xml
===================================================================
--- idm/trunk/idm-cache/src/test/resources/jboss-cache.xml (rev
0)
+++ idm/trunk/idm-cache/src/test/resources/jboss-cache.xml 2009-11-04 22:30:01 UTC (rev
905)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
+
+</jbosscache>
\ No newline at end of file
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/IdentitySearchCriteriaImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/IdentitySearchCriteriaImpl.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/IdentitySearchCriteriaImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -43,12 +43,13 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
+import java.io.Serializable;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
-public class IdentitySearchCriteriaImpl implements IdentitySearchCriteria,
IdentityObjectSearchCriteria
+public class IdentitySearchCriteriaImpl implements IdentitySearchCriteria,
IdentityObjectSearchCriteria, Serializable
{
private boolean sorted = false;
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -77,7 +77,7 @@
IdentitySession newSession =
new IdentitySessionImpl(sessionConfigCtx.getRealmName(),
- sessionConfigCtx.getRepository(), sessionConfigCtx.getTypeMapper());
+ sessionConfigCtx.getRepository(), sessionConfigCtx.getTypeMapper(),
sessionConfigCtx.getApiCacheProvider());
realmMap.put(realmName, newSession);
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -84,6 +84,14 @@
return true;
}
+ public static String parseId(String name, String type)
+ {
+ GroupId gid = new GroupId(name, type);
+ String id = gid.getId();
+ gid = null;
+ return id;
+ }
+
public String getName()
{
return name;
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/query/AbstractQuery.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/query/AbstractQuery.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/query/AbstractQuery.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -41,12 +41,13 @@
import java.util.List;
import java.util.LinkedList;
+import java.io.Serializable;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
-public abstract class AbstractQuery implements Query
+public abstract class AbstractQuery implements Query, Serializable
{
protected IdentitySearchCriteriaImpl searchCriteria = new
IdentitySearchCriteriaImpl();
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/query/UserQueryImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/query/UserQueryImpl.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/query/UserQueryImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -33,7 +33,7 @@
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
*/
-public class UserQueryImpl extends AbstractQuery implements UserQuery
+public class UserQueryImpl extends AbstractQuery implements UserQuery
{
public final String userId;
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -68,6 +68,7 @@
import org.jboss.identity.idm.impl.api.query.UserQueryBuilderImpl;
import org.jboss.identity.idm.impl.api.query.GroupQueryBuilderImpl;
import org.jboss.identity.idm.impl.api.query.RoleQueryBuilderImpl;
+import org.jboss.identity.idm.cache.APICacheProvider;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -98,6 +99,10 @@
private final Collection<EventListener> listeners = new
LinkedList<EventListener>();
+ private final APICacheProvider apiCacheProvider;
+
+ private final String cacheNS;
+
public IdentitySessionContext getSessionContext()
{
return sessionContext;
@@ -105,7 +110,8 @@
public IdentitySessionImpl(String realmName,
IdentityStoreRepository repository,
- IdentityObjectTypeMapper typeMapper) throws
IdentityException
+ IdentityObjectTypeMapper typeMapper,
+ APICacheProvider apiCacheProvider) throws
IdentityException
{
this.realmName = realmName;
@@ -129,7 +135,17 @@
this.userQueryExecutor = new UserQueryExecutorImpl(this);
this.groupQueryExecutor = new GroupQueryExecutorImpl(this);
this.roleQueryExecutor = new RoleQueryExecutorImpl(this);
+
+ this.apiCacheProvider = apiCacheProvider;
+ if (apiCacheProvider != null)
+ {
+ cacheNS = apiCacheProvider.getNamespace(realmName);
+ }
+ else
+ {
+ cacheNS = null;
+ }
}
@@ -224,47 +240,192 @@
public Collection<User> execute(UserQuery userQuery) throws QueryException
{
- return userQueryExecutor.execute((UserQueryImpl)userQuery);
+ if (apiCacheProvider != null)
+ {
+ Collection<User> results = apiCacheProvider.getUserQuery(cacheNS,
userQuery);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
+ Collection<User> results =
userQueryExecutor.execute((UserQueryImpl)userQuery);
+
+ if (apiCacheProvider != null)
+ {
+ apiCacheProvider.putUserQuery(cacheNS, userQuery, results);
+ }
+
+ return results;
}
public User uniqueResult(UserQuery userQuery) throws QueryException
{
- return userQueryExecutor.uniqueResult((UserQueryImpl)userQuery);
+ if (apiCacheProvider != null)
+ {
+ User result = apiCacheProvider.getUserQueryUnique(cacheNS, userQuery);
+ if (result != null)
+ {
+ return result;
+ }
+ }
+
+ User result = userQueryExecutor.uniqueResult((UserQueryImpl)userQuery);
+
+ if (apiCacheProvider != null)
+ {
+ apiCacheProvider.putUserQueryUnique(cacheNS, userQuery, result);
+ }
+
+ return result;
}
public List<User> list(UserQuery userQuery) throws QueryException
{
- return userQueryExecutor.list((UserQueryImpl)userQuery);
+
+ if (apiCacheProvider != null)
+ {
+ Collection<User> results = apiCacheProvider.getUserQuery(cacheNS,
userQuery);
+ if (results != null && results instanceof List)
+ {
+ return (List<User>)results;
+ }
+ }
+
+ List<User> results = userQueryExecutor.list((UserQueryImpl)userQuery);
+
+ if (apiCacheProvider != null)
+ {
+ apiCacheProvider.putUserQuery(cacheNS, userQuery, results);
+ }
+
+ return results;
}
public Collection<Group> execute(GroupQuery groupQuery) throws QueryException
{
- return groupQueryExecutor.execute((GroupQueryImpl)groupQuery);
+ if (apiCacheProvider != null)
+ {
+ Collection<Group> results = apiCacheProvider.getGroupQuery(cacheNS,
groupQuery);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
+ Collection<Group> results =
groupQueryExecutor.execute((GroupQueryImpl)groupQuery);
+
+ if (apiCacheProvider != null)
+ {
+ apiCacheProvider.putGroupQuery(cacheNS, groupQuery, results);
+ }
+
+ return results;
}
public Group uniqueResult(GroupQuery groupQuery) throws QueryException
{
- return groupQueryExecutor.uniqueResult((GroupQueryImpl)groupQuery);
+ if (apiCacheProvider != null)
+ {
+ Group result = apiCacheProvider.getGroupQueryUnique(cacheNS, groupQuery);
+ if (result != null)
+ {
+ return result;
+ }
+ }
+
+ Group group = groupQueryExecutor.uniqueResult((GroupQueryImpl)groupQuery);
+
+ if (apiCacheProvider != null)
+ {
+ apiCacheProvider.putGroupQueryUnique(cacheNS, groupQuery, group);
+ }
+
+ return group;
}
public List<Group> list(GroupQuery groupQuery) throws QueryException
{
- return groupQueryExecutor.list((GroupQueryImpl)groupQuery);
+ if (apiCacheProvider != null)
+ {
+ Collection<Group> results = apiCacheProvider.getGroupQuery(cacheNS,
groupQuery);
+ if (results != null && results instanceof List)
+ {
+ return (List<Group>)results;
+ }
+ }
+
+ List<Group> results = groupQueryExecutor.list((GroupQueryImpl)groupQuery);
+
+ if (apiCacheProvider != null)
+ {
+ apiCacheProvider.putGroupQuery(cacheNS, groupQuery, results);
+ }
+
+ return results;
}
public Collection<Role> execute(RoleQuery roleQuery) throws QueryException
{
- return roleQueryExecutor.execute((RoleQueryImpl)roleQuery);
+ if (apiCacheProvider != null)
+ {
+ Collection<Role> results = apiCacheProvider.getRoleQuery(cacheNS,
roleQuery);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
+ Collection<Role> results =
roleQueryExecutor.execute((RoleQueryImpl)roleQuery);
+
+ if (apiCacheProvider != null)
+ {
+ apiCacheProvider.putRoleQuery(cacheNS, roleQuery, results);
+ }
+
+ return results;
}
public Role uniqueResult(RoleQuery roleQuery) throws QueryException
{
- return roleQueryExecutor.uniqueResult((RoleQueryImpl)roleQuery);
+ if (apiCacheProvider != null)
+ {
+ Role result = apiCacheProvider.getRoleQueryUnique(cacheNS, roleQuery);
+ if (result != null)
+ {
+ return result;
+ }
+ }
+
+ Role result = roleQueryExecutor.uniqueResult((RoleQueryImpl)roleQuery);
+
+ if (apiCacheProvider != null)
+ {
+ apiCacheProvider.putRoleQueryUnique(cacheNS, roleQuery, result);
+ }
+
+ return result;
}
public List<Role> list(RoleQuery roleQuery) throws QueryException
{
- return roleQueryExecutor.list((RoleQueryImpl)roleQuery);
+ if (apiCacheProvider != null)
+ {
+ Collection<Role> results = apiCacheProvider.getRoleQuery(cacheNS,
roleQuery);
+ if (results != null && results instanceof List)
+ {
+ return (List<Role>)results;
+ }
+ }
+
+ List<Role> results = roleQueryExecutor.list((RoleQueryImpl)roleQuery);
+
+ if (apiCacheProvider != null)
+ {
+ apiCacheProvider.putRoleQuery(cacheNS, roleQuery, results);
+ }
+
+ return results;
}
public void registerListener(EventListener listener)
@@ -276,4 +437,14 @@
{
return listeners;
}
+
+ public APICacheProvider getApiCacheProvider()
+ {
+ return apiCacheProvider;
+ }
+
+ public String getCacheNS()
+ {
+ return cacheNS;
+ }
}
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -38,6 +38,7 @@
import org.jboss.identity.idm.impl.api.model.GroupId;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
import org.jboss.identity.idm.impl.api.IdentitySearchCriteriaImpl;
+import org.jboss.identity.idm.cache.APICacheProvider;
import java.io.Serializable;
import java.util.Collection;
@@ -52,9 +53,15 @@
{
protected final IdentitySessionImpl identitySession;
+ protected final APICacheProvider cache;
+
+ protected final String cacheNS;
+
protected AbstractManager(IdentitySessionImpl session)
{
this.identitySession = session;
+ this.cache = session.getApiCacheProvider();
+ this.cacheNS = session.getCacheNS();
}
public IdentitySession getIdentitySession()
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -154,6 +154,15 @@
{
checkNotNullArgument(identityType, "IdentityType");
+ if (cache != null)
+ {
+ Map<String, Attribute> attributes = cache.getAttributes(cacheNS,
identityType.getId());
+ if (attributes != null)
+ {
+ return attributes;
+ }
+ }
+
Map<String, IdentityObjectAttribute> map =
getRepository().getAttributes(getInvocationContext(),
createIdentityObject(identityType));
Map<String, Attribute> newMap = new HashMap<String, Attribute>();
@@ -162,6 +171,11 @@
{
newMap.put(entry.getKey(), convertAttribute(entry.getValue()));
}
+
+ if (cache != null)
+ {
+ cache.putAttributes(cacheNS, identityType.getId(), newMap);
+ }
return newMap;
}
@@ -185,6 +199,18 @@
getRepository().updateAttributes(getInvocationContext(),
createIdentityObject(identity), convertAttributes(attributes));
+ if (cache != null)
+ {
+ Map<String, Attribute> attrMap = new HashMap<String, Attribute>();
+
+ for (Attribute attribute : attributes)
+ {
+ attrMap.put(attribute.getName(), attribute);
+ }
+
+ cache.putAttributes(cacheNS, identity.getId(), attrMap);
+ }
+
postAttributesUpdate(identity, attributes);
}
@@ -289,6 +315,13 @@
getRepository().addAttributes(getInvocationContext(),
createIdentityObject(identityType), convertAttributes(attributes));
+ if (cache != null)
+ {
+ // Grab the new profile and persist in cache
+ cache.invalidateAttributes(cacheNS, identityType.getId());
+ cache.putAttributes(cacheNS, identityType.getId(),
this.getAttributes(identityType));
+ }
+
postAttributesAdd(identityType, attributes);
}
@@ -303,6 +336,13 @@
getRepository().removeAttributes(getInvocationContext(),
createIdentityObject(identityType), attributeNames);
+ if (cache != null)
+ {
+ // Grab the new profile and persist in cache
+ cache.invalidateAttributes(cacheNS, identityType.getId());
+ cache.putAttributes(cacheNS, identityType.getId(),
this.getAttributes(identityType));
+ }
+
postAttributesRemove(identityType, attributeNames);
}
@@ -403,6 +443,8 @@
checkNotNullArgument(attributeName, "Attribute name");
checkNotNullArgument(value, "Attribute value");
+ //TODO: cache
+
IdentityObject io =
getRepository().findIdentityObjectByUniqueAttribute(getInvocationContext(),
getUserObjectType(), new SimpleAttribute(attributeName, value));
if (io == null)
@@ -419,6 +461,8 @@
checkNotNullArgument(attributeName, "Attribute name");
checkNotNullArgument(value, "Attribute value");
+ //TODO: cache
+
IdentityObject io =
getRepository().findIdentityObjectByUniqueAttribute(getInvocationContext(),
getIdentityObjectType(groupType),
new SimpleAttribute(attributeName, value));
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -34,6 +34,7 @@
import org.jboss.identity.idm.impl.api.model.GroupId;
import org.jboss.identity.idm.impl.api.model.SimpleUser;
import org.jboss.identity.idm.impl.api.model.SimpleGroup;
+import org.jboss.identity.idm.impl.cache.GroupSearchImpl;
import java.util.Collection;
import java.util.List;
@@ -126,9 +127,20 @@
IdentityObject identityObject =
getRepository().createIdentityObject(getInvocationContext(), identityName, iot);
+ User user = createUser(identityObject);
+
+ //Cache
+ if (cache != null)
+ {
+ //TODO: maybe invalidate only part
+ cache.invalidate(cacheNS);
+ cache.putUser(cacheNS, user);
+ }
+
postCreate(new SimpleUser(identityName));
- return createUser(identityObject);
+
+ return user;
}
public Group createGroup(String groupName, String groupType) throws IdentityException
@@ -144,9 +156,18 @@
IdentityObject identityObject =
getRepository().createIdentityObject(getInvocationContext(), groupName, iot);
+ Group group = createGroup(identityObject);
+
+ if (cache != null)
+ {
+ //TODO: maybe invalidate only part
+ cache.invalidate(cacheNS);
+ cache.putGroup(cacheNS, group);
+ }
+
postCreate(new SimpleGroup(groupName, groupType));
- return createGroup(identityObject);
+ return group;
}
public String createGroupId(String groupName, String groupType)
@@ -167,7 +188,15 @@
getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObject(user));
+ if (cache != null)
+ {
+ //TODO: maybe invalidate only part
+ cache.invalidate(cacheNS);
+ }
+
postRemove(user);
+
+
}
public void removeUser(String userName, boolean force) throws IdentityException
@@ -178,6 +207,12 @@
getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObjectForUserName(userName));
+ if (cache != null)
+ {
+ //TODO: maybe invalidate only part
+ cache.invalidate(cacheNS);
+ }
+
postRemove(new SimpleUser(userName));
}
@@ -192,6 +227,11 @@
getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObject(group));
+ if (cache != null)
+ {
+ cache.invalidate(cacheNS);
+ }
+
postRemove(group);
}
@@ -205,35 +245,88 @@
getRepository().removeIdentityObject(getInvocationContext(),
createIdentityObjectForGroupId(groupId));
+ if (cache != null)
+ {
+ cache.invalidate(cacheNS);
+ }
+
postRemove(new SimpleGroup(new GroupId(groupId)));
}
public int getUserCount() throws IdentityException
{
+ if (cache != null)
+ {
+ int count = cache.getUserCount(cacheNS);
+ if (count != -1)
+ {
+ return count;
+ }
+ }
+
IdentityObjectType iot = getUserObjectType();
- return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
+ int count = getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
+
+ if (cache != null)
+ {
+ cache.putUserCount(cacheNS, count);
+ }
+
+ return count;
}
public int getGroupTypeCount(String groupType) throws IdentityException
{
checkNotNullArgument(groupType, "Group type");
+ if (cache != null)
+ {
+ int count = cache.getGroupCount(cacheNS, groupType);
+ if (count != -1)
+ {
+ return count;
+ }
+ }
+
IdentityObjectType iot = getIdentityObjectType(groupType);
- return getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
+ int count = getRepository().getIdentityObjectsCount(getInvocationContext(), iot);
+
+ if (cache != null)
+ {
+ cache.putGroupCount(cacheNS, groupType, count);
+ }
+
+ return count;
}
public User findUser(String name) throws IdentityException
{
checkNotNullArgument(name, "User name");
+ if (cache != null)
+ {
+ User user = cache.getUser(cacheNS, name);
+ if (user != null)
+ {
+ return user;
+ }
+ }
+
IdentityObject io = getRepository().findIdentityObject(getInvocationContext(),
name, getUserObjectType());
if (io != null)
{
- return createUser(io);
+ User user = createUser(io);
+
+ if (cache != null)
+ {
+ cache.putUser(cacheNS, user);
+ }
+
+ return user;
}
return null;
}
@@ -241,7 +334,16 @@
public Collection<User> findUser(IdentitySearchCriteria criteria) throws
IdentityException
{
+ if (cache != null)
+ {
+ Collection<User> users = cache.getUsers(cacheNS, criteria);
+ if (users != null)
+ {
+ return users;
+ }
+ }
+
Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), getUserObjectType(),
convertSearchControls(criteria));
List<User> identities = new LinkedList<User>();
@@ -251,6 +353,12 @@
identities.add(createUser(identityObject));
}
+
+ if (cache != null)
+ {
+ cache.putUsers(cacheNS, criteria, identities);
+ }
+
return identities;
}
@@ -259,11 +367,27 @@
checkNotNullArgument(name, "Group name");
checkNotNullArgument(groupType, "Group type");
+ if (cache != null)
+ {
+ Group group = cache.getGroup(cacheNS, groupType, name);
+ if (group != null)
+ {
+ return group;
+ }
+ }
+
IdentityObject io = getRepository().findIdentityObject(getInvocationContext(),
name, getIdentityObjectType(groupType));
if (io != null)
{
- return createGroup(io);
+ Group group = createGroup(io);
+
+ if (cache != null)
+ {
+ cache.putGroup(cacheNS, group);
+ }
+
+ return group;
}
return null;
}
@@ -288,6 +412,19 @@
{
checkNotNullArgument(groupType, "Group type");
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.setGroupType(groupType);
+ search.setSearchCriteria(criteria);
+
+ Collection<Group> results = cache.getGroupSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(),
getIdentityObjectType(groupType), convertSearchControls(criteria));
List<Group> groups = new LinkedList<Group>();
@@ -297,6 +434,16 @@
groups.add(createGroup(identityObject));
}
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.setGroupType(groupType);
+ search.setSearchCriteria(criteria);
+
+ cache.putGroupSearch(cacheNS, search, groups);
+
+ }
+
return groups;
}
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -42,6 +42,10 @@
import org.jboss.identity.idm.impl.api.model.SimpleGroup;
import org.jboss.identity.idm.impl.api.model.GroupId;
import org.jboss.identity.idm.impl.api.model.SimpleUser;
+import org.jboss.identity.idm.impl.cache.RelationshipSearchImpl;
+import org.jboss.identity.idm.impl.cache.GroupSearchImpl;
+import org.jboss.identity.idm.impl.cache.UserSearchImpl;
+import org.jboss.identity.idm.cache.RelationshipSearch;
import java.util.Collection;
import java.util.Iterator;
@@ -209,6 +213,12 @@
getRepository().createRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ }
+
postGroupAssociationCreate(parent, member);
}
@@ -227,6 +237,13 @@
getRepository().createRelationship(getInvocationContext(),
createIdentityObjectForGroupId(parentId), createIdentityObjectForGroupId(memberId),
MEMBER, null, true);
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ }
+
+
postGroupAssociationCreate(parent, member);
}
@@ -294,6 +311,13 @@
getRepository().createRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null, true);
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ }
+
+
postUserAssociationCreate(parent, member);
}
@@ -311,6 +335,13 @@
getRepository().createRelationship(getInvocationContext(),
createIdentityObjectForGroupId(parentId), createIdentityObjectForUserName(memberId),
MEMBER, null, true);
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ }
+
+
postUserAssociationCreate(parent, member);
}
@@ -353,6 +384,12 @@
getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null);
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ }
+
postGroupAssociationRemove(parent, member);
}
@@ -388,6 +425,13 @@
getRepository().removeRelationship(getInvocationContext(),
createIdentityObjectForGroupId(parent), createIdentityObjectForGroupId(member), MEMBER,
null);
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ }
+
+
postGroupAssociationRemove(parentGroup, memberGroup);
}
@@ -418,6 +462,13 @@
getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(parent), createIdentityObject(member), MEMBER, null);
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ }
+
+
postUserAssociationRemove(parent, member);
}
}
@@ -452,6 +503,13 @@
getRepository().removeRelationship(getInvocationContext(),
createIdentityObjectForGroupId(parent), createIdentityObjectForUserName(member), MEMBER,
null);
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ }
+
+
postUserAssociationRemove(parentGroup, memberUser);
}
@@ -473,7 +531,27 @@
checkNotNullArgument(parents, "parents");
checkNotNullArgument(members, "members");
+ if (cache != null)
+ {
+ RelationshipSearchImpl search = new RelationshipSearchImpl();
+ for (G parent : parents)
+ {
+ search.addParent(parent);
+ }
+ for (I member : members)
+ {
+ search.addMember(member);
+ }
+ Boolean result = cache.getRelationshipSearch(cacheNS, search);
+
+ if (result != null)
+ {
+ return result;
+ }
+ }
+
+
for (Iterator<G> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
IdentityType parent = parentsIterator.next();
@@ -486,11 +564,41 @@
if (relationships.size() == 0)
{
+ if (cache != null)
+ {
+ RelationshipSearchImpl search = new RelationshipSearchImpl();
+ for (G p : parents)
+ {
+ search.addParent(p);
+ }
+ for (I m : members)
+ {
+ search.addMember(m);
+ }
+ cache.putRelationshipSearch(cacheNS, search, false);
+
+ }
+
return false;
}
}
}
+ if (cache != null)
+ {
+ RelationshipSearchImpl search = new RelationshipSearchImpl();
+ for (G p : parents)
+ {
+ search.addParent(p);
+ }
+ for (I m : members)
+ {
+ search.addMember(m);
+ }
+ cache.putRelationshipSearch(cacheNS, search, true);
+
+ }
+
return true;
}
@@ -499,7 +607,26 @@
checkNotNullArgument(parents, "parents");
checkNotNullArgument(members, "members");
+ if (cache != null)
+ {
+ RelationshipSearchImpl search = new RelationshipSearchImpl();
+ for (String parent : parents)
+ {
+ search.addParent(parent);
+ }
+ for (String member : members)
+ {
+ search.addMember(member);
+ }
+ Boolean result = cache.getRelationshipSearch(cacheNS, search);
+
+ if (result != null)
+ {
+ return result;
+ }
+ }
+
for (Iterator<String> parentsIterator = parents.iterator();
parentsIterator.hasNext();)
{
String parent = parentsIterator.next();
@@ -512,10 +639,41 @@
if (relationships.size() == 0)
{
+ if (cache != null)
+ {
+ RelationshipSearchImpl search = new RelationshipSearchImpl();
+ for (String p : parents)
+ {
+ search.addParent(p);
+ }
+ for (String m : members)
+ {
+ search.addMember(m);
+ }
+ cache.putRelationshipSearch(cacheNS, search, false);
+
+ }
+
return false;
}
}
}
+
+ if (cache != null)
+ {
+ RelationshipSearchImpl search = new RelationshipSearchImpl();
+ for (String p : parents)
+ {
+ search.addParent(p);
+ }
+ for (String m : members)
+ {
+ search.addMember(m);
+ }
+ cache.putRelationshipSearch(cacheNS, search, true);
+
+ }
+
return true;
}
@@ -538,15 +696,38 @@
checkNotNullArgument(parent, "Parent Id");
checkNotNullArgument(member, "Member Id");
+ if (cache != null)
+ {
+ RelationshipSearchImpl search = new RelationshipSearchImpl();
+ search.addParent(parent);
+ search.addMember(member);
+ Boolean result = cache.getRelationshipSearch(cacheNS, search);
+
+ if (result != null)
+ {
+ return result;
+ }
+ }
+
Collection<IdentityObjectRelationship> relationships =
getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(parent),
createIdentityObject(member), MEMBER);
+ boolean result = true;
+
if (relationships.size() == 0)
{
- return false;
+ result = false;
}
- return true;
+ if (cache != null)
+ {
+ RelationshipSearchImpl search = new RelationshipSearchImpl();
+ search.addParent(parent);
+ search.addMember(member);
+ cache.putRelationshipSearch(cacheNS, search, result);
+ }
+
+ return result;
}
private Collection<Group> findAssociatedGroupsCascaded(Collection<Group>
previous, Group group, String groupType, boolean parent, IdentitySearchCriteria criteria)
throws IdentityException
@@ -575,8 +756,23 @@
{
checkNotNullArgument(group, "Group");
-// checkNotNullArgument(groupType, "Group type");
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addAssociatedGroupId(group.getId());
+ search.setGroupType(groupType);
+ search.setParent(parent);
+ search.setCascade(cascade);
+ search.setSearchCriteria(criteria);
+
+ Collection<Group> results = cache.getGroupSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
List<Group> identities = new LinkedList<Group>();
IdentityObjectType iot = groupType != null ? getIdentityObjectType(groupType) :
null;
@@ -602,20 +798,36 @@
throw new IdentityException("Failed to apply criteria", e);
}
- return identities;
+
}
+ else
+ {
- Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group),
MEMBER, parent, convertSearchControls(criteria));
+ Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group),
MEMBER, parent, convertSearchControls(criteria));
- for (IdentityObject io : ios)
- {
- if ((iot == null &&
!io.getIdentityType().getName().equals(getUserObjectType().getName())) ||
- (iot != null &&
io.getIdentityType().getName().equals(iot.getName())))
+ for (IdentityObject io : ios)
{
- identities.add(createGroup(io));
+ if ((iot == null &&
!io.getIdentityType().getName().equals(getUserObjectType().getName())) ||
+ (iot != null &&
io.getIdentityType().getName().equals(iot.getName())))
+ {
+ identities.add(createGroup(io));
+ }
}
}
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addAssociatedGroupId(group.getId());
+ search.setGroupType(groupType);
+ search.setParent(parent);
+ search.setCascade(cascade);
+ search.setSearchCriteria(criteria);
+
+ cache.putGroupSearch(cacheNS, search, identities);
+
+ }
+
return identities;
}
@@ -643,6 +855,20 @@
checkNotNullArgument(user, "User");
//checkNotNullArgument(groupType, "Group type");
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addAssociatedUserId(user.getId());
+ search.setGroupType(groupType);
+ search.setSearchCriteria(criteria);
+
+ Collection<Group> results = cache.getGroupSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
List<Group> identities = new LinkedList<Group>();
IdentityObjectType iot = groupType != null ? getIdentityObjectType(groupType) :
null;
@@ -657,6 +883,19 @@
}
}
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addAssociatedUserId(user.getId());
+ search.setGroupType(groupType);
+ search.setSearchCriteria(criteria);
+
+ cache.putGroupSearch(cacheNS, search, identities);
+
+ }
+
+
+
return identities;
}
@@ -682,6 +921,19 @@
{
checkNotNullArgument(user, "User");
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addAssociatedUserId(user.getId());
+ search.setSearchCriteria(criteria);
+
+ Collection<Group> results = cache.getGroupSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
List<Group> identities = new LinkedList<Group>();
Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(user),
MEMBER, false, convertSearchControls(criteria));
@@ -697,6 +949,15 @@
identities.add(createGroup(io));
}
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addAssociatedUserId(user.getId());
+ search.setSearchCriteria(criteria);
+
+ cache.putGroupSearch(cacheNS, search, identities);
+ }
+
return identities;
}
@@ -720,6 +981,20 @@
{
checkNotNullArgument(group, "Group");
+ if (cache != null)
+ {
+ UserSearchImpl search = new UserSearchImpl();
+ search.addAssociatedGroupId(group.getId());
+ search.setCascade(cascade);
+ search.setSearchCriteria(criteria);
+
+ Collection<User> results = cache.getUserSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
List<User> identities = new LinkedList<User>();
if (cascade)
@@ -751,23 +1026,34 @@
throw new IdentityException("Failed to apply criteria", e);
}
- return identities;
-
}
+ else
+ {
- Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group),
MEMBER, true, convertSearchControls(criteria));
+ Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group),
MEMBER, true, convertSearchControls(criteria));
- String userTypeName = getUserObjectType().getName();
+ String userTypeName = getUserObjectType().getName();
- for (IdentityObject io : ios)
- {
- //Filter out groups
- if (io.getIdentityType().getName().equals(userTypeName))
+ for (IdentityObject io : ios)
{
- identities.add(createUser(io));
+ //Filter out groups
+ if (io.getIdentityType().getName().equals(userTypeName))
+ {
+ identities.add(createUser(io));
+ }
}
}
+ if (cache != null)
+ {
+ UserSearchImpl search = new UserSearchImpl();
+ search.addAssociatedGroupId(group.getId());
+ search.setCascade(cascade);
+ search.setSearchCriteria(criteria);
+
+ cache.putUserSearch(cacheNS, search, identities);
+ }
+
return identities;
}
@@ -791,6 +1077,20 @@
{
checkNotNullArgument(user, "User");
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addRelatedUserId(user.getId());
+ search.setGroupType(groupType);
+ search.setSearchCriteria(criteria);
+
+ Collection<Group> results = cache.getGroupSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
List<Group> identities = new LinkedList<Group>();
Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(user),
null, false, convertSearchControls(criteria));
@@ -805,6 +1105,20 @@
identities.add(createGroup(io));
}
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addRelatedUserId(user.getId());
+ search.setGroupType(groupType);
+ search.setSearchCriteria(criteria);
+
+ Collection<Group> results = cache.getGroupSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
return identities;
}
@@ -821,6 +1135,19 @@
{
checkNotNullArgument(group, "Group");
+ if (cache != null)
+ {
+ UserSearchImpl search = new UserSearchImpl();
+ search.addRelatedGroupId(group.getId());
+ search.setSearchCriteria(criteria);
+
+ Collection<User> results = cache.getUserSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
List<User> identities = new LinkedList<User>();
Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group),
null, true, convertSearchControls(criteria));
@@ -840,6 +1167,16 @@
}
}
+ if (cache != null)
+ {
+ UserSearchImpl search = new UserSearchImpl();
+ search.addRelatedGroupId(group.getId());
+ search.setSearchCriteria(criteria);
+
+ cache.putUserSearch(cacheNS, search, identities);
+
+ }
+
return identities;
}
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -32,6 +32,7 @@
import org.jboss.identity.idm.api.RoleManagerFeaturesDescription;
import org.jboss.identity.idm.api.IdentitySearchCriteria;
import org.jboss.identity.idm.api.IdentitySearchCriteriumType;
+import org.jboss.identity.idm.api.query.RoleQuery;
import org.jboss.identity.idm.common.exception.IdentityException;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
@@ -43,6 +44,11 @@
import org.jboss.identity.idm.impl.api.model.SimpleRole;
import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
import org.jboss.identity.idm.impl.types.SimpleIdentityObjectRelationship;
+import org.jboss.identity.idm.impl.cache.RoleTypeSearchImpl;
+import org.jboss.identity.idm.impl.cache.UserSearchImpl;
+import org.jboss.identity.idm.impl.cache.GroupSearchImpl;
+import org.jboss.identity.idm.impl.cache.RoleSearchImpl;
+import org.jboss.identity.idm.cache.RoleTypeSearch;
import java.util.Collection;
import java.util.Set;
@@ -134,7 +140,17 @@
throw new IdentityException("Role management not supported");
}
- return new SimpleRoleType(roleType);
+ RoleType result = new SimpleRoleType(roleType);
+
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ cache.putRoleType(cacheNS, result);
+ }
+
+ return result;
+
}
public void removeRoleType(String name) throws IdentityException
@@ -147,6 +163,13 @@
getRepository().removeRelationshipName(getInvocationContext(), name);
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ cache.removeRoleType(cacheNS, new SimpleRoleType(name));
+ }
+
postRemove(new SimpleRoleType(name));
}
@@ -167,11 +190,26 @@
{
checkNotNullArgument(name, "RoleType name");
+
+ if (cache != null)
+ {
+ RoleType roleType = cache.getRoleType(cacheNS, new SimpleRoleType(name));
+ if (roleType != null)
+ {
+ return roleType;
+ }
+ }
+
try
{
Set<String> names =
getRepository().getRelationshipNames(getInvocationContext(), null);
if (names.contains(name))
{
+ if (cache != null)
+ {
+ cache.putRoleType(cacheNS, new SimpleRoleType(name));
+ }
+
return new SimpleRoleType(name);
}
}
@@ -185,7 +223,17 @@
public Collection<RoleType> findRoleTypes(IdentitySearchCriteria criteria)
throws IdentityException
{
+ if (cache != null)
+ {
+ RoleTypeSearch search = new RoleTypeSearchImpl();
+ search.setSearchCriteria(criteria);
+ Collection<RoleType> result = cache.getRoleTypeSearch(cacheNS, search);
+ if (result != null)
+ {
+ return result;
+ }
+ }
try
{
@@ -197,6 +245,15 @@
types.add(new SimpleRoleType(name));
}
+ if (cache != null)
+ {
+ RoleTypeSearch search = new RoleTypeSearchImpl();
+ search.setSearchCriteria(criteria);
+
+ cache.putRoleTypeSearch(cacheNS, search, types);
+
+ }
+
return types;
}
catch (OperationNotSupportedException e)
@@ -218,18 +275,25 @@
checkNotNullArgument(group, "Group");
//TODO: add createRoleType switch to the API
-
Role _role = new SimpleRole(roleType, user, group);
preCreate(_role);
IdentityObjectRelationship rel =
getRepository().createRelationship(getInvocationContext(), createIdentityObject(group),
createIdentityObject(user), ROLE, roleType.getName(), false);
+ Role role = new SimpleRole(new SimpleRoleType(rel.getName()),
createUser(rel.getToIdentityObject()), createGroup(rel.getFromIdentityObject()));
+
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ cache.putRole(cacheNS, role);
+ }
+
postCreate(_role);
-
- //TODO: null id - IdentityObjectRelationship doesn't have id
- return new SimpleRole(new SimpleRoleType(rel.getName()),
createUser(rel.getToIdentityObject()), createGroup(rel.getFromIdentityObject()));
+ return role;
+
}
public Role createRole(String roleTypeName, String userName, String groupId) throws
IdentityException
@@ -256,6 +320,13 @@
getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(group), createIdentityObject(user), ROLE, roleType.getName());
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ cache.removeRole(cacheNS, _role);
+ }
+
postRemove(_role);
}
@@ -279,6 +350,13 @@
getRepository().removeRelationship(getInvocationContext(),
createIdentityObject(role.getGroup()), createIdentityObject(role.getUser()), ROLE,
role.getRoleType().getName());
+ if (cache != null)
+ {
+ cache.invalidateAllQueries(cacheNS);
+ cache.invalidateAllSearches(cacheNS);
+ cache.removeRole(cacheNS, role);
+ }
+
postRemove(role);
}
@@ -288,6 +366,16 @@
checkNotNullArgument(user, "User");
checkNotNullArgument(group, "Group");
+ if (cache != null)
+ {
+ Role role = new SimpleRole(roleType, user, group);
+ role = cache.getRole(cacheNS, role);
+ if (role != null)
+ {
+ return true;
+ }
+ }
+
//TODO: does separate hasRelationship method in IdentityStore makes sense?
Set<IdentityObjectRelationship> rels =
getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(group),
createIdentityObject(user), ROLE);
@@ -296,6 +384,12 @@
{
if (rel.getType().getName().equals(ROLE.getName()) && rel.getName() !=
null && rel.getName().equals(roleType.getName()))
{
+ if (cache != null)
+ {
+ Role role = new SimpleRole(roleType, user, group);
+ cache.putRole(cacheNS, role);
+ }
+
return true;
}
}
@@ -321,6 +415,16 @@
checkNotNullArgument(user, "User");
checkNotNullArgument(group, "Group");
+ if (cache != null)
+ {
+ Role role = new SimpleRole(roleType, user, group);
+ role = cache.getRole(cacheNS, role);
+ if (role != null)
+ {
+ return role;
+ }
+ }
+
//TODO: does separate hasRelationship method in IdentityStore makes sense?
Set<IdentityObjectRelationship> rels =
getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(group),
createIdentityObject(user), ROLE);
@@ -334,9 +438,17 @@
{
if (roleType.getName().equals(relationship.getName()))
{
- return new SimpleRole(new SimpleRoleType(relationship.getName()),
+
+ Role role = new SimpleRole(new SimpleRoleType(relationship.getName()),
createUser(relationship.getToIdentityObject()),
createGroup(relationship.getFromIdentityObject()));
+
+ if (cache != null)
+ {
+ cache.putRole(cacheNS, role);
+ }
+
+ return role;
}
}
@@ -374,6 +486,20 @@
checkNotNullArgument(user, "User");
checkNotNullArgument(group, "Group");
+ if (cache != null)
+ {
+ RoleTypeSearchImpl search = new RoleTypeSearchImpl();
+ search.setUser(user);
+ search.setGroup(group);
+ search.setSearchCriteria(criteria);
+
+ Collection<RoleType> results = cache.getRoleTypeSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
Set<IdentityObjectRelationship> rels =
getRepository().resolveRelationships(getInvocationContext(), createIdentityObject(group),
createIdentityObject(user), ROLE);
Set<RoleType> types = new HashSet<RoleType>();
@@ -382,6 +508,17 @@
types.add(new SimpleRoleType(rel.getName()));
}
+ if (cache != null)
+ {
+ RoleTypeSearchImpl search = new RoleTypeSearchImpl();
+ search.setUser(user);
+ search.setGroup(group);
+ search.setSearchCriteria(criteria);
+
+ cache.putRoleTypeSearch(cacheNS, search, types);
+
+ }
+
return types;
@@ -411,6 +548,19 @@
Set<RoleType> types = new HashSet<RoleType>();
+ if (cache != null)
+ {
+ RoleTypeSearchImpl search = new RoleTypeSearchImpl();
+ search.setUser(user);
+ search.setSearchCriteria(criteria);
+
+ Collection<RoleType> results = cache.getRoleTypeSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
try
{
Collection<String> names =
getRepository().getRelationshipNames(getInvocationContext(), createIdentityObject(user),
convertSearchControls(criteria));
@@ -420,6 +570,15 @@
types.add(new SimpleRoleType(name));
}
+ if (cache != null)
+ {
+ RoleTypeSearchImpl search = new RoleTypeSearchImpl();
+ search.setUser(user);
+ search.setSearchCriteria(criteria);
+
+ cache.putRoleTypeSearch(cacheNS, search, types);
+ }
+
return types;
}
@@ -442,7 +601,6 @@
public Collection<RoleType> findGroupRoleTypes(Group group) throws
IdentityException
{
checkNotNullArgument(group, "Group");
-
return findGroupRoleTypes(group, null);
}
@@ -461,6 +619,19 @@
Set<RoleType> types = new HashSet<RoleType>();
+ if (cache != null)
+ {
+ RoleTypeSearchImpl search = new RoleTypeSearchImpl();
+ search.setGroup(group);
+ search.setSearchCriteria(criteria);
+
+ Collection<RoleType> results = cache.getRoleTypeSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
try
{
Collection<String> names =
getRepository().getRelationshipNames(getInvocationContext(), createIdentityObject(group),
convertSearchControls(criteria));
@@ -470,6 +641,16 @@
types.add(new SimpleRoleType(name));
}
+ if (cache != null)
+ {
+ RoleTypeSearchImpl search = new RoleTypeSearchImpl();
+ search.setGroup(group);
+ search.setSearchCriteria(criteria);
+
+ cache.putRoleTypeSearch(cacheNS, search, types);
+
+ }
+
return types;
}
@@ -486,7 +667,19 @@
List<User> identities = new LinkedList<User>();
+ if (cache != null)
+ {
+ UserSearchImpl search = new UserSearchImpl();
+ search.addRelatedGroupId(group.getId());
+ search.setSearchCriteria(criteria);
+ Collection<User> results = cache.getUserSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
Collection<IdentityObject> ios = null;
ios = getRepository().findIdentityObject(getInvocationContext(),
createIdentityObject(group), ROLE, true, convertSearchControls(criteria));
@@ -496,6 +689,16 @@
identities.add(createUser(io));
}
+ if (cache != null)
+ {
+ UserSearchImpl search = new UserSearchImpl();
+ search.addRelatedGroupId(group.getId());
+ search.setSearchCriteria(criteria);
+
+ cache.putUserSearch(cacheNS, search, identities);
+
+ }
+
return identities;
}
@@ -514,17 +717,38 @@
List<Group> identities = new LinkedList<Group>();
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addRelatedUserId(user.getId());
+ search.setSearchCriteria(criteria);
+ Collection<Group> results = cache.getGroupSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
Collection<IdentityObject> ios = null;
ios = getRepository().findIdentityObject(getInvocationContext(),
createIdentityObject(user), ROLE, false, convertSearchControls(criteria));
for (IdentityObject io : ios)
{
-
identities.add(createGroup(io));
}
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addRelatedUserId(user.getId());
+ search.setSearchCriteria(criteria);
+
+ cache.putGroupSearch(cacheNS, search, identities);
+
+ }
+
return identities;
}
@@ -544,6 +768,20 @@
List<Group> identities = new LinkedList<Group>();
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addRelatedUserId(user.getId());
+ search.setGroupType(groupType);
+ search.setSearchCriteria(criteria);
+
+ Collection<Group> results = cache.getGroupSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
Collection<IdentityObject> ios = null;
ios = getRepository().findIdentityObject(getInvocationContext(),
createIdentityObject(user), ROLE, false, convertSearchControls(criteria));
@@ -568,7 +806,18 @@
}
}
+ if (cache != null)
+ {
+ GroupSearchImpl search = new GroupSearchImpl();
+ search.addRelatedUserId(user.getId());
+ search.setGroupType(groupType);
+ search.setSearchCriteria(criteria);
+ cache.putGroupSearch(cacheNS, search, identities);
+
+ }
+
+
return identities;
}
@@ -590,6 +839,19 @@
Set<Role> roles = new HashSet<Role>();
+ if (cache != null)
+ {
+ RoleSearchImpl search = new RoleSearchImpl();
+ search.setIdentityTypeId(identityType.getId());
+ search.setRoleType(roleType);
+
+ Collection<Role> results = cache.getRoleSearch(cacheNS, search);
+ if (results != null)
+ {
+ return results;
+ }
+ }
+
Set<IdentityObjectRelationship> relationships = null;
// If Identity then search for parent relationships
@@ -618,6 +880,16 @@
}
}
+ if (cache != null)
+ {
+ RoleSearchImpl search = new RoleSearchImpl();
+ search.setIdentityTypeId(identityType.getId());
+ search.setRoleType(roleType);
+
+ cache.putRoleSearch(cacheNS, search, roles);
+
+ }
+
return roles;
}
@@ -625,7 +897,6 @@
public Collection<Role> findRoles(String id, String roleTypeName) throws
IdentityException
{
checkNotNullArgument(id, "Group id or User name");
-// checkNotNullArgument(roleTypeName, "RoleType name");
RoleType roleType = roleTypeName != null ? new SimpleRoleType(roleTypeName) :
null;
return findRoles(createIdentityTypeFromId(id), roleType);
@@ -634,8 +905,24 @@
public Map<String, String> getProperties(RoleType roleType) throws
IdentityException
{
checkNotNullArgument(roleType, "RoleType name");
+
+ if (cache != null)
+ {
+ Map<String, String> result = cache.getProperties(cacheNS, roleType);
+ if (result != null)
+ {
+ return result;
+ }
+ }
- return getRepository().getRelationshipNameProperties(getInvocationContext(),
roleType.getName());
+ Map<String, String> result =
getRepository().getRelationshipNameProperties(getInvocationContext(),
roleType.getName());
+
+ if (cache != null)
+ {
+ cache.putProperties(cacheNS, roleType, result);
+ }
+
+ return result;
}
public Map<String, String> getProperties(String roleTypeName) throws
IdentityException
@@ -649,7 +936,23 @@
{
checkNotNullArgument(role, "Role");
- return getRepository().getRelationshipProperties(getInvocationContext(),
createIdentityObjectRelationship(role));
+ if (cache != null)
+ {
+ Map<String, String> result = cache.getProperties(cacheNS, role);
+ if (result != null)
+ {
+ return result;
+ }
+ }
+
+ Map<String, String> result =
getRepository().getRelationshipProperties(getInvocationContext(),
createIdentityObjectRelationship(role));
+
+ if (cache != null)
+ {
+ cache.putProperties(cacheNS, role, result);
+ }
+
+ return result;
}
public void setProperty(Role role, String name, String value) throws
IdentityException
@@ -665,6 +968,12 @@
getRepository().setRelationshipProperties(getInvocationContext(),
createIdentityObjectRelationship(role), props);
+ if (cache != null)
+ {
+ cache.invalidateRoleProperties(cacheNS, role);
+ cache.putProperties(cacheNS, role, getProperties(role));
+ }
+
postPropertiesSet(role, props);
}
@@ -681,6 +990,13 @@
getRepository().setRelationshipNameProperties(getInvocationContext(),
roleType.getName(), props);
+ if (cache != null)
+ {
+ cache.invalidateRoleTypeProperties(cacheNS, roleType);
+ cache.putProperties(cacheNS, roleType, getProperties(roleType));
+ }
+
+
postPropertiesSet(roleType, props);
}
@@ -697,6 +1013,13 @@
setProperty(new SimpleRoleType(roleTypeName), name, value);
+ if (cache != null)
+ {
+ cache.invalidateRoleTypeProperties(cacheNS, new SimpleRoleType(roleTypeName));
+ cache.putProperties(cacheNS, new SimpleRoleType(roleTypeName), getProperties(new
SimpleRoleType(roleTypeName)));
+ }
+
+
postPropertiesSet(new SimpleRoleType(roleTypeName), props);
}
@@ -709,6 +1032,13 @@
getRepository().setRelationshipProperties(getInvocationContext(),
createIdentityObjectRelationship(role), properties);
+ if (cache != null)
+ {
+ cache.invalidateRoleProperties(cacheNS, role);
+ cache.putProperties(cacheNS, role, getProperties(role));
+ }
+
+
postPropertiesSet(role, properties);
}
@@ -721,6 +1051,12 @@
getRepository().setRelationshipNameProperties(getInvocationContext(),
roleType.getName(), properties);
+ if (cache != null)
+ {
+ cache.invalidateRoleTypeProperties(cacheNS, roleType);
+ cache.putProperties(cacheNS, roleType, getProperties(roleType));
+ }
+
postPropertiesSet(roleType, properties);
}
@@ -732,6 +1068,12 @@
setProperties(new SimpleRoleType(roleTypeName), properties);
+ if (cache != null)
+ {
+ cache.invalidateRoleTypeProperties(cacheNS, new SimpleRoleType(roleTypeName));
+ cache.putProperties(cacheNS, new SimpleRoleType(roleTypeName), getProperties(new
SimpleRoleType(roleTypeName)));
+ }
+
postPropertiesSet(new SimpleRoleType(roleTypeName), properties);
}
@@ -748,6 +1090,13 @@
getRepository().removeRelationshipProperties(getInvocationContext(),
createIdentityObjectRelationship(role), names);
+ if (cache != null)
+ {
+ cache.invalidateRoleProperties(cacheNS, role);
+ cache.putProperties(cacheNS, role, getProperties(role));
+ }
+
+
postPropertiesRemove(role, names);
}
@@ -763,6 +1112,12 @@
getRepository().removeRelationshipNameProperties(getInvocationContext(),
roleType.getName(), names);
+ if (cache != null)
+ {
+ cache.invalidateRoleTypeProperties(cacheNS, roleType);
+ cache.putProperties(cacheNS, roleType, getProperties(roleType));
+ }
+
postPropertiesRemove(roleType, names);
}
@@ -777,6 +1132,12 @@
removeProperty(new SimpleRoleType(roleTypeName), name);
+ if (cache != null)
+ {
+ cache.invalidateRoleTypeProperties(cacheNS, new SimpleRoleType(roleTypeName));
+ cache.putProperties(cacheNS, new SimpleRoleType(roleTypeName), getProperties(new
SimpleRoleType(roleTypeName)));
+ }
+
postPropertiesRemove(new SimpleRoleType(roleTypeName), names);
}
Added:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/AbstractSearch.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/AbstractSearch.java
(rev 0)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/AbstractSearch.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,49 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.impl.cache;
+
+import org.jboss.identity.idm.api.IdentitySearchCriteria;
+
+import java.io.Serializable;
+
+public abstract class AbstractSearch implements Serializable
+{
+ private IdentitySearchCriteria searchCriteria;
+
+ public IdentitySearchCriteria getSearchCriteria()
+ {
+ return searchCriteria;
+ }
+
+ public void setSearchCriteria(IdentitySearchCriteria searchCriteria)
+ {
+ this.searchCriteria = searchCriteria;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return searchCriteria != null ? searchCriteria.hashCode() : 0;
+ }
+}
Added:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/GroupSearchImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/GroupSearchImpl.java
(rev 0)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/GroupSearchImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,213 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.impl.cache;
+
+import org.jboss.identity.idm.cache.GroupSearch;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+public class GroupSearchImpl extends AbstractSearch implements GroupSearch
+{
+ private String groupId;
+
+ private String groupType;
+
+ private Collection<String> associatedUserIds = new HashSet<String>();
+
+ private Collection<String> relatedUserIds = new HashSet<String>();
+
+ private Collection<String> associatedGroupIds = new HashSet<String>();
+
+ private Collection<String> relatedGroupIds = new HashSet<String>();
+
+ private Boolean parent;
+
+ private Boolean cascade;
+
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId)
+ {
+ this.groupId = groupId;
+ }
+
+ public String getGroupType()
+ {
+ return groupType;
+ }
+
+ public void setGroupType(String groupType)
+ {
+ this.groupType = groupType;
+ }
+
+ public Collection<String> getAssociatedUserIds()
+ {
+ return associatedUserIds;
+ }
+
+ public void setAssociatedUserIds(Collection<String> associatedUserIds)
+ {
+ this.associatedUserIds = associatedUserIds;
+ }
+
+ public void addAssociatedUserId(String id)
+ {
+ this.associatedUserIds.add(id);
+ }
+
+ public Collection<String> getRelatedUserIds()
+ {
+ return relatedUserIds;
+ }
+
+ public void setRelatedUserIds(Collection<String> relatedUserIds)
+ {
+ this.relatedUserIds = relatedUserIds;
+ }
+
+ public void addRelatedUserId(String id)
+ {
+ this.relatedUserIds.add(id);
+ }
+
+ public Collection<String> getAssociatedGroupIds()
+ {
+ return associatedGroupIds;
+ }
+
+ public void setAssociatedGroupIds(Collection<String> associatedGroupIds)
+ {
+ this.associatedGroupIds = associatedGroupIds;
+ }
+
+ public void addAssociatedGroupId(String id)
+ {
+ this.associatedGroupIds.add(id);
+ }
+
+ public Collection<String> getRelatedGroupIds()
+ {
+ return relatedGroupIds;
+ }
+
+ public void setRelatedGroupIds(Collection<String> relatedGroupIds)
+ {
+ this.relatedGroupIds = relatedGroupIds;
+ }
+
+ public void addRelatedGroupId(String id)
+ {
+ this.relatedGroupIds.add(id);
+ }
+
+ public Boolean isParent()
+ {
+ return parent;
+ }
+
+ public void setParent(Boolean parent)
+ {
+ this.parent = parent;
+ }
+
+ public Boolean isCascade()
+ {
+ return cascade;
+ }
+
+ public void setCascade(Boolean cascade)
+ {
+ this.cascade = cascade;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ GroupSearchImpl that = (GroupSearchImpl)o;
+
+ if (associatedGroupIds != null ?
!associatedGroupIds.equals(that.associatedGroupIds) : that.associatedGroupIds != null)
+ {
+ return false;
+ }
+ if (associatedUserIds != null ? !associatedUserIds.equals(that.associatedUserIds) :
that.associatedUserIds != null)
+ {
+ return false;
+ }
+ if (cascade != null ? !cascade.equals(that.cascade) : that.cascade != null)
+ {
+ return false;
+ }
+ if (groupId != null ? !groupId.equals(that.groupId) : that.groupId != null)
+ {
+ return false;
+ }
+ if (groupType != null ? !groupType.equals(that.groupType) : that.groupType !=
null)
+ {
+ return false;
+ }
+ if (parent != null ? !parent.equals(that.parent) : that.parent != null)
+ {
+ return false;
+ }
+ if (relatedGroupIds != null ? !relatedGroupIds.equals(that.relatedGroupIds) :
that.relatedGroupIds != null)
+ {
+ return false;
+ }
+ if (relatedUserIds != null ? !relatedUserIds.equals(that.relatedUserIds) :
that.relatedUserIds != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (groupId != null ? groupId.hashCode() : 0);
+ result = 31 * result + (groupType != null ? groupType.hashCode() : 0);
+ result = 31 * result + (associatedUserIds != null ? associatedUserIds.hashCode() :
0);
+ result = 31 * result + (relatedUserIds != null ? relatedUserIds.hashCode() : 0);
+ result = 31 * result + (associatedGroupIds != null ? associatedGroupIds.hashCode()
: 0);
+ result = 31 * result + (relatedGroupIds != null ? relatedGroupIds.hashCode() : 0);
+ result = 31 * result + (parent != null ? parent.hashCode() : 0);
+ result = 31 * result + (cascade != null ? cascade.hashCode() : 0);
+ return result;
+ }
+}
Added:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RelationshipSearchImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RelationshipSearchImpl.java
(rev 0)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RelationshipSearchImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,125 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.impl.cache;
+
+import org.jboss.identity.idm.cache.RelationshipSearch;
+import org.jboss.identity.idm.api.IdentityType;
+import org.jboss.identity.idm.impl.api.model.GroupId;
+import org.jboss.identity.idm.impl.api.model.SimpleGroup;
+import org.jboss.identity.idm.impl.api.model.SimpleUser;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+public class RelationshipSearchImpl extends AbstractSearch implements RelationshipSearch
+{
+ private Collection<IdentityType> parents = new HashSet<IdentityType>();
+
+ private Collection<IdentityType> members = new HashSet<IdentityType>();
+
+ public Collection<IdentityType> getParents()
+ {
+ return parents;
+ }
+
+ public Collection<IdentityType> getMembers()
+ {
+ return members;
+ }
+
+ public void setParents(Collection<IdentityType> parents)
+ {
+ this.parents = parents;
+ }
+
+ public void setMembers(Collection<IdentityType> members)
+ {
+ this.members = members;
+ }
+
+ public void addParent(IdentityType it)
+ {
+ parents.add(it);
+ }
+
+ public void addMember(IdentityType it)
+ {
+ members.add(it);
+ }
+
+ public void addParent(String id)
+ {
+ if (GroupId.validateId(id))
+ {
+ parents.add(new SimpleGroup(new GroupId(id)));
+ return;
+ }
+ parents.add(new SimpleUser(id));
+ }
+
+ public void addMember(String id)
+ {
+ if (GroupId.validateId(id))
+ {
+ members.add(new SimpleGroup(new GroupId(id)));
+ return;
+ }
+ members.add(new SimpleUser(id));
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ RelationshipSearchImpl that = (RelationshipSearchImpl)o;
+
+ if (members != null ? !members.equals(that.members) : that.members != null)
+ {
+ return false;
+ }
+ if (parents != null ? !parents.equals(that.parents) : that.parents != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (parents != null ? parents.hashCode() : 0);
+ result = 31 * result + (members != null ? members.hashCode() : 0);
+ return result;
+ }
+}
Added:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RoleSearchImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RoleSearchImpl.java
(rev 0)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RoleSearchImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,90 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.impl.cache;
+
+import org.jboss.identity.idm.cache.RoleSearch;
+import org.jboss.identity.idm.api.RoleType;
+
+public class RoleSearchImpl extends AbstractSearch implements RoleSearch
+{
+
+ private String identityTypeId;
+
+ private RoleType roleType;
+
+ public String getIdentityTypeId()
+ {
+ return identityTypeId;
+ }
+
+ public void setIdentityTypeId(String identityTypeId)
+ {
+ this.identityTypeId = identityTypeId;
+ }
+
+ public RoleType getRoleType()
+ {
+ return roleType;
+ }
+
+ public void setRoleType(RoleType roleType)
+ {
+ this.roleType = roleType;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ RoleSearchImpl that = (RoleSearchImpl)o;
+
+ if (identityTypeId != null ? !identityTypeId.equals(that.identityTypeId) :
that.identityTypeId != null)
+ {
+ return false;
+ }
+ if (roleType != null ? !roleType.equals(that.roleType) : that.roleType != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (identityTypeId != null ? identityTypeId.hashCode() : 0);
+ result = 31 * result + (roleType != null ? roleType.hashCode() : 0);
+ return result;
+ }
+}
Added:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RoleTypeSearchImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RoleTypeSearchImpl.java
(rev 0)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/RoleTypeSearchImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,90 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.impl.cache;
+
+import org.jboss.identity.idm.cache.RoleTypeSearch;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.User;
+
+public class RoleTypeSearchImpl extends AbstractSearch implements RoleTypeSearch
+{
+ private User user;
+
+ private Group group;
+
+ public User getUser()
+ {
+ return user;
+ }
+
+ public void setUser(User user)
+ {
+ this.user = user;
+ }
+
+ public Group getGroup()
+ {
+ return group;
+ }
+
+ public void setGroup(Group group)
+ {
+ this.group = group;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ RoleTypeSearchImpl that = (RoleTypeSearchImpl)o;
+
+ if (group != null ? !group.equals(that.group) : that.group != null)
+ {
+ return false;
+ }
+ if (user != null ? !user.equals(that.user) : that.user != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (user != null ? user.hashCode() : 0);
+ result = 31 * result + (group != null ? group.hashCode() : 0);
+ return result;
+ }
+}
Added:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/UserSearchImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/UserSearchImpl.java
(rev 0)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/UserSearchImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -0,0 +1,180 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.impl.cache;
+
+import org.jboss.identity.idm.cache.UserSearch;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+public class UserSearchImpl extends AbstractSearch implements UserSearch
+{
+
+ private String userId;
+
+ private Collection<String> associatedUserIds = new HashSet<String>();
+
+ private Collection<String> relatedUserIds = new HashSet<String>();
+
+ private Collection<String> associatedGroupTypeNames = new
HashSet<String>();
+
+ private Collection<String> relatedGroupTypeNames = new HashSet<String>();
+
+ private Boolean cascade;
+
+ public String getUserId()
+ {
+ return userId;
+ }
+
+ public void setUserId(String userId)
+ {
+ this.userId = userId;
+ }
+
+ public Collection<String> getAssociatedUserIds()
+ {
+ return associatedUserIds;
+ }
+
+ public void setAssociatedUserIds(Collection<String> associatedUserIds)
+ {
+ this.associatedUserIds = associatedUserIds;
+ }
+
+ public void addAssociatedUserId(String id)
+ {
+ this.associatedUserIds.add(id);
+ }
+
+ public Collection<String> getRelatedUserIds()
+ {
+ return relatedUserIds;
+ }
+
+ public void setRelatedUserIds(Collection<String> relatedUserIds)
+ {
+ this.relatedUserIds = relatedUserIds;
+ }
+
+ public void addRelatedUserId(String id)
+ {
+ this.relatedUserIds.add(id);
+ }
+
+ public Collection<String> getAssociatedGroupTypeNames()
+ {
+ return associatedGroupTypeNames;
+ }
+
+ public void setAssociatedGroupTypeNames(Collection<String>
associatedGroupTypeNames)
+ {
+ this.associatedGroupTypeNames = associatedGroupTypeNames;
+ }
+
+ public void addAssociatedGroupId(String id)
+ {
+ this.associatedGroupTypeNames.add(id);
+ }
+
+ public Collection<String> getRelatedGroupTypeNames()
+ {
+ return relatedGroupTypeNames;
+ }
+
+ public void setRelatedGroupTypeNames(Collection<String> relatedGroupTypeNames)
+ {
+ this.relatedGroupTypeNames = relatedGroupTypeNames;
+ }
+
+ public void addRelatedGroupId(String id)
+ {
+ this.relatedGroupTypeNames.add(id);
+ }
+
+ public Boolean isCascade()
+ {
+ return cascade;
+ }
+
+ public void setCascade(Boolean cascade)
+ {
+ this.cascade = cascade;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ UserSearchImpl that = (UserSearchImpl)o;
+
+ if (associatedGroupTypeNames != null ?
!associatedGroupTypeNames.equals(that.associatedGroupTypeNames) :
that.associatedGroupTypeNames != null)
+ {
+ return false;
+ }
+ if (associatedUserIds != null ? !associatedUserIds.equals(that.associatedUserIds) :
that.associatedUserIds != null)
+ {
+ return false;
+ }
+ if (cascade != null ? !cascade.equals(that.cascade) : that.cascade != null)
+ {
+ return false;
+ }
+ if (relatedGroupTypeNames != null ?
!relatedGroupTypeNames.equals(that.relatedGroupTypeNames) : that.relatedGroupTypeNames !=
null)
+ {
+ return false;
+ }
+ if (relatedUserIds != null ? !relatedUserIds.equals(that.relatedUserIds) :
that.relatedUserIds != null)
+ {
+ return false;
+ }
+ if (userId != null ? !userId.equals(that.userId) : that.userId != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (userId != null ? userId.hashCode() : 0);
+ result = 31 * result + (associatedUserIds != null ? associatedUserIds.hashCode() :
0);
+ result = 31 * result + (relatedUserIds != null ? relatedUserIds.hashCode() : 0);
+ result = 31 * result + (associatedGroupTypeNames != null ?
associatedGroupTypeNames.hashCode() : 0);
+ result = 31 * result + (relatedGroupTypeNames != null ?
relatedGroupTypeNames.hashCode() : 0);
+ result = 31 * result + (cascade != null ? cascade.hashCode() : 0);
+ return result;
+ }
+}
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -44,6 +44,7 @@
import org.jboss.identity.idm.spi.store.IdentityStore;
import org.jboss.identity.idm.spi.store.AttributeStore;
import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.idm.cache.APICacheProvider;
import java.util.logging.Logger;
import java.util.logging.Level;
@@ -248,9 +249,53 @@
mapper = new IdentityObjectTypeMapperImpl(metaData.getGroupTypeMappings(),
metaData.getIdentityMapping());
}
+ // Cache
+
+ Map<String, String> cacheProps = new HashMap<String, String>();
+ String cacheClassName = null;
+
+ // Parse all 'cache.' prefixed options
+ for (String key : metaData.getOptions().keySet())
+ {
+ if (key.startsWith("cache."))
+ {
+ if (metaData.getOptions().get(key).size() > 0)
+ {
+ cacheProps.put(key, metaData.getOptions().get(key).get(0));
+ }
+ if (key.equals("cache.providerClass") &&
metaData.getOptions().get(key).size() > 0)
+ {
+ cacheClassName = metaData.getOptions().get(key).get(0);
+ }
+ }
+ }
+
+ APICacheProvider provider = null;
+
+ // Instantiate provider
+ if (cacheClassName != null)
+ {
+ Class repoClass = null;
+ try
+ {
+ repoClass = Class.forName(cacheClassName);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IdentityException("Cannot instantiate
APICacheProvider:" + cacheClassName, e);
+ }
+
+ Constructor ct = repoClass.getConstructor();
+
+ provider = (APICacheProvider)ct.newInstance();
+
+ provider.initialize(cacheProps);
+ }
+
+
//IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper);
IdentitySessionConfigurationContext sessionConfigCtx =
- new IdentitySessionConfigurationContext(realmName, configMD, repo, mapper);
+ new IdentitySessionConfigurationContext(realmName, configMD, repo, mapper,
provider);
sessionCtxMap.put(realmName, sessionConfigCtx);
}
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/configuration/IdentitySessionConfigurationContext.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/configuration/IdentitySessionConfigurationContext.java 2009-11-03
14:33:23 UTC (rev 904)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/configuration/IdentitySessionConfigurationContext.java 2009-11-04
22:30:01 UTC (rev 905)
@@ -27,6 +27,7 @@
import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
+import org.jboss.identity.idm.cache.APICacheProvider;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -41,16 +42,19 @@
private final IdentityConfigurationMetaData identityConfigurationMetaData;
private final IdentityStoreRepository repository;
private final IdentityObjectTypeMapper typeMapper;
+ private final APICacheProvider apiCacheProvider;
public IdentitySessionConfigurationContext(String realmName,
IdentityConfigurationMetaData
identityConfigurationMetaData,
IdentityStoreRepository repository,
- IdentityObjectTypeMapper typeMapper)
+ IdentityObjectTypeMapper typeMapper,
+ APICacheProvider apiCacheProvider)
{
this.realmName = realmName;
this.identityConfigurationMetaData = identityConfigurationMetaData;
this.repository = repository;
this.typeMapper = typeMapper;
+ this.apiCacheProvider = apiCacheProvider;
}
public String getRealmName()
@@ -72,4 +76,9 @@
{
return typeMapper;
}
+
+ public APICacheProvider getApiCacheProvider()
+ {
+ return apiCacheProvider;
+ }
}
Added: idm/trunk/idm-testsuite/src/test/resources/jboss-cache.xml
===================================================================
--- idm/trunk/idm-testsuite/src/test/resources/jboss-cache.xml
(rev 0)
+++ idm/trunk/idm-testsuite/src/test/resources/jboss-cache.xml 2009-11-04 22:30:01 UTC
(rev 905)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
+
+</jbosscache>
\ No newline at end of file
Modified: idm/trunk/idm-testsuite/src/test/resources/test-identity-config.xml
===================================================================
--- idm/trunk/idm-testsuite/src/test/resources/test-identity-config.xml 2009-11-03
14:33:23 UTC (rev 904)
+++ idm/trunk/idm-testsuite/src/test/resources/test-identity-config.xml 2009-11-04
22:30:01 UTC (rev 905)
@@ -9,6 +9,16 @@
<identity-type-mappings>
<user-mapping>USER</user-mapping>
</identity-type-mappings>
+ <options>
+ <option>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheAPICacheProviderImpl</value>
+ </option>
+ <option>
+ <name>cache.configFile</name>
+ <value>jboss-cache.xml</value>
+ </option>
+ </options>
</realm>
<realm>
<id>realm://portal/SamplePortal/DB</id>
@@ -16,6 +26,16 @@
<identity-type-mappings>
<user-mapping>USER</user-mapping>
</identity-type-mappings>
+ <options>
+ <option>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheAPICacheProviderImpl</value>
+ </option>
+ <option>
+ <name>cache.configFile</name>
+ <value>jboss-cache.xml</value>
+ </option>
+ </options>
</realm>
<realm>
<id>realm://RedHat/DB_LDAP</id>
@@ -23,6 +43,16 @@
<identity-type-mappings>
<user-mapping>USER</user-mapping>
</identity-type-mappings>
+ <options>
+ <option>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheAPICacheProviderImpl</value>
+ </option>
+ <option>
+ <name>cache.configFile</name>
+ <value>jboss-cache.xml</value>
+ </option>
+ </options>
</realm>
<realm>
<id>realm://portal/SamplePortal/DB_LDAP</id>
@@ -30,6 +60,16 @@
<identity-type-mappings>
<user-mapping>USER</user-mapping>
</identity-type-mappings>
+ <options>
+ <option>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheAPICacheProviderImpl</value>
+ </option>
+ <option>
+ <name>cache.configFile</name>
+ <value>jboss-cache.xml</value>
+ </option>
+ </options>
</realm>
</realms>
<repositories>