Author: bdaw
Date: 2009-11-05 14:23:37 -0500 (Thu, 05 Nov 2009)
New Revision: 907
Added:
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/AbstractSPISearchImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectRelationshipNameSearchImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectRelationshipSearchImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectSearchImpl.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectRelationshipNameSearch.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectRelationshipSearch.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectSearch.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/Search.java
Removed:
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheProviderImpl.java
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/Search.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/APICacheProviderTestCase.java
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/session/IdentitySessionImpl.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAttributeStoreWrapper.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.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-core/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/store/SimpleIdentityStoreInvocationContext.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityStoreCacheProvider.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreInvocationContext.java
idm/trunk/idm-testsuite/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
idm/trunk/idm-testsuite/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-msad-local.xml
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-msad.xml
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-openldapds.xml
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-redhatds.xml
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-sunds.xml
idm/trunk/idm-testsuite/src/test/resources/test-identity-config.xml
Log:
- SPI caching layer improvements
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-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/APICacheProvider.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -22,6 +22,7 @@
package org.jboss.identity.idm.cache;
import org.jboss.identity.idm.api.*;
+import org.jboss.identity.idm.api.cfg.IdentityConfigurationRegistry;
import org.jboss.identity.idm.api.query.GroupQuery;
import org.jboss.identity.idm.api.query.RoleQuery;
import org.jboss.identity.idm.api.query.UserQuery;
@@ -44,7 +45,7 @@
* Initialize provider.
* @param properties
*/
- void initialize(Map<String, String> properties);
+ void initialize(Map<String, String> properties, IdentityConfigurationRegistry
configurationRegistry);
void invalidate(String ns);
Modified: 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 2009-11-05
12:19:23 UTC (rev 906)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/cache/Search.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -27,7 +27,7 @@
import java.io.Serializable;
-public interface Search extends Serializable
+public abstract interface Search extends Serializable
{
IdentitySearchCriteria getSearchCriteria();
Deleted:
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheProviderImpl.java
===================================================================
---
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheProviderImpl.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheProviderImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -1,933 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, 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.cache.Fqn;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Node;
-import org.jboss.identity.idm.spi.model.IdentityObject;
-import org.jboss.identity.idm.spi.model.IdentityObjectType;
-import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
-import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.idm.spi.search.IdentityObjectSearchCriteria;
-import org.jboss.identity.idm.spi.cache.IdentityStoreCacheProvider;
-
-import java.util.logging.Logger;
-import java.util.logging.Level;
-import java.util.Set;
-import java.util.Map;
-import java.util.Collection;
-import java.io.InputStream;
-
-/**
- * Helper class providing caching support for IdentityStore. Stores search methods
results using hash from a set of used
- * IdentityObjectSearchControl objects as a key. *
- *
- * TODO: update cache tree structure documentation to all used nodes/keys...
- * Cache structure:
- *
- * CACHE_ROOT (real)
- * |
- * |-JBID_ROOT_NODE
- * |
- * |-OBJECT_TYPES_NODE
- * | |
- * | |-OBJECT_TYPES_IDS_NODE
- * | | |
- * | | |- (IdentityObjectType names)
- * | | | key[NODE_OBJECT_KEY] -> IdentityObject
- * | | |- ...
- * | |
- * | |-OBJECT_TYPES_NAMES_NODE
- * | | |
- * | | |- (IdentityObjectType names)
- * | | | key[NODE_OBJECT_KEY] -> IdentityObject
- * | | | key[NODE_ATTRIBUTES_KEY] -> Map<String, IdentityObjectAttribute>
- * | | |- ...
- * | |
- * | |-OBJECT_TYPES_SEARCH_NODE
- * | |
- * | |
- * | |- ...
- * |
- * |-RELATIONSHIPS_NODE
- * |
-
- *
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class IdentityStoreCacheProviderImpl implements IdentityStoreCacheProvider
-{
- private static Logger log =
Logger.getLogger(IdentityStoreCacheProvider.class.getName());
-
- //Structure
- public static final String JBID_ROOT_NODE = "/jboss_id_idm";
-
- public static final String OBJECT_TYPES_NODE = JBID_ROOT_NODE +
"/object_types";
-
- public static final String OBJECT_TYPES_IDS_NODE = OBJECT_TYPES_NODE +
"/by_ids";
-
- public static final String OBJECT_TYPES_NAMES_NODE = OBJECT_TYPES_NODE +
"/by_names";
-
- public static final String OBJECT_TYPES_SEARCH_BY_TYPE_NODE = OBJECT_TYPES_NODE +
"/search_by_type";
-
- public static final String OBJECT_TYPES_SEARCH_NODE = OBJECT_TYPES_NODE +
"/search";
-
- // Don't populate children as resident nodes!
- public static final String OBJECT_TYPES_COUNT_NODE = OBJECT_TYPES_NODE +
"/count";
-
- public static final String RELATIONSHIPS_SEARCH_NODE = JBID_ROOT_NODE +
"/relationship_types_names";
-
- public static final String RELATIONSHIPS_SEARCH_SIMPLE_NODE =
RELATIONSHIPS_SEARCH_NODE + "/simple";
-
- public static final String RELATIONSHIPS_SEARCH_COMPLEX_NODE =
RELATIONSHIPS_SEARCH_NODE + "/complex";
-
- public static final String RELATIONSHIP_NAMES_SEARCH_NODE = JBID_ROOT_NODE +
"/relationship_names_search";
-
- public static final String RELATIONSHIP_NAMES_SEARCH_IO_NODE =
RELATIONSHIP_NAMES_SEARCH_NODE + "/identity_object";
-
- public static final String RELATIONSHIP_NAMES_SEARCH_ALL_NODE =
RELATIONSHIP_NAMES_SEARCH_NODE + "/all";
-
- // Node keys
-
- public static final String NODE_OBJECT_KEY = "object";
-
- public static final String NODE_ATTRIBUTES_KEY = "attributes";
-
- public static final String NODE_REL_NAME_KEY = "relationship_name";
-
- public static final String NODE_REL_TYPE_KEY = "relationship_type";
-
- public static final String NODE_REL_FROM_KEY = "relationship_from";
-
- public static final String NODE_REL_TO_KEY = "relationship_to";
-
- public static final String NODE_SEARCH_RESULTS_KEY = "search_results";
-
-
- // FQNs
-
- public static final Fqn FQN_OBJECT_TYPES = Fqn.fromString(OBJECT_TYPES_NODE);
-
- public static final Fqn FQN_OBJECT_TYPES_NAMES =
Fqn.fromString(OBJECT_TYPES_NAMES_NODE);
-
- public static final Fqn FQN_OBJECT_TYPES_IDS = Fqn.fromString(OBJECT_TYPES_IDS_NODE);
-
- public static final Fqn FQN_OBJECT_TYPES_SEARCH_BY_TYPE =
Fqn.fromString(OBJECT_TYPES_SEARCH_BY_TYPE_NODE);
-
- public static final Fqn FQN_OBJECT_TYPES_SEARCH =
Fqn.fromString(OBJECT_TYPES_SEARCH_NODE);
-
- public static final Fqn FQN_OBJECT_TYPES_COUNT =
Fqn.fromString(OBJECT_TYPES_COUNT_NODE);
-
- public static final Fqn FQN_RELATIONSHIPS =
Fqn.fromString(RELATIONSHIPS_SEARCH_NODE);
-
- public static final Fqn FQN_RELATIONSHIPS_COMPLEX =
Fqn.fromString(RELATIONSHIPS_SEARCH_COMPLEX_NODE);
-
- public static final Fqn FQN_RELATIONSHIPS_SIMPLE =
Fqn.fromString(RELATIONSHIPS_SEARCH_SIMPLE_NODE);
-
- protected final Cache cache;
-
- public IdentityStoreCacheProviderImpl(InputStream cacheConfigInputStream)
- {
- CacheFactory factory = new DefaultCacheFactory();
-
- this.cache = factory.createCache(cacheConfigInputStream);
-
- this.cache.start();
-
- }
-
- private Fqn createIONameNodeFQN(String ioTypeName, String ioName)
- {
- return Fqn.fromElements(OBJECT_TYPES_NAMES_NODE, ioTypeName, ioName);
- }
-
- private Fqn createIONameNodeFQN(IdentityObject io)
- {
- return Fqn.fromElements(OBJECT_TYPES_NAMES_NODE, io.getIdentityType().getName(),
io.getName());
- }
-
- private Fqn createIOIdNodeFQN(IdentityObject io)
- {
- return Fqn.fromElements(OBJECT_TYPES_IDS_NODE, io.getIdentityType().getName(),
io.getId());
- }
-
- private Fqn createIOTypeCountNodeFQN(IdentityObjectType iot)
- {
- return Fqn.fromElements(OBJECT_TYPES_COUNT_NODE, iot.getName());
- }
-
- private Fqn createIOTypeSearchNodeFQN(IdentityObjectType iot, Object searchId)
- {
- return Fqn.fromElements(OBJECT_TYPES_SEARCH_BY_TYPE_NODE, iot.getName(),
searchId);
- }
-
- private Fqn createIOSearchNodeFQN(IdentityObject io, IdentityObjectRelationshipType
relationshipType, boolean parent, Object searchId)
- {
- return Fqn.fromElements(OBJECT_TYPES_SEARCH_NODE, io.getIdentityType().getName(),
relationshipType == null ? "null" : relationshipType.getName(),
- io.getName() + "_" + parent, searchId);
- }
-
- private Fqn createRelationshipNamesIdentityObjectSearchFqn(IdentityObject
identityObject, Object searchId)
- {
- return Fqn.fromElements(RELATIONSHIP_NAMES_SEARCH_IO_NODE,
identityObject.getIdentityType() + "_" + identityObject.getName(),
- searchId);
- }
-
- private Fqn createRelationshipNamesAllSearchFqn(Object searchId)
- {
- return Fqn.fromElements(RELATIONSHIP_NAMES_SEARCH_ALL_NODE, searchId);
- }
-
- private Fqn createRelationshipsSimpleSearchFqn(IdentityObject fromIdentity,
- IdentityObject toIdentity,
- IdentityObjectRelationshipType
relationshipType)
- {
- //TODO: fixme - null relationshipType
- return Fqn.fromElements(RELATIONSHIPS_SEARCH_SIMPLE_NODE,
fromIdentity.getIdentityType().getName() + "_" + toIdentity.getName(),
- toIdentity.getIdentityType().getName() + "_" + toIdentity.getName(),
relationshipType == null ? "null" : relationshipType );
- }
-
- private Fqn createRelationshipsComplexSearchFqn(IdentityObject identity,
- IdentityObjectRelationshipType
relationshipType,
- boolean parent,
- boolean named,
- String name)
- {
- return Fqn.fromElements(RELATIONSHIPS_SEARCH_COMPLEX_NODE,
identity.getIdentityType().getName() + "_" + identity.getName(),
- parent, relationshipType, named + "_" + name);
- }
-
- public static boolean isSchemaFqn(Fqn fqn)
- {
- if (fqn.equals(JBID_ROOT_NODE) ||
- fqn.equals(OBJECT_TYPES_NODE) ||
- fqn.equals(OBJECT_TYPES_IDS_NODE) ||
- fqn.equals(OBJECT_TYPES_NAMES_NODE) ||
- fqn.equals(RELATIONSHIPS_SEARCH_NODE))
- {
- return true;
- }
- return false;
- }
-
- public static boolean isFqnObjectTypeChild(Fqn fqn)
- {
- return fqn.isChildOf(FQN_OBJECT_TYPES);
- }
-
- public static boolean isFqnObjectTypeIdsChild(Fqn fqn)
- {
- return fqn.isChildOf(FQN_OBJECT_TYPES_IDS);
- }
-
- public static boolean isFqnObjectTypeNamesChild(Fqn fqn)
- {
- return fqn.isChildOf(FQN_OBJECT_TYPES_NAMES);
- }
-
- public static boolean isFqnObjectTypeSearchChild(Fqn fqn)
- {
- return fqn.isChildOf(FQN_OBJECT_TYPES_SEARCH_BY_TYPE);
- }
-
- public static boolean isFqnRelationshipsChild(Fqn fqn)
- {
- return fqn.isChildOf(FQN_RELATIONSHIPS);
- }
-
-
- private void removeNodeChildren(String path)
- {
- Fqn fqn = Fqn.fromString(path);
- Node node = getCache().getRoot().getChild(fqn);
-
- if (node != null)
- {
- Set<Object> names = node.getChildrenNames();
- for (Object name : names)
- {
- node.removeChild(name);
- }
- }
- }
-
- protected Logger getLog()
- {
- return log;
- }
-
- protected Cache getCache()
- {
- return cache;
- }
-
- public void initResidentNodes(Set<String> supportedIdentityObjectTypes,
- Set<String> supportedRelationshipTypes)
- {
-
getCache().getRoot().addChild(Fqn.fromString(IdentityStoreCacheProviderImpl.JBID_ROOT_NODE)).setResident(true);
-
getCache().getRoot().addChild(Fqn.fromString(IdentityStoreCacheProviderImpl.OBJECT_TYPES_NODE)).setResident(true);
- getCache().getRoot().addChild(FQN_OBJECT_TYPES_IDS).setResident(true);
- getCache().getRoot().addChild(FQN_OBJECT_TYPES_NAMES).setResident(true);
- getCache().getRoot().addChild(FQN_OBJECT_TYPES_SEARCH).setResident(true);
- getCache().getRoot().addChild(FQN_OBJECT_TYPES_SEARCH_BY_TYPE).setResident(true);
- getCache().getRoot().addChild(FQN_OBJECT_TYPES_COUNT).setResident(true);
-
getCache().getRoot().addChild(Fqn.fromString(RELATIONSHIP_NAMES_SEARCH_ALL_NODE)).setResident(true);
-
getCache().getRoot().addChild(Fqn.fromString(RELATIONSHIP_NAMES_SEARCH_IO_NODE)).setResident(true);
-
getCache().getRoot().addChild(Fqn.fromString(RELATIONSHIPS_SEARCH_COMPLEX_NODE)).setResident(true);
-
getCache().getRoot().addChild(Fqn.fromString(RELATIONSHIPS_SEARCH_SIMPLE_NODE)).setResident(true);
-
- for (String objectTypeName : supportedIdentityObjectTypes)
- {
- Fqn nodeFqn = Fqn.fromRelativeElements(FQN_OBJECT_TYPES_NAMES, "/" +
objectTypeName);
- getCache().getRoot().addChild(nodeFqn).setResident(true);
-
- nodeFqn = Fqn.fromRelativeElements(FQN_OBJECT_TYPES_IDS, "/" +
objectTypeName);
- getCache().getRoot().addChild(nodeFqn).setResident(true);
- }
- }
-
- public void putIntoCache(IdentityObject io)
- {
- Fqn nodeFqn = createIONameNodeFQN(io);
-
- Node ioNode = getCache().getRoot().addChild(nodeFqn);
-
- // in case this node was already present in cache
- if (!ioNode.getKeys().contains(NODE_OBJECT_KEY))
- {
- ioNode.put(NODE_OBJECT_KEY, io);
- }
-
- nodeFqn = createIOIdNodeFQN(io);
-
- ioNode = getCache().getRoot().addChild(nodeFqn);
-
- // in case this node was already present in cache
- if (!ioNode.getKeys().contains(NODE_OBJECT_KEY))
- {
- ioNode.put(NODE_OBJECT_KEY, io);
- }
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject stored in cache: " +
io.getName() + "; " + io.getId());
- }
- }
-
- public void putIntoCache(IdentityObject io, Map<String, IdentityObjectAttribute>
attributesMap)
- {
- Fqn nodeFqn = createIONameNodeFQN(io);
-
- Node ioNode = getCache().getRoot().addChild(nodeFqn);
-
- // in case this node was already present in cache
- if (!ioNode.getKeys().contains(NODE_OBJECT_KEY))
- {
- ioNode.put(NODE_OBJECT_KEY, io);
- }
-
- if (!ioNode.getKeys().contains(NODE_ATTRIBUTES_KEY))
- {
- ioNode.put(NODE_ATTRIBUTES_KEY, attributesMap);
- }
-
- nodeFqn = createIOIdNodeFQN(io);
-
- ioNode = getCache().getRoot().addChild(nodeFqn);
-
- // in case this node was already present in cache
- if (!ioNode.getKeys().contains(NODE_OBJECT_KEY))
- {
- ioNode.put(NODE_OBJECT_KEY, io);
- }
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject stored in cache with
attributes map: " + io.getName() + "; " + io.getId()
- + "; type=" + io.getIdentityType().getName() );
- }
- }
-
- public void removeFromCache(IdentityObject io)
- {
- Fqn nodeFqn = createIONameNodeFQN(io);
-
- getCache().getRoot().removeChild(nodeFqn);
-
- nodeFqn = createIOIdNodeFQN(io);
-
- getCache().getRoot().removeChild(nodeFqn);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject removed from cache: "
+ io.getName() + "; " + io.getId()
- + "; type=" + io.getIdentityType().getName() );
- }
- }
-
- public void removeAttributesFromCache(IdentityObject io)
- {
- Fqn nodeFqn = createIONameNodeFQN(io);
-
- Node ioNode = getCache().getRoot().addChild(nodeFqn);
-
- ioNode.remove(NODE_ATTRIBUTES_KEY);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject attributes removed from
cache: name=" + io.getName() + "; id=" + io.getId()
- + "; type=" + io.getIdentityType().getName() );
- }
- }
-
- public IdentityObject getFromCache(String name, IdentityObjectType
identityObjectType)
- {
- Fqn nodeFqn = Fqn.fromElements(OBJECT_TYPES_NODE, identityObjectType.getName(),
name);
-
- Node ioNode = getCache().getRoot().getChild(nodeFqn);
-
- if (ioNode != null)
- {
- IdentityObject io = (IdentityObject)ioNode.get(NODE_OBJECT_KEY);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject found in cache:
name=" + io.getName() + "; id=" + io.getId());
- }
-
- return io;
- }
-
- return null;
-
- }
-
- public Map<String, IdentityObjectAttribute> getAttributesFromCache(String name,
IdentityObjectType identityObjectType)
- {
- Fqn nodeFqn = Fqn.fromElements(OBJECT_TYPES_NODE, identityObjectType.getName(),
name);
-
- Node ioNode = getCache().getRoot().getChild(nodeFqn);
-
- if (ioNode != null)
- {
- Map<String, IdentityObjectAttribute> attrs = (Map<String,
IdentityObjectAttribute>)ioNode.get(NODE_ATTRIBUTES_KEY);
-
- if (attrs != null)
- {
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject attributes found in
cache: name=" + name + "; type=" + identityObjectType.getName());
- }
- }
- return attrs;
- }
-
- return null;
-
- }
-
- public IdentityObject getFromCache(String id)
- {
- Node idsNode = getCache().getRoot().getChild(OBJECT_TYPES_IDS_NODE);
-
- for (Node typeNode : (Set<Node>)idsNode.getChildren())
- {
- for (Object name : typeNode.getChildrenNames())
- {
- if (name.toString().equals(id))
- {
- IdentityObject io =
(IdentityObject)typeNode.getChild(name).get(NODE_OBJECT_KEY);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject found in cache:
name" + io.getName() + "; type" + io.getIdentityType().getName());
- }
-
- return io;
- }
- }
- }
-
- return null;
-
- }
-
- public void putIdentityObjectSearchIntoCache(IdentityObjectType identityType,
- IdentityObjectSearchCriteria criteria,
- Collection<IdentityObject>
results)
- {
- Fqn nodeFqn = createIOTypeSearchNodeFQN(identityType, getControlsHash(criteria));
-
- Node searchNode = getCache().getRoot().addChild(nodeFqn);
-
- searchNode.put(NODE_SEARCH_RESULTS_KEY, results);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject search results stored in
cache: type" + identityType.getName());
- }
- }
-
- public Collection<IdentityObject>
getIdentityObjectSearchFromCache(IdentityObjectType identityType,
-
IdentityObjectSearchCriteria criteria)
- {
- Fqn nodeFqn = createIOTypeSearchNodeFQN(identityType, getControlsHash(criteria));
-
- Node searchNode = getCache().getRoot().getChild(nodeFqn);
-
- Collection<IdentityObject> results = null;
-
- if (searchNode != null)
- {
-
-
- results =
(Collection<IdentityObject>)searchNode.get(NODE_SEARCH_RESULTS_KEY);
-
- if (results != null && getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject search results found in
cache: type" + identityType.getName());
- }
- }
-
- return results;
-
- }
-
- public void putIdentityObjectSearchToCache(IdentityObject identity,
- IdentityObjectRelationshipType
relationshipType,
- boolean parent,
- IdentityObjectSearchCriteria criteria,
- Collection<IdentityObject> results)
- {
-
- Fqn nodeFqn = createIOSearchNodeFQN(identity, relationshipType, parent,
getControlsHash(criteria));
-
- Node searchNode = getCache().getRoot().addChild(nodeFqn);
-
- searchNode.put(NODE_SEARCH_RESULTS_KEY, results);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject search results stored in
cache: IdentityObject name= " + identity.getName()
- + "; IdentityObject type= " + identity.getIdentityType().getName()
+ "; IdentityObjectRelationshipType= " + relationshipType +
- "; parent= " + parent);
- }
-
- }
-
- public Collection<IdentityObject>
getIdentityObjectSearchFromCache(IdentityObject identity,
-
IdentityObjectRelationshipType relationshipType,
- boolean parent,
-
IdentityObjectSearchCriteria criteria)
- {
-
- Fqn nodeFqn = createIOSearchNodeFQN(identity, relationshipType, parent,
getControlsHash(criteria));
-
- Node searchNode = getCache().getRoot().getChild(nodeFqn);
-
- Collection<IdentityObject> results = null;
-
- if (searchNode != null)
- {
- results =
(Collection<IdentityObject>)searchNode.get(NODE_SEARCH_RESULTS_KEY);
-
- if (results != null && getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject search results found in
cache: IdentityObject name= " + identity.getName()
- + "; IdentityObject type= " +
identity.getIdentityType().getName() + "; IdentityObjectRelationshipType= " +
relationshipType +
- "; parent= " + parent);
- }
- }
-
- return results;
-
- }
-
- public void putRelationshipsSearchIntoCache(IdentityObject fromIdentity,
- IdentityObject toIdentity,
- IdentityObjectRelationshipType
relationshipType,
- Set<IdentityObjectRelationship>
results)
- {
-
- Fqn fqn = createRelationshipsSimpleSearchFqn(fromIdentity, toIdentity,
relationshipType);
- Node node = getCache().getRoot().addChild(fqn);
-
- node.put(NODE_SEARCH_RESULTS_KEY, results);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationship search stored
in cache: fromIdentity" +
- fromIdentity.toString() + "; toIdentity=" + toIdentity.toString()
+
- "; relationshipType=" + relationshipType.getName() ) ;
- }
-
- }
-
-
-
- public Set<IdentityObjectRelationship>
getRelationshipsSearchFromCache(IdentityObject fromIdentity,
- IdentityObject
toIdentity,
-
IdentityObjectRelationshipType relationshipType)
- {
- Fqn fqn = createRelationshipsSimpleSearchFqn(fromIdentity, toIdentity,
relationshipType);
- Node node = getCache().getRoot().getChild(fqn);
-
- if (node != null)
- {
- if (node.getKeys().contains(NODE_SEARCH_RESULTS_KEY) &&
getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationship search
found in cache: fromIdentity" +
- fromIdentity.toString() + "; toIdentity=" +
toIdentity.toString() +
- "; relationshipType=" + relationshipType.getName() ) ;
- }
-
- return
(Set<IdentityObjectRelationship>)node.get(NODE_SEARCH_RESULTS_KEY);
- }
- return null;
- }
-
- public void putRelationshipSearchIntoCache(IdentityObject identity,
- IdentityObjectRelationshipType
relationshipType,
- boolean parent,
- boolean named,
- String name,
- Set<IdentityObjectRelationship>
results)
- {
- Fqn fqn = createRelationshipsComplexSearchFqn(identity, relationshipType, parent,
named, name);
- Node node = getCache().getRoot().addChild(fqn);
-
- node.put(NODE_SEARCH_RESULTS_KEY, results);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationship search stored
in cache: " +
- "identity" + identity.toString() +
- "; relationshipType=" + relationshipType.getName() +
- "; parent=" + parent +
- "; named=" + named +
- "; name=" + name) ;
- }
-
- }
-
-
-
- public Set<IdentityObjectRelationship>
getRelationshipsSearchFromCache(IdentityObject identity,
-
IdentityObjectRelationshipType relationshipType,
- boolean
parent,
- boolean
named,
- String name)
- {
- Fqn fqn = createRelationshipsComplexSearchFqn(identity, relationshipType, parent,
named, name);
- Node node = getCache().getRoot().getChild(fqn);
-
- Set<IdentityObjectRelationship> results = null;
-
- if (node != null)
- {
- results =
(Set<IdentityObjectRelationship>)node.get(NODE_SEARCH_RESULTS_KEY);
-
- if (results != null && getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationship search
found in cache: " +
- "identity" + identity.toString() +
- "; relationshipType=" + relationshipType.getName() +
- "; parent=" + parent +
- "; named=" + named +
- "; name=" + name) ;
- }
- }
- return results;
-
- }
-
- public void invalidateCachedIdentityObjectSearches(IdentityObject io)
- {
-
- Fqn fqn = Fqn.fromElements(OBJECT_TYPES_SEARCH_BY_TYPE_NODE,
io.getIdentityType().getName());
- getCache().getRoot().removeChild(fqn);
-
- // It can be in any result in the type searches
- removeNodeChildren(OBJECT_TYPES_SEARCH_NODE);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObject searches invalidated in
cache: identityObject=" + io.toString());
- }
- }
-
- public void putIdentityObjectCountIntoCache(IdentityObjectType identityType, int
count)
- {
- Fqn fqn = createIOTypeCountNodeFQN(identityType);
- Node node = getCache().getRoot().addChild(fqn);
-
- node.put(NODE_OBJECT_KEY, count);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectType count search strored
in cache: " +
- "identityObjectType=" + identityType.getName() +
- "; count=" + count);
- }
-
- }
-
- public int getIdentityObjectCountFromCache(IdentityObjectType identityType)
- {
- Fqn fqn = createIOTypeCountNodeFQN(identityType);
- Node node = getCache().getRoot().getChild(fqn);
-
-
- if (node != null && node.getKeys().contains(NODE_OBJECT_KEY))
- {
- int count = (Integer)(node.get(NODE_OBJECT_KEY));
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectType count search result
found in cache: " +
- "identityObjectType=" + identityType.getName() +
- "; count=" + count);
- }
-
- return count;
-
- }
- // -1 means nothing in cache
- return -1;
- }
-
-
- public void invalidateCachedIdentityObjectCount(IdentityObjectType identityType)
- {
- Fqn fqn = createIOTypeCountNodeFQN(identityType);
- Node node = getCache().getRoot().addChild(fqn);
-
- node.remove(NODE_OBJECT_KEY);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectType count search result
invalidated in cache: " +
- "identityObjectType=" + identityType.getName());
- }
- }
-
- public void invalidateCachedRelationshipSearches(IdentityObject fromIdentity,
- IdentityObject toIdentity,
- IdentityObjectRelationshipType
relationshipType,
- String relationshipName)
- {
- String fromName = fromIdentity.getIdentityType().getName() + "_" +
fromIdentity.getName();
- String toName = toIdentity.getIdentityType().getName() + "_" +
toIdentity.getName();
-
- // Simple
-
-// Fqn fqn = Fqn.fromElements(RELATIONSHIPS_SEARCH_SIMPLE_NODE, fromName, toName,
relationshipType.getName());
-// getCache().getRoot().removeChild(fqn);
-
- Fqn fqn = createRelationshipsSimpleSearchFqn(fromIdentity, toIdentity,
relationshipType);
- getCache().getRoot().removeChild(fqn);
-
- // Complex
-
- String relNameElement;
- if (relationshipName != null)
- {
- relNameElement = true + relationshipName;
- }
- else
- {
- relNameElement = false + relationshipName;
- }
-
-
- fqn = Fqn.fromElements(RELATIONSHIPS_SEARCH_COMPLEX_NODE, fromName, true,
relationshipType.getName(), relNameElement);
- getCache().getRoot().removeChild(fqn);
- fqn = Fqn.fromElements(RELATIONSHIPS_SEARCH_COMPLEX_NODE, toName, false,
relationshipType.getName(), relNameElement);
- getCache().getRoot().removeChild(fqn);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationship search result
invalidated in cache: fromIdentity" +
- fromIdentity.toString() + "; toIdentity=" + toIdentity.toString()
+
- "; relationshipType=" + relationshipType.getName() ) ;
- }
-
- }
-
- public void invalidateCachedRelationshipSearches(IdentityObject identity1,
IdentityObject identity2, boolean named)
- {
-
- String name1 = identity1.getIdentityType().getName() + "_" +
identity1.getName();
- String name2 = identity2.getIdentityType().getName() + "_" +
identity2.getName();
-
-
- // Complex search
-
- Fqn fqn = Fqn.fromElements(RELATIONSHIPS_SEARCH_COMPLEX_NODE, name1);
- getCache().getRoot().removeChild(fqn);
- fqn = Fqn.fromElements(RELATIONSHIPS_SEARCH_COMPLEX_NODE, name2);
- getCache().getRoot().removeChild(fqn);
-
- // Simple search
-
- getCache().getRoot().removeChild(Fqn.fromElements(RELATIONSHIPS_SEARCH_SIMPLE_NODE,
name1));
- getCache().getRoot().removeChild(Fqn.fromElements(RELATIONSHIPS_SEARCH_SIMPLE_NODE,
name2));
-
- fqn = Fqn.fromElements(RELATIONSHIPS_SEARCH_SIMPLE_NODE);
- Set<String> names = getCache().getRoot().getChildrenNames();
-
- for (String childName : names)
- {
- //
- getCache().getRoot().removeChild(Fqn.fromElements(fqn, childName, name1));
- getCache().getRoot().removeChild(Fqn.fromElements(fqn, childName, name2));
- }
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationship search result
invalidated in cache for: identity1" +
- identity1.toString() + "; identity2=" + identity2.toString() +
- "; named=" + named ) ;
- }
-
- }
-
- public void invalidateRelationshipNameSearches(String name)
- {
- //TODO: at the moment it just trash up all relationships searches
-
- removeNodeChildren(RELATIONSHIP_NAMES_SEARCH_ALL_NODE);
- removeNodeChildren(RELATIONSHIP_NAMES_SEARCH_IO_NODE);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationshipName search
results invalidated in cache: name" +
- name ) ;
- }
- }
-
-
-
- public void putRelationshipNamesSearchIntoCache(IdentityObjectSearchCriteria criteria,
Set<String> results)
- {
-
- Fqn fqn = createRelationshipNamesAllSearchFqn(getControlsHash(criteria));
-
- Node node = getCache().getRoot().addChild(fqn);
-
- node.put(NODE_SEARCH_RESULTS_KEY, results);
-
- if (getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationshipName search
results invalidated in cache: criteria hash=" +
- getControlsHash(criteria)) ;
- }
-
- }
-
- public Set<String>
getRelationshipNamesSearchFromCache(IdentityObjectSearchCriteria criteria)
- {
-
- Fqn fqn = createRelationshipNamesAllSearchFqn(getControlsHash(criteria));
-
- Node node = getCache().getRoot().getChild(fqn);
-
- if (node != null)
- {
- Set<String> results =
(Set<String>)node.get(NODE_SEARCH_RESULTS_KEY);
-
- if (results != null && getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationshipName search
result found in cache: criteria hash=" +
- getControlsHash(criteria)) ;
- }
-
- return results;
- }
-
-
- return null;
- }
-
- public void putRelationshipNamesSearchIntoCache(IdentityObject identity,
- IdentityObjectSearchCriteria
criteria,
- Set<String> results)
- {
-
- Fqn fqn = createRelationshipNamesIdentityObjectSearchFqn(identity,
getControlsHash(criteria));
-
- Node node = getCache().getRoot().addChild(fqn);
-
- node.put(NODE_SEARCH_RESULTS_KEY, results);
-
- if (results != null && getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationshipName search
result stored in cache: " +
- "criteria hash=" + getControlsHash(criteria) +
- "identity=" + identity.toString()) ;
- }
-
- }
-
- public Set<String> getRelationshipNamesSearchFromCache(IdentityObject identity,
IdentityObjectSearchCriteria criteria)
- {
-
-
- Fqn fqn = createRelationshipNamesIdentityObjectSearchFqn(identity,
getControlsHash(criteria));
-
- Node node = getCache().getRoot().getChild(fqn);
-
- if (node != null)
- {
- Set<String> results =
(Set<String>)node.get(NODE_SEARCH_RESULTS_KEY);
-
- if (results != null && getLog().isLoggable(Level.FINER))
- {
- getLog().finer(this.toString() + "IdentityObjectRelationshipName search
result found in cache: " +
- "criteria hash=" + getControlsHash(criteria) +
- "identity=" + identity.toString()) ;
- }
-
- return results;
- }
- return null;
- }
-
- private int getControlsHash(IdentityObjectSearchCriteria criteria)
- {
- // Convert criteria to Set to have the same hashcode regardles order of criteria
- int hashcode = 0;
-
- if (criteria != null)
- {
- hashcode = criteria.hashCode();
- }
-
- return hashcode;
- }
-}
Modified:
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 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAPICacheProviderImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -23,10 +23,12 @@
import org.jboss.identity.idm.cache.*;
import org.jboss.identity.idm.api.*;
+import org.jboss.identity.idm.api.cfg.IdentityConfigurationRegistry;
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.identity.idm.common.exception.IdentityException;
import org.jboss.cache.*;
import java.util.Map;
@@ -49,6 +51,12 @@
public static final String CONFIG_FILE_OPTION = "cache.configFile";
+ public static final String CONFIG_CACHE_REGISTRY_OPTION =
"cache.cacheRegistryName";
+
+ public static final String CACHE_PROVIDER_REGISTRY_NAME =
"cache.providerRegistryName";
+
+ public static final String CACHE_SCOPE = "cache.scope";
+
public static final String NODE_OBJECT_KEY = "object";
public static final String NODE_QUERY_KEY = "query";
@@ -57,6 +65,8 @@
public static final String NODE_MAIN_ROOT = "IDM_ROOT";
+ public static final String NODE_COMMON_ROOT = "COMMON_ROOT";
+
public static final String NODE_USERS = "USERS";
public static final String NODE_USERS_COUNT = "USERS_COUNT";
@@ -110,9 +120,27 @@
return Fqn.fromElements(getNamespacedFqn(ns), node);
}
- public void initialize(Map<String, String> properties)
+ public void initialize(Map<String, String> properties,
IdentityConfigurationRegistry configurationRegistry)
{
CacheFactory factory = new DefaultCacheFactory();
+
+ String registryName = properties.get(CONFIG_CACHE_REGISTRY_OPTION);
+
+ // Get cache from registry
+ if (registryName != null)
+ {
+ try
+ {
+ this.cache = (Cache)configurationRegistry.getObject(registryName);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("Cannot find JBoss Cache
'Cache' object in configuration registry with provided" +
+ "name: " + registryName);
+ }
+
+ return;
+ }
String config = properties.get(CONFIG_FILE_OPTION);
@@ -146,11 +174,19 @@
public String getNamespace(String realmId)
{
+ if (realmId == null)
+ {
+ return NODE_COMMON_ROOT;
+ }
return realmId;
}
public String getNamespace(String realmId, String sessionId)
{
+ if (sessionId == null)
+ {
+ return getNamespace(realmId);
+ }
return realmId + "/" + sessionId;
}
Copied:
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java
(from rev 906,
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheProviderImpl.java)
===================================================================
---
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java
(rev 0)
+++
idm/trunk/idm-cache/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -0,0 +1,575 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, 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.cache.*;
+import org.jboss.identity.idm.spi.model.IdentityObject;
+import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
+import org.jboss.identity.idm.spi.cache.IdentityStoreCacheProvider;
+import org.jboss.identity.idm.spi.cache.IdentityObjectSearch;
+import org.jboss.identity.idm.spi.cache.IdentityObjectRelationshipSearch;
+import org.jboss.identity.idm.spi.cache.IdentityObjectRelationshipNameSearch;
+import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
+import org.jboss.identity.idm.impl.types.SimpleIdentityObject;
+import org.jboss.identity.idm.impl.types.SimpleIdentityObjectType;
+import org.jboss.identity.idm.impl.types.SimpleIdentityObjectRelationship;
+import org.jboss.identity.idm.impl.types.SimpleIdentityObjectRelationshipType;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+
+import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.util.*;
+
+/**
+ * Helper class providing caching support for IdentityStore.
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class JBossCacheIdentityStoreCacheProviderImpl implements
IdentityStoreCacheProvider
+{
+ private static Logger log =
Logger.getLogger(JBossCacheIdentityStoreCacheProviderImpl.class.getName());
+
+
+ private Cache cache;
+
+ public static final String CONFIG_FILE_OPTION = "cache.configFile";
+
+ public static final String CONFIG_CACHE_REGISTRY_OPTION =
"cache.cacheRegistryName";
+
+ public static final String NODE_OBJECT_KEY = "object";
+
+ public static final String NODE_SEARCH_KEY = "search";
+
+ public static final String NODE_SEARCH_UNIQUE_KEY = "query_unique";
+
+ public static final String NODE_MAIN_ROOT = "IDM_ROOT";
+
+ public static final String NODE_COMMON_ROOT = "COMMON_ROOT";
+
+ public static final String NODE_IO_COUNT = "NODE_IO_COUNT";
+
+ public static final String NODE_IO_ATTRIBUTES = "NODE_IO_ATTRIBUTES";
+
+ public static final String NODE_REL_PROPS = "NODE_REL_PROPS";
+
+ public static final String NODE_REL_NAME_PROPS = "NODE_REL_NAME_PROPS";
+
+ public static final String NODE_IO_SEARCH = "NODE_IO_SEARCH";
+
+ public static final String NODE_IO_REL_SEARCH = "NODE_IO_REL_SEARCH";
+
+ public static final String NODE_IO_REL_NAME_SEARCH =
"NODE_IO_REL_NAME_SEARCH";
+
+ 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,
IdentityRepositoryConfigurationContext configurationContext)
+ {
+ CacheFactory factory = new DefaultCacheFactory();
+
+ String registryName = properties.get(CONFIG_CACHE_REGISTRY_OPTION);
+
+ // Get cache from registry
+ if (registryName != null)
+ {
+ try
+ {
+ this.cache =
(Cache)configurationContext.getConfigurationRegistry().getObject(registryName);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("Cannot find JBoss Cache
'Cache' object in configuration registry with provided" +
+ "name: " + registryName);
+ }
+
+ return;
+ }
+
+ 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));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating namespace:" + ns);
+ }
+ }
+
+ public String getNamespace(String storeId)
+ {
+ if (storeId == null)
+ {
+ return NODE_COMMON_ROOT;
+ }
+ return storeId;
+ }
+
+ public String getNamespace(String storeId, String sessionId)
+ {
+ if (sessionId == null)
+ {
+ return getNamespace(storeId);
+ }
+ return storeId + "/" + sessionId;
+ }
+
+ public String getNamespace(String storeId, String sessionId, String realmId)
+ {
+ if (realmId == null)
+ {
+ return getNamespace(sessionId);
+ }
+ return storeId + "/" + sessionId + "/" + realmId;
+ }
+
+ public void putIdentityObjectCount(String ns, String type, int count)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_IO_COUNT, type);
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, count);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "IdentityObject count stored in cache: " +
count + "; type=" + type);
+ }
+ }
+
+ public int getIdentityObjectCount(String ns, String type)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_IO_COUNT, type);
+
+ 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;
+ }
+
+ if (log.isLoggable(Level.FINER) && count != -1)
+ {
+ log.finer(this.toString() + "IdentityObject count found in cache: "
+ count + "; type=" + type);
+ }
+
+ return count;
+ }
+
+ return -1;
+ }
+
+ public void invalidateIdentityObjectCount(String ns, String type)
+ {
+ getCache().getRoot().removeChild(Fqn.fromElements(getNamespacedFqn(ns),
NODE_IO_COUNT, type));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating IdentityObject count.
Namespace:" + ns + "; type=" + type);
+ }
+ }
+
+ public void putIdentityObjectSearch(String ns, IdentityObjectSearch search,
Collection<IdentityObject> results)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_IO_SEARCH, search.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, safeCopyIO(results));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "IdentityObject search stored in cache:
results.size()=" + results.size());
+ }
+ }
+
+ public Collection<IdentityObject> getIdentityObjectSearch(String ns,
IdentityObjectSearch search)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_IO_SEARCH, search.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Collection<IdentityObject> results =
(Collection<IdentityObject>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER) && results != null)
+ {
+ log.finer(this.toString() + "IdentityObject search found in cache:
results.size()=" + results.size());
+ }
+
+ return results;
+ }
+
+ return null;
+ }
+
+ public void invalidateIdentityObjectSearches(String ns)
+ {
+ getCache().getRoot().removeChild(getFqn(ns, NODE_IO_SEARCH));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating IdentityObject searches.
Namespace:" + ns);
+ }
+ }
+
+ public void putIdentityObjectRelationshipSearch(String ns,
IdentityObjectRelationshipSearch search, Set<IdentityObjectRelationship> results)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_IO_REL_SEARCH, search.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, safeCopyIOR(results));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "IdentityObjectRelationship search stored in
cache: results.size()=" + results.size());
+ }
+ }
+
+ public Set<IdentityObjectRelationship>
getIdentityObjectRelationshipSearch(String ns, IdentityObjectRelationshipSearch search)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_IO_REL_SEARCH, search.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Set<IdentityObjectRelationship> results =
(Set<IdentityObjectRelationship>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER) && results != null)
+ {
+ log.finer(this.toString() + "IdentityObjectRelationship search found in
cache: results.size()=" + results.size());
+ }
+
+ return results;
+ }
+
+ return null;
+ }
+
+ public void invalidateIdentityObjectRelationshipSearches(String ns)
+ {
+ getCache().getRoot().removeChild(getFqn(ns, NODE_IO_REL_SEARCH));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating IdentityObjectRelationship
searches. Namespace:" + ns);
+ }
+ }
+
+ public void putIdentityObjectRelationshipNameSearch(String ns,
IdentityObjectRelationshipNameSearch search, Set<String> results)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_IO_REL_NAME_SEARCH, search.hashCode());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, results);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "IdentityObjectRelationshipName search stored
in cache: results.size()=" + results.size());
+ }
+ }
+
+ public Set<String> getIdentityObjectRelationshipNameSearch(String ns,
IdentityObjectRelationshipNameSearch search)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_IO_REL_NAME_SEARCH, search.hashCode());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Set<String> results = (Set<String>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER) && results != null)
+ {
+ log.finer(this.toString() + "IdentityObjectRelationshipName search found
in cache: results.size()=" + results.size());
+ }
+
+ return results;
+ }
+
+ return null;
+ }
+
+ public void invalidateIdentityObjectRelationshipNameSearches(String ns)
+ {
+ getCache().getRoot().removeChild(getFqn(ns, NODE_IO_REL_NAME_SEARCH));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating IdentityObjectRelationshipName
searches. Namespace:" + ns);
+ }
+ }
+
+ public void putProperties(String ns, IdentityObjectRelationship relationship,
Map<String, String> properties)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_REL_PROPS, decode(relationship));
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, properties);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "IdentityObjectRelationship properties stored
in cache: relationship=" + relationship + "; properties.size()=" +
properties.size());
+ }
+ }
+
+ private String decode(IdentityObjectRelationship r)
+ {
+ return r.getFromIdentityObject().getIdentityType().getName() +
+ r.getFromIdentityObject().getName() +
+ r.getToIdentityObject().getIdentityType().getName() +
+ r.getToIdentityObject().getName() +
+ r.getType().getName();
+ }
+
+ public Map<String, String> getProperties(String ns, IdentityObjectRelationship
relationship)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_REL_PROPS, decode(relationship));
+
+ 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) && props != null)
+ {
+ log.finer(this.toString() + "IdentityObjectRelationship properties found
in cache: properties.size()=" + props.size() +
+ "; relationship=" + relationship);
+ }
+
+ return props;
+ }
+
+ return null;
+ }
+
+ public void invalidateRelationshipProperties(String ns, IdentityObjectRelationship
relationship)
+ {
+ getCache().getRoot().removeChild(getFqn(ns, NODE_REL_PROPS,
decode(relationship)));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating IdentityObjectRelationship
properties. Namespace:" + ns + "; relationship=" + relationship);
+ }
+ }
+
+ public void invalidateRelationshipProperties(String ns)
+ {
+ getCache().getRoot().removeChild(getFqn(ns, NODE_REL_PROPS));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating IdentityObjectRelationship
properties. Namespace:" + ns);
+ }
+ }
+
+ public void putProperties(String ns, String name, Map<String, String>
properties)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_REL_NAME_PROPS, name);
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, properties);
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "IdentityObjectRelationshipName properties
stored in cache: name=" + name + "; properties.size()=" +
properties.size());
+ }
+ }
+
+ public Map<String, String> getProperties(String ns, String name)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_REL_NAME_PROPS, name);
+
+ 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) && props != null)
+ {
+ log.finer(this.toString() + "IdentityObjectRelationshipName properties
found in cache: properties.size()=" + props.size() +
+ "; name=" + name);
+ }
+
+ return props;
+ }
+
+ return null;
+ }
+
+ public void invalidateRelationshipNameProperties(String ns, String relationship)
+ {
+ getCache().getRoot().removeChild(getFqn(ns, NODE_REL_NAME_PROPS, relationship));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating IdentityObjectRelationshipName
properties. Namespace:" + ns + "; name=" + relationship);
+ }
+ }
+
+ public void invalidateRelationshipNameProperties(String ns)
+ {
+ getCache().getRoot().removeChild(getFqn(ns, NODE_REL_NAME_PROPS));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating IdentityObjectRelationshipName
properties. Namespace:" + ns);
+ }
+
+ }
+
+ public void putIdentityObjectAttributes(String ns, IdentityObject io, Map<String,
IdentityObjectAttribute> attributes)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_IO_ATTRIBUTES, io.getIdentityType().getName() +
io.getName());
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ ioNode.put(NODE_OBJECT_KEY, safeCopyAttr(attributes));
+
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "IdentityObject attributes stored in cache:
io=" + io + "; attributes.size()=" + attributes.size());
+ }
+ }
+
+ public Map<String, IdentityObjectAttribute> getIdentityObjectAttributes(String
ns, IdentityObject io)
+ {
+ Fqn nodeFqn = getFqn(ns, NODE_IO_ATTRIBUTES, io.getIdentityType().getName() +
io.getName());
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ Map<String, IdentityObjectAttribute> props = (Map<String,
IdentityObjectAttribute>)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER) && props != null)
+ {
+ log.finer(this.toString() + "IIdentityObject attributes found in cache:
attributes.size()=" + props.size() +
+ "; io=" + io);
+ }
+
+ return props;
+ }
+
+ return null;
+ }
+
+ public void invalidateIdentityObjectAttriubtes(String ns, IdentityObject io)
+ {
+ getCache().getRoot().removeChild(getFqn(ns, NODE_IO_ATTRIBUTES,
io.getIdentityType().getName() + io.getName()));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating IdentityObject attributes.
Namespace:" + ns + "; io=" + io);
+ }
+ }
+
+ public void invalidateIdentityObjectAttriubtes(String ns)
+ {
+ getCache().getRoot().removeChild(getFqn(ns, NODE_IO_ATTRIBUTES));
+ if (log.isLoggable(Level.FINER))
+ {
+ log.finer(this.toString() + "Invalidating IdentityObject attributes.
Namespace:" + ns);
+ }
+ }
+
+ private List<IdentityObject> safeCopyIO(Collection<IdentityObject> res)
+ {
+ List<IdentityObject> nr = new LinkedList<IdentityObject>();
+
+ for (IdentityObject io : res)
+ {
+ nr.add(new SimpleIdentityObject(io.getName(),
+ new SimpleIdentityObjectType(io.getIdentityType().getName())));
+ }
+
+ return nr;
+ }
+
+ private Set<IdentityObjectRelationship>
safeCopyIOR(Set<IdentityObjectRelationship> res)
+ {
+ Set<IdentityObjectRelationship> nr = new
HashSet<IdentityObjectRelationship>();
+
+ for (IdentityObjectRelationship ior : res)
+ {
+ IdentityObject from = new
SimpleIdentityObject(ior.getFromIdentityObject().getName(),
+ new
SimpleIdentityObjectType(ior.getFromIdentityObject().getIdentityType().getName()));
+ IdentityObject to = new
SimpleIdentityObject(ior.getToIdentityObject().getName(),
+ new
SimpleIdentityObjectType(ior.getToIdentityObject().getIdentityType().getName()));
+
+ nr.add(new SimpleIdentityObjectRelationship(from, to, ior.getName(), new
SimpleIdentityObjectRelationshipType(ior.getType().getName())));
+ }
+
+ return nr;
+ }
+
+ private Map<String, IdentityObjectAttribute> safeCopyAttr(Map<String,
IdentityObjectAttribute> res)
+ {
+ Map<String, IdentityObjectAttribute> nr = new HashMap<String,
IdentityObjectAttribute>();
+
+ for (IdentityObjectAttribute attr : res.values())
+ {
+ nr.put(attr.getName(), new SimpleAttribute(attr));
+ }
+
+ return nr;
+ }
+
+
+}
Modified:
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 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-cache/src/test/java/org/jboss/identity/idm/cache/APICacheProviderTestCase.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -40,7 +40,7 @@
Map<String, String> props = new HashMap<String, String>();
props.put(JBossCacheAPICacheProviderImpl.CONFIG_FILE_OPTION,
"jboss-cache.xml");
APICacheProvider cache = new JBossCacheAPICacheProviderImpl();
- cache.initialize(props);
+ cache.initialize(props, null);
String ns = "toto";
@@ -65,9 +65,6 @@
assertNull(cache.getUser(ns, "u2"));
assertNull(cache.getUser(ns, "u3"));
-
-
-
}
}
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-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/IdentitySearchCriteriaImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -62,6 +62,75 @@
private int firstResult;
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ IdentitySearchCriteriaImpl that = (IdentitySearchCriteriaImpl)o;
+
+ if (ascending != that.ascending)
+ {
+ return false;
+ }
+ if (filtered != that.filtered)
+ {
+ return false;
+ }
+ if (firstResult != that.firstResult)
+ {
+ return false;
+ }
+ if (maxResults != that.maxResults)
+ {
+ return false;
+ }
+ if (paged != that.paged)
+ {
+ return false;
+ }
+ if (sorted != that.sorted)
+ {
+ return false;
+ }
+ if (attributes != null ? !attributes.equals(that.attributes) : that.attributes !=
null)
+ {
+ return false;
+ }
+ if (filter != null ? !filter.equals(that.filter) : that.filter != null)
+ {
+ return false;
+ }
+ if (sortByName != null ? !sortByName.equals(that.sortByName) : that.sortByName !=
null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = (sorted ? 1 : 0);
+ result = 31 * result + (sortByName != null ? sortByName.hashCode() : 0);
+ result = 31 * result + (ascending ? 1 : 0);
+ result = 31 * result + (paged ? 1 : 0);
+ result = 31 * result + firstResult;
+ result = 31 * result + maxResults;
+ result = 31 * result + (filtered ? 1 : 0);
+ result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
+ result = 31 * result + (filter != null ? filter.hashCode() : 0);
+ return result;
+ }
+
private int maxResults;
private boolean filtered = false;
@@ -186,76 +255,7 @@
return attributes;
}
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
- IdentitySearchCriteriaImpl that = (IdentitySearchCriteriaImpl)o;
-
- if (ascending != that.ascending)
- {
- return false;
- }
- if (filtered != that.filtered)
- {
- return false;
- }
- if (firstResult != that.firstResult)
- {
- return false;
- }
- if (maxResults != that.maxResults)
- {
- return false;
- }
- if (paged != that.paged)
- {
- return false;
- }
- if (sorted != that.sorted)
- {
- return false;
- }
- if (!attributes.equals(that.attributes))
- {
- return false;
- }
- if (filter != null ? !filter.equals(that.filter) : that.filter != null)
- {
- return false;
- }
- if (sortByName != null ? !sortByName.equals(that.sortByName) : that.sortByName !=
null)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = (sorted ? 1 : 0);
- result = 31 * result + (sortByName != null ? sortByName.hashCode() : 0);
- result = 31 * result + (ascending ? 1 : 0);
- result = 31 * result + (paged ? 1 : 0);
- result = 31 * result + firstResult;
- result = 31 * result + maxResults;
- result = 31 * result + (filtered ? 1 : 0);
- result = 31 * result + attributes.hashCode();
- result = 31 * result + (filter != null ? filter.hashCode() : 0);
- return result;
- }
-
-
// Static helper methods:
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-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/IdentitySessionFactoryImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -75,7 +75,11 @@
IdentitySession newSession =
new IdentitySessionImpl(sessionConfigCtx.getRealmName(),
- sessionConfigCtx.getRepository(), sessionConfigCtx.getTypeMapper(),
sessionConfigCtx.getApiCacheProvider());
+ sessionConfigCtx.getRepository(),
+ sessionConfigCtx.getTypeMapper(),
+ sessionConfigCtx.getApiCacheProvider(),
+ sessionConfigCtx.getIdentityConfigurationContext(),
+ sessionConfigCtx.getRealmOptions());
realmMap.put(realmName, newSession);
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-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -26,6 +26,7 @@
import java.util.Collection;
import java.util.List;
import java.util.LinkedList;
+import java.util.Map;
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.Transaction;
@@ -49,6 +50,7 @@
import org.jboss.identity.idm.spi.store.IdentityStoreSession;
import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContext;
import org.jboss.identity.idm.impl.store.SimpleIdentityStoreInvocationContext;
import org.jboss.identity.idm.impl.api.session.context.IdentitySessionContext;
import org.jboss.identity.idm.impl.api.session.context.IdentitySessionContextImpl;
@@ -111,12 +113,14 @@
public IdentitySessionImpl(String realmName,
IdentityStoreRepository repository,
IdentityObjectTypeMapper typeMapper,
- APICacheProvider apiCacheProvider) throws
IdentityException
+ APICacheProvider apiCacheProvider,
+ IdentityConfigurationContext configurationContext,
+ Map<String, List<String>> realmOptions) throws
IdentityException
{
this.realmName = realmName;
IdentityStoreSession storeSession = repository.createIdentityStoreSession();
- final IdentityStoreInvocationContext invocationCtx = new
SimpleIdentityStoreInvocationContext(storeSession, realmName);
+ final IdentityStoreInvocationContext invocationCtx = new
SimpleIdentityStoreInvocationContext(storeSession, realmName,
String.valueOf(this.hashCode()));
IdentityStoreInvocationContextResolver resolver = new
IdentityStoreInvocationContextResolver()
{
@@ -138,9 +142,21 @@
this.apiCacheProvider = apiCacheProvider;
+
+
if (apiCacheProvider != null)
{
- cacheNS = apiCacheProvider.getNamespace(realmName);
+ // Find cache scope
+ List<String> cacheScope = realmOptions.get("cache.scope");
+
+ if (cacheScope != null && cacheScope.size() > 1 &&
cacheScope.get(0).equals("session"))
+ {
+ cacheNS = apiCacheProvider.getNamespace(realmName,
String.valueOf(this.hashCode()));
+ }
+ else
+ {
+ cacheNS = apiCacheProvider.getNamespace(realmName);
+ }
}
else
{
@@ -149,10 +165,12 @@
}
+ public String getId()
+ {
+ return String.valueOf(this.hashCode());
+ }
-
-
public String getRealmName()
{
return realmName;
Added:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/AbstractSPISearchImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/AbstractSPISearchImpl.java
(rev 0)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/AbstractSPISearchImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -0,0 +1,42 @@
+/*
+* 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.spi.cache.Search;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchCriteria;
+
+public class AbstractSPISearchImpl implements Search
+{
+ private IdentityObjectSearchCriteria identityObjectSearchCriteria;
+
+ public IdentityObjectSearchCriteria getIdentityObjectSearchCriteria()
+ {
+ return identityObjectSearchCriteria;
+ }
+
+ public void setIdentityObjectSearchCriteria(IdentityObjectSearchCriteria
identityObjectSearchCriteria)
+ {
+ this.identityObjectSearchCriteria = identityObjectSearchCriteria;
+ }
+}
Added:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectRelationshipNameSearchImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectRelationshipNameSearchImpl.java
(rev 0)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectRelationshipNameSearchImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -0,0 +1,88 @@
+/*
+* 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.spi.cache.IdentityObjectRelationshipNameSearch;
+
+public class IdentityObjectRelationshipNameSearchImpl extends AbstractSPISearchImpl
implements IdentityObjectRelationshipNameSearch
+{
+
+ private String ioName;
+
+ private String ioType;
+
+ public String getIoName()
+ {
+ return ioName;
+ }
+
+ public void setIoName(String ioName)
+ {
+ this.ioName = ioName;
+ }
+
+ public String getIoType()
+ {
+ return ioType;
+ }
+
+ public void setIoType(String ioType)
+ {
+ this.ioType = ioType;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ IdentityObjectRelationshipNameSearchImpl that =
(IdentityObjectRelationshipNameSearchImpl)o;
+
+ if (ioName != null ? !ioName.equals(that.ioName) : that.ioName != null)
+ {
+ return false;
+ }
+ if (ioType != null ? !ioType.equals(that.ioType) : that.ioType != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = ioName != null ? ioName.hashCode() : 0;
+ result = 31 * result + (ioType != null ? ioType.hashCode() : 0);
+ return result;
+ }
+}
Added:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectRelationshipSearchImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectRelationshipSearchImpl.java
(rev 0)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectRelationshipSearchImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -0,0 +1,209 @@
+/*
+* 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.spi.cache.IdentityObjectRelationshipSearch;
+
+public class IdentityObjectRelationshipSearchImpl extends AbstractSPISearchImpl
implements IdentityObjectRelationshipSearch
+{
+
+ private String fromIOName;
+
+ private String fromIOType;
+
+ private String toIOName;
+
+ private String toIOType;
+
+ private String relationshipType;
+
+ private String ioName;
+
+ private String ioType;
+
+ private boolean parent;
+
+ private boolean named;
+
+ private String name;
+
+ public String getFromIOName()
+ {
+ return fromIOName;
+ }
+
+ public void setFromIOName(String fromIOName)
+ {
+ this.fromIOName = fromIOName;
+ }
+
+ public String getFromIOType()
+ {
+ return fromIOType;
+ }
+
+ public void setFromIOType(String fromIOType)
+ {
+ this.fromIOType = fromIOType;
+ }
+
+ public String getToIOName()
+ {
+ return toIOName;
+ }
+
+ public void setToIOName(String toIOName)
+ {
+ this.toIOName = toIOName;
+ }
+
+ public String getToIOType()
+ {
+ return toIOType;
+ }
+
+ public void setToIOType(String toIOType)
+ {
+ this.toIOType = toIOType;
+ }
+
+ public String getRelationshipType()
+ {
+ return relationshipType;
+ }
+
+ public void setRelationshipType(String relationshipType)
+ {
+ this.relationshipType = relationshipType;
+ }
+
+ public String getIoName()
+ {
+ return ioName;
+ }
+
+ public void setIoName(String ioName)
+ {
+ this.ioName = ioName;
+ }
+
+ public String getIoType()
+ {
+ return ioType;
+ }
+
+ public void setIoType(String ioType)
+ {
+ this.ioType = ioType;
+ }
+
+ public boolean isParent()
+ {
+ return parent;
+ }
+
+ public void setParent(boolean parent)
+ {
+ this.parent = parent;
+ }
+
+ public boolean isNamed()
+ {
+ return named;
+ }
+
+ public void setNamed(boolean named)
+ {
+ this.named = named;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ IdentityObjectRelationshipSearchImpl that =
(IdentityObjectRelationshipSearchImpl)o;
+
+ if (named != that.named)
+ {
+ return false;
+ }
+ if (parent != that.parent)
+ {
+ return false;
+ }
+ if (fromIOName != null ? !fromIOName.equals(that.fromIOName) : that.fromIOName !=
null)
+ {
+ return false;
+ }
+ if (fromIOType != null ? !fromIOType.equals(that.fromIOType) : that.fromIOType !=
null)
+ {
+ return false;
+ }
+ if (ioName != null ? !ioName.equals(that.ioName) : that.ioName != null)
+ {
+ return false;
+ }
+ if (ioType != null ? !ioType.equals(that.ioType) : that.ioType != null)
+ {
+ return false;
+ }
+ if (name != null ? !name.equals(that.name) : that.name != null)
+ {
+ return false;
+ }
+ if (relationshipType != null ? !relationshipType.equals(that.relationshipType) :
that.relationshipType != null)
+ {
+ return false;
+ }
+ if (toIOName != null ? !toIOName.equals(that.toIOName) : that.toIOName != null)
+ {
+ return false;
+ }
+ if (toIOType != null ? !toIOType.equals(that.toIOType) : that.toIOType != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+}
Added:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectSearchImpl.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectSearchImpl.java
(rev 0)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/IdentityObjectSearchImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -0,0 +1,172 @@
+/*
+* 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.spi.cache.IdentityObjectSearch;
+
+public class IdentityObjectSearchImpl extends AbstractSPISearchImpl implements
IdentityObjectSearch
+{
+ private String id;
+
+ private String name;
+
+ private String type;
+
+ private String relationshipType;
+
+ private String relatedIOName;
+
+ private String relatedIOType;
+
+ private boolean parent;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public String getRelatedIOName()
+ {
+ return relatedIOName;
+ }
+
+ public void setRelatedIOName(String relatedIOName)
+ {
+ this.relatedIOName = relatedIOName;
+ }
+
+ public String getRelatedIOType()
+ {
+ return relatedIOType;
+ }
+
+ public void setRelatedIOType(String relatedIOType)
+ {
+ this.relatedIOType = relatedIOType;
+ }
+
+ public boolean isParent()
+ {
+ return parent;
+ }
+
+ public void setParent(boolean parent)
+ {
+ this.parent = parent;
+ }
+
+ public String getRelationshipType()
+ {
+ return relationshipType;
+ }
+
+ public void setRelationshipType(String relationshipType)
+ {
+ this.relationshipType = relationshipType;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ IdentityObjectSearchImpl that = (IdentityObjectSearchImpl)o;
+
+ if (parent != that.parent)
+ {
+ return false;
+ }
+ if (id != null ? !id.equals(that.id) : that.id != null)
+ {
+ return false;
+ }
+ if (name != null ? !name.equals(that.name) : that.name != null)
+ {
+ return false;
+ }
+ if (relatedIOName != null ? !relatedIOName.equals(that.relatedIOName) :
that.relatedIOName != null)
+ {
+ return false;
+ }
+ if (relatedIOType != null ? !relatedIOType.equals(that.relatedIOType) :
that.relatedIOType != null)
+ {
+ return false;
+ }
+ if (relationshipType != null ? !relationshipType.equals(that.relationshipType) :
that.relationshipType != null)
+ {
+ return false;
+ }
+ if (type != null ? !type.equals(that.type) : that.type != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (name != null ? name.hashCode() : 0);
+ result = 31 * result + (type != null ? type.hashCode() : 0);
+ result = 31 * result + (relationshipType != null ? relationshipType.hashCode() :
0);
+ result = 31 * result + (relatedIOName != null ? relatedIOName.hashCode() : 0);
+ result = 31 * result + (relatedIOType != null ? relatedIOType.hashCode() : 0);
+ result = 31 * result + (parent ? 1 : 0);
+ return result;
+ }
+}
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAttributeStoreWrapper.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAttributeStoreWrapper.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheAttributeStoreWrapper.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -49,18 +49,31 @@
protected final IdentityStoreCacheProvider cacheSupport;
- // if update/add/remove operation on attributes should result in getAttributes() query
to store new set in cache
- // with many updates it can add additional cost
- private boolean reloadAttributesToCacheOnUpdate = true;
+ protected final String cacheScope;
-
- public JBossCacheAttributeStoreWrapper(AttributeStore attributeStore,
IdentityStoreCacheProvider cacheSupport)
+ public JBossCacheAttributeStoreWrapper(AttributeStore attributeStore,
IdentityStoreCacheProvider cacheSupport, String cacheScope)
{
- //cacheSupport = new IdentityStoreCacheSupportImpl(cacheConfigInputStream);
this.cacheSupport = cacheSupport;
this.attributeStore = attributeStore;
+ this.cacheScope = cacheScope;
}
+ protected String getCacheNS(IdentityStoreInvocationContext ctx)
+ {
+
+ if (cacheScope != null && cacheScope.equals("realm"))
+ {
+ return cacheSupport.getNamespace(attributeStore.getId(), ctx.getRealmId());
+ }
+ if (cacheScope != null && cacheScope.equals("session"))
+ {
+ return cacheSupport.getNamespace(attributeStore.getId(), ctx.getRealmId(),
ctx.getSessionId());
+ }
+
+ return cacheSupport.getNamespace(attributeStore.getId());
+
+ }
+
public String getId()
{
return attributeStore.getId();
@@ -88,19 +101,18 @@
public Map<String, IdentityObjectAttribute>
getAttributes(IdentityStoreInvocationContext invocationContext,
IdentityObject identity)
throws IdentityException
{
- Map<String, IdentityObjectAttribute> results =
cacheSupport.getAttributesFromCache(identity.getName(), identity.getIdentityType());
- if (results == null)
+ Map<String, IdentityObjectAttribute> results =
cacheSupport.getIdentityObjectAttributes(getCacheNS(invocationContext), identity);
+ if (results != null)
{
- results = attributeStore.getAttributes(invocationContext, identity);
-
- if (results != null && results.size() > 0)
- {
- //TODO:FIXME
-// cacheSupport.putIntoCache(identity, results);
- }
+ return results;
}
+ results = attributeStore.getAttributes(invocationContext, identity);
+
+ cacheSupport.putIdentityObjectAttributes(getCacheNS(invocationContext), identity,
results);
+
+
return results;
}
@@ -108,18 +120,22 @@
IdentityObject identity,
String name) throws IdentityException
{
- Map<String, IdentityObjectAttribute> results =
cacheSupport.getAttributesFromCache(identity.getName(), identity.getIdentityType());
+ Map<String, IdentityObjectAttribute> results =
cacheSupport.getIdentityObjectAttributes(getCacheNS(invocationContext), identity);
if (results != null && results.containsKey(name))
{
return results.get(name);
}
- else
- {
- return attributeStore.getAttribute(invocationContext, identity, name);
- //TODO: add this attribute to the node map
+ IdentityObjectAttribute result = attributeStore.getAttribute(invocationContext,
identity, name);
+
+ // Put fresh attributes in cache
+ if (result != null)
+ {
+ cacheSupport.invalidateIdentityObjectAttriubtes(getCacheNS(invocationContext),
identity);
+ cacheSupport.putIdentityObjectAttributes(getCacheNS(invocationContext),
identity, attributeStore.getAttributes(invocationContext, identity));
}
+ return result;
}
@@ -129,23 +145,8 @@
{
attributeStore.updateAttributes(invocationCtx, identity, attributes);
- cacheSupport.removeAttributesFromCache(identity);
-
- if (reloadAttributesToCacheOnUpdate)
- {
- Map<String, IdentityObjectAttribute> results =
attributeStore.getAttributes(invocationCtx, identity);
-
- if (results != null && results.size() > 0)
- {
- //TODO:FIXME
-// cacheSupport.putIntoCache(identity, results);
- }
- }
- else
- {
- // update attributes in node map directly
- }
-
+ cacheSupport.invalidateIdentityObjectAttriubtes(getCacheNS(invocationCtx),
identity);
+ cacheSupport.putIdentityObjectAttributes(getCacheNS(invocationCtx), identity,
attributeStore.getAttributes(invocationCtx, identity));
}
public void addAttributes(IdentityStoreInvocationContext invocationCtx,
@@ -154,22 +155,8 @@
{
attributeStore.addAttributes(invocationCtx, identity, attributes);
- cacheSupport.removeAttributesFromCache(identity);
-
- if (reloadAttributesToCacheOnUpdate)
- {
- Map<String, IdentityObjectAttribute> results =
attributeStore.getAttributes(invocationCtx, identity);
-
- if (results != null && results.size() > 0)
- {
- //TODO:FIXME
-// cacheSupport.putIntoCache(identity, results);
- }
- }
- else
- {
- // add attributes in node map directly
- }
+ cacheSupport.invalidateIdentityObjectAttriubtes(getCacheNS(invocationCtx),
identity);
+ cacheSupport.putIdentityObjectAttributes(getCacheNS(invocationCtx), identity,
attributeStore.getAttributes(invocationCtx, identity));
}
public void removeAttributes(IdentityStoreInvocationContext invocationCtx,
@@ -178,24 +165,11 @@
{
attributeStore.removeAttributes(invocationCtx, identity, attributeNames);
- cacheSupport.removeAttributesFromCache(identity);
-
- if (reloadAttributesToCacheOnUpdate)
- {
- Map<String, IdentityObjectAttribute> results =
attributeStore.getAttributes(invocationCtx, identity);
-
- if (results != null && results.size() > 0)
- {
- cacheSupport.putIntoCache(identity, results);
- }
- }
- else
- {
- // remove attributes in node map directly
- }
+ cacheSupport.invalidateIdentityObjectAttriubtes(getCacheNS(invocationCtx),
identity);
+ cacheSupport.putIdentityObjectAttributes(getCacheNS(invocationCtx), identity,
attributeStore.getAttributes(invocationCtx, identity));
}
- //TODO:
+ //TODO: cache
public IdentityObject
findIdentityObjectByUniqueAttribute(IdentityStoreInvocationContext invocationCtx,
IdentityObjectType identityObjectType, IdentityObjectAttribute attribute) throws
IdentityException
{
return attributeStore.findIdentityObjectByUniqueAttribute(invocationCtx,
identityObjectType, attribute);
@@ -207,11 +181,6 @@
return log;
}
-// protected Cache getCache()
-// {
-// return cache;
-// }
-
@Override
public String toString()
{
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -35,10 +35,12 @@
import org.jboss.identity.idm.spi.search.IdentityObjectSearchCriteria;
import org.jboss.identity.idm.spi.cache.IdentityStoreCacheProvider;
import org.jboss.identity.idm.common.exception.IdentityException;
+import org.jboss.identity.idm.impl.types.SimpleIdentityObjectRelationship;
import java.util.Map;
import java.util.Collection;
import java.util.Set;
+import java.util.HashSet;
import java.util.logging.Logger;
/**
@@ -57,20 +59,15 @@
private final IdentityStore identityStore;
- public JBossCacheIdentityStoreWrapper(IdentityStore identityStore,
IdentityStoreCacheProvider cacheSupport) throws IdentityException
+ public JBossCacheIdentityStoreWrapper(IdentityStore identityStore,
IdentityStoreCacheProvider cacheSupport, String cacheNS) throws IdentityException
{
- super(identityStore, cacheSupport);
+ super(identityStore, cacheSupport, cacheNS);
this.identityStore = identityStore;
-
-
-
cacheSupport.initResidentNodes(identityStore.getSupportedFeatures().getSupportedIdentityObjectTypes(),
- identityStore.getSupportedFeatures().getSupportedRelationshipTypes());
-
log.fine("------------------------------------------------------");
log.fine("JBossCacheIdentityStoreWrapper created ....." +
- "(IdentityStore: " + identityStore.getId() + ")");
+ "(IdentityStore: " + identityStore.getId() + "; cache namespace:
" + cacheNS + ")");
log.fine("------------------------------------------------------");
}
@@ -93,15 +90,19 @@
String name,
IdentityObjectType identityObjectType)
throws IdentityException
{
+
+
IdentityObject io = identityStore.createIdentityObject(invocationCtx, name,
identityObjectType);
+
+
if (io != null)
{
- //should also invalidate IO searches cache - searches/type - clear all children
- cacheSupport.invalidateCachedIdentityObjectSearches(io);
- cacheSupport.invalidateCachedIdentityObjectCount(identityObjectType);
+
cacheSupport.invalidateIdentityObjectRelationshipNameSearches(getCacheNS(invocationCtx));
+
cacheSupport.invalidateIdentityObjectRelationshipSearches(getCacheNS(invocationCtx));
+ cacheSupport.invalidateIdentityObjectSearches(getCacheNS(invocationCtx));
+ cacheSupport.invalidateIdentityObjectCount(getCacheNS(invocationCtx),
identityObjectType.getName());
- cacheSupport.putIntoCache(io);
}
return io;
}
@@ -115,16 +116,15 @@
{
IdentityObject io = identityStore.createIdentityObject(invocationCtx, name,
identityObjectType, attributes);
-
-
if (io != null)
{
- //should also invalidate IO searches cache - searches/type - clear all children
- cacheSupport.invalidateCachedIdentityObjectSearches(io);
- //grab profile - because IS can add extra attributes we canno rely only on
attributes passed
+
cacheSupport.invalidateIdentityObjectRelationshipNameSearches(getCacheNS(invocationCtx));
+
cacheSupport.invalidateIdentityObjectRelationshipSearches(getCacheNS(invocationCtx));
+ cacheSupport.invalidateIdentityObjectSearches(getCacheNS(invocationCtx));
+ cacheSupport.invalidateIdentityObjectCount(getCacheNS(invocationCtx),
identityObjectType.getName());
- cacheSupport.putIntoCache(io, identityStore.getAttributes(invocationCtx, io));
+
}
return io;
}
@@ -134,56 +134,81 @@
{
identityStore.removeIdentityObject(invocationCtx, identity);
- cacheSupport.removeFromCache(identity);
+
cacheSupport.invalidateIdentityObjectRelationshipNameSearches(getCacheNS(invocationCtx));
+
cacheSupport.invalidateIdentityObjectRelationshipSearches(getCacheNS(invocationCtx));
+ cacheSupport.invalidateIdentityObjectSearches(getCacheNS(invocationCtx));
+ cacheSupport.invalidateIdentityObjectAttriubtes(getCacheNS(invocationCtx),
identity);
+ cacheSupport.invalidateIdentityObjectCount(getCacheNS(invocationCtx),
identity.getIdentityType().getName());
- cacheSupport.invalidateCachedIdentityObjectSearches(identity);
- cacheSupport.invalidateCachedIdentityObjectCount(identity.getIdentityType());
}
public int getIdentityObjectsCount(IdentityStoreInvocationContext invocationCtx,
IdentityObjectType identityType) throws
IdentityException
{
- int count = cacheSupport.getIdentityObjectCountFromCache(identityType);
+ int count = cacheSupport.getIdentityObjectCount(getCacheNS(invocationCtx),
identityType.getName());
- if (count == -1)
+ if (count != -1)
{
- count = identityStore.getIdentityObjectsCount(invocationCtx, identityType);
-
- cacheSupport.putIdentityObjectCountIntoCache(identityType, count);
+ return count;
}
+ count = identityStore.getIdentityObjectsCount(invocationCtx, identityType);
+ cacheSupport.putIdentityObjectCount(getCacheNS(invocationCtx),
identityType.getName(), count);
+
return count;
}
-
-
public IdentityObject findIdentityObject(IdentityStoreInvocationContext
invocationContext,
String name,
IdentityObjectType identityObjectType) throws
IdentityException
{
- IdentityObject io = cacheSupport.getFromCache(name, identityObjectType);
+ IdentityObjectSearchImpl search = new IdentityObjectSearchImpl();
+ search.setName(name);
+ if (identityObjectType != null)
+ {
+ search.setType(identityObjectType.getName());
+ }
+ Collection<IdentityObject> results =
cacheSupport.getIdentityObjectSearch(getCacheNS(invocationContext), search);
- if (io == null)
+ if (results != null && results.size() == 1)
{
- io = identityStore.findIdentityObject(invocationContext, name,
identityObjectType);
- cacheSupport.putIntoCache(io);
- return io;
+ return results.iterator().next();
}
+ IdentityObject io = identityStore.findIdentityObject(invocationContext, name,
identityObjectType);
+
+ if (io != null)
+ {
+ Set<IdentityObject> temp = new HashSet<IdentityObject>();
+ temp.add(io);
+ cacheSupport.putIdentityObjectSearch(getCacheNS(invocationContext), search,
temp);
+ }
+
return io;
}
public IdentityObject findIdentityObject(IdentityStoreInvocationContext
invocationContext,
String id) throws IdentityException
{
- IdentityObject io = cacheSupport.getFromCache(id);
- if (io == null)
+ IdentityObjectSearchImpl search = new IdentityObjectSearchImpl();
+ search.setId(id);
+
+ Collection<IdentityObject> results =
cacheSupport.getIdentityObjectSearch(getCacheNS(invocationContext), search);
+
+ if (results != null && results.size() == 1)
+ {
+ return results.iterator().next();
+ }
+
+ IdentityObject io = identityStore.findIdentityObject(invocationContext, id);
+
+ if (io != null)
{
- io = identityStore.findIdentityObject(invocationContext, id);
- cacheSupport.putIntoCache(io);
- return io;
+ Set<IdentityObject> temp = new HashSet<IdentityObject>();
+ temp.add(io);
+ cacheSupport.putIdentityObjectSearch(getCacheNS(invocationContext), search,
temp);
}
return io;
@@ -194,21 +219,26 @@
IdentityObjectSearchCriteria
criteria) throws IdentityException
{
- Collection<IdentityObject> results =
cacheSupport.getIdentityObjectSearchFromCache(identityType, criteria);
+ //TODO: fix
- if (results == null)
- {
- results = identityStore.findIdentityObject(invocationCtx, identityType,
criteria);
+// IdentityObjectSearchImpl search = new IdentityObjectSearchImpl();
+// search.setIdentityObjectSearchCriteria(criteria);
+// if (identityType != null)
+// {
+// search.setType(identityType.getName());
+// }
- cacheSupport.putIdentityObjectSearchIntoCache(identityType, criteria, results);
+// Collection<IdentityObject> results =
cacheSupport.getIdentityObjectSearch(getCacheNS(invocationCtx), search);
- // Put all the results into cache separately
- for (IdentityObject result : results)
- {
- cacheSupport.putIntoCache(result);
- }
- }
+// if (results != null)
+// {
+// return results;
+// }
+ Collection<IdentityObject> results =
identityStore.findIdentityObject(invocationCtx, identityType, criteria);
+
+// cacheSupport.putIdentityObjectSearch(getCacheNS(invocationCtx), search,
results);
+
return results;
@@ -224,19 +254,31 @@
IdentityObjectSearchCriteria
criteria) throws IdentityException
{
- Collection<IdentityObject> results =
cacheSupport.getIdentityObjectSearchFromCache(identity, relationshipType, parent,
criteria);
+ IdentityObjectSearchImpl search = new IdentityObjectSearchImpl();
+ search.setIdentityObjectSearchCriteria(criteria);
+ search.setParent(parent);
+ if (relationshipType != null)
+ {
+ search.setRelationshipType(relationshipType.getName());
+ }
+ if (identity != null)
+ {
+ search.setName(identity.getName());
+ search.setType(identity.getIdentityType().getName());
+ }
- if (results == null)
+ Collection<IdentityObject> results =
cacheSupport.getIdentityObjectSearch(getCacheNS(invocationCtx), search);
+
+ if (results != null)
{
- results = identityStore.findIdentityObject(invocationCtx, identity,
relationshipType, parent, criteria);
+ //TODO
+ return results;
+ }
- cacheSupport.putIdentityObjectSearchToCache(identity,
relationshipType,parent,criteria, results);
+ results = identityStore.findIdentityObject(invocationCtx, identity,
relationshipType, parent, criteria);
- for (IdentityObject result : results)
- {
- cacheSupport.putIntoCache(result);
- }
- }
+ cacheSupport.putIdentityObjectSearch(getCacheNS(invocationCtx), search, results);
+
return results;
}
@@ -250,7 +292,9 @@
String relationshipName,
boolean createNames) throws
IdentityException
{
- cacheSupport.invalidateCachedRelationshipSearches(fromIdentity, toIdentity,
relationshipType, relationshipName);
+
cacheSupport.invalidateIdentityObjectRelationshipNameSearches(getCacheNS(invocationCxt));
+
cacheSupport.invalidateIdentityObjectRelationshipSearches(getCacheNS(invocationCxt));
+ cacheSupport.invalidateIdentityObjectSearches(getCacheNS(invocationCxt));
return identityStore.createRelationship(invocationCxt,
fromIdentity, toIdentity, relationshipType, relationshipName, createNames);
@@ -266,8 +310,12 @@
{
identityStore.removeRelationship(invocationCxt, fromIdentity, toIdentity,
relationshipType, relationshipName);
- cacheSupport.invalidateCachedRelationshipSearches(fromIdentity, toIdentity,
relationshipType, relationshipName);
-
+
cacheSupport.invalidateIdentityObjectRelationshipNameSearches(getCacheNS(invocationCxt));
+
cacheSupport.invalidateIdentityObjectRelationshipSearches(getCacheNS(invocationCxt));
+ cacheSupport.invalidateIdentityObjectSearches(getCacheNS(invocationCxt));
+ IdentityObjectRelationship relationship = new
SimpleIdentityObjectRelationship(fromIdentity, toIdentity, relationshipName,
relationshipType);
+ cacheSupport.invalidateRelationshipProperties(getCacheNS(invocationCxt),
relationship);
+
}
@@ -280,8 +328,10 @@
{
identityStore.removeRelationships(invocationCtx, identity1, identity2, named);
- cacheSupport.invalidateCachedRelationshipSearches(identity1, identity2, named);
-
+
cacheSupport.invalidateIdentityObjectRelationshipNameSearches(getCacheNS(invocationCtx));
+
cacheSupport.invalidateIdentityObjectRelationshipSearches(getCacheNS(invocationCtx));
+ cacheSupport.invalidateIdentityObjectSearches(getCacheNS(invocationCtx));
+ cacheSupport.invalidateRelationshipProperties(getCacheNS(invocationCtx));
}
@@ -291,16 +341,33 @@
IdentityObjectRelationshipType relationshipType) throws IdentityException
{
+ IdentityObjectRelationshipSearchImpl search = new
IdentityObjectRelationshipSearchImpl();
+ if (fromIdentity != null)
+ {
+ search.setFromIOName(fromIdentity.getName());
+ search.setFromIOType(fromIdentity.getIdentityType().getName());
+ }
+ if (toIdentity != null)
+ {
+ search.setToIOName(toIdentity.getName());
+ search.setToIOType(toIdentity.getIdentityType().getName());
+ }
+ if (relationshipType != null)
+ {
+ search.setRelationshipType(relationshipType.getName());
+ }
+
+ Set<IdentityObjectRelationship> results =
cacheSupport.getIdentityObjectRelationshipSearch(getCacheNS(invocationCxt), search);
- Set<IdentityObjectRelationship> results =
cacheSupport.getRelationshipsSearchFromCache(fromIdentity, toIdentity, relationshipType);
-
- if (results == null)
+ if (results != null)
{
- results = identityStore.resolveRelationships(invocationCxt, fromIdentity,
toIdentity, relationshipType);
-
- cacheSupport.putRelationshipsSearchIntoCache(fromIdentity, toIdentity,
relationshipType, results);
+ return results;
}
+ results = identityStore.resolveRelationships(invocationCxt, fromIdentity,
toIdentity, relationshipType);
+
+ cacheSupport.putIdentityObjectRelationshipSearch(getCacheNS(invocationCxt), search,
results);
+
return results;
}
@@ -312,16 +379,34 @@
boolean named,
String name) throws
IdentityException
{
- Set<IdentityObjectRelationship> results =
cacheSupport.getRelationshipsSearchFromCache(identity, relationshipType, parent, named,
name);
- if (results == null)
+ IdentityObjectRelationshipSearchImpl search = new
IdentityObjectRelationshipSearchImpl();
+ if (identity != null)
{
- results = identityStore.resolveRelationships(invocationCtx,
- identity, relationshipType, parent, named, name);
+ search.setIoName(identity.getName());
+ search.setIoType(identity.getIdentityType().getName());
+ }
+ if (relationshipType != null)
+ {
+ search.setRelationshipType(relationshipType.getName());
+ }
+ search.setParent(parent);
+ search.setNamed(named);
+ search.setName(name);
- cacheSupport.putRelationshipSearchIntoCache(identity, relationshipType, parent,
named, name, results);
+ Set<IdentityObjectRelationship> results =
cacheSupport.getIdentityObjectRelationshipSearch(getCacheNS(invocationCtx), search);
+
+ if (results != null)
+ {
+ return results;
}
+ results = identityStore.resolveRelationships(invocationCtx,
+ identity, relationshipType, parent, named, name);
+
+ cacheSupport.putIdentityObjectRelationshipSearch(getCacheNS(invocationCtx), search,
results);
+
+
return results;
}
@@ -329,7 +414,9 @@
String name) throws IdentityException,
OperationNotSupportedException
{
- cacheSupport.invalidateRelationshipNameSearches(name);
+ cacheSupport.invalidateIdentityObjectRelationshipNameSearches(getCacheNS(ctx));
+ cacheSupport.invalidateIdentityObjectRelationshipSearches(getCacheNS(ctx));
+ cacheSupport.invalidateIdentityObjectSearches(getCacheNS(ctx));
return identityStore.createRelationshipName(ctx, name);
}
@@ -337,7 +424,10 @@
public String removeRelationshipName(IdentityStoreInvocationContext ctx,
String name) throws IdentityException,
OperationNotSupportedException
{
- cacheSupport.invalidateRelationshipNameSearches(name);
+ cacheSupport.invalidateIdentityObjectRelationshipNameSearches(getCacheNS(ctx));
+ cacheSupport.invalidateIdentityObjectRelationshipSearches(getCacheNS(ctx));
+ cacheSupport.invalidateIdentityObjectSearches(getCacheNS(ctx));
+ cacheSupport.invalidateRelationshipNameProperties(getCacheNS(ctx), name);
return identityStore.removeRelationshipName(ctx, name);
}
@@ -345,15 +435,21 @@
public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObjectSearchCriteria criteria) throws
IdentityException, OperationNotSupportedException
{
- Set<String> results =
cacheSupport.getRelationshipNamesSearchFromCache(criteria);
- if (results == null)
+ IdentityObjectRelationshipNameSearchImpl search = new
IdentityObjectRelationshipNameSearchImpl();
+ search.setIdentityObjectSearchCriteria(criteria);
+
+ Set<String> results =
cacheSupport.getIdentityObjectRelationshipNameSearch(getCacheNS(ctx), search);
+
+ if (results != null)
{
- results = identityStore.getRelationshipNames(ctx, criteria);
-
- cacheSupport.putRelationshipNamesSearchIntoCache(criteria, results);
+ return results;
}
+ results = identityStore.getRelationshipNames(ctx, criteria);
+
+ cacheSupport.putIdentityObjectRelationshipNameSearch(getCacheNS(ctx), search,
results);
+
return results;
}
@@ -363,56 +459,96 @@
IdentityObjectSearchCriteria criteria) throws
IdentityException, OperationNotSupportedException
{
+ IdentityObjectRelationshipNameSearchImpl search = new
IdentityObjectRelationshipNameSearchImpl();
+ if (identity != null)
+ {
+ search.setIoName(identity.getName());
+ search.setIoType(identity.getIdentityType().getName());
+ }
+ search.setIdentityObjectSearchCriteria(criteria);
- Set<String> results =
cacheSupport.getRelationshipNamesSearchFromCache(identity, criteria);
+ Set<String> results =
cacheSupport.getIdentityObjectRelationshipNameSearch(getCacheNS(ctx), search);
- if (results == null)
+ if (results != null)
{
- results = identityStore.getRelationshipNames(ctx, identity, criteria);
-
- cacheSupport.putRelationshipNamesSearchIntoCache(identity, criteria, results);
+ return results;
}
+ results = identityStore.getRelationshipNames(ctx, identity, criteria);
+
+ cacheSupport.putIdentityObjectRelationshipNameSearch(getCacheNS(ctx), search,
results);
+
return results;
}
public Map<String, String>
getRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name) throws
IdentityException, OperationNotSupportedException
{
- //TODO: apply caching
- return identityStore.getRelationshipNameProperties(ctx, name);
+ Map<String, String> properties = cacheSupport.getProperties(getCacheNS(ctx),
name);
+
+ if (properties != null)
+ {
+ return properties;
+ }
+
+ properties = identityStore.getRelationshipNameProperties(ctx, name);
+
+ cacheSupport.putProperties(getCacheNS(ctx), name, properties);
+
+ return properties;
+
}
public void setRelationshipNameProperties(IdentityStoreInvocationContext ctx, String
name, Map<String, String> properties) throws IdentityException,
OperationNotSupportedException
{
- //TODO: apply caching
+
identityStore.setRelationshipNameProperties(ctx, name, properties);
+
+ cacheSupport.invalidateRelationshipNameProperties(getCacheNS(ctx), name);
+ cacheSupport.putProperties(getCacheNS(ctx), name,
getRelationshipNameProperties(ctx, name));
}
public void removeRelationshipNameProperties(IdentityStoreInvocationContext ctx,
String name, Set<String> properties) throws IdentityException,
OperationNotSupportedException
{
- //TODO: apply caching
identityStore.removeRelationshipNameProperties(ctx, name, properties);
+ cacheSupport.invalidateRelationshipNameProperties(getCacheNS(ctx), name);
+ cacheSupport.putProperties(getCacheNS(ctx), name,
getRelationshipNameProperties(ctx, name));
+
}
public Map<String, String>
getRelationshipProperties(IdentityStoreInvocationContext ctx, IdentityObjectRelationship
relationship) throws IdentityException, OperationNotSupportedException
{
- //TODO: apply caching
- return identityStore.getRelationshipProperties(ctx, relationship);
+ Map<String, String> properties = cacheSupport.getProperties(getCacheNS(ctx),
relationship);
+
+ if (properties != null)
+ {
+ return properties;
+ }
+
+ properties = identityStore.getRelationshipProperties(ctx, relationship);
+
+ cacheSupport.putProperties(getCacheNS(ctx), relationship, properties);
+
+ return properties;
+
}
public void setRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Map<String, String> properties) throws
IdentityException, OperationNotSupportedException
{
- //TODO: apply caching
identityStore.setRelationshipProperties(ctx, relationship, properties);
+
+ cacheSupport.invalidateRelationshipProperties(getCacheNS(ctx), relationship);
+ cacheSupport.putProperties(getCacheNS(ctx), relationship,
getRelationshipProperties(ctx, relationship));
}
public void removeRelationshipProperties(IdentityStoreInvocationContext ctx,
IdentityObjectRelationship relationship, Set<String> properties) throws
IdentityException, OperationNotSupportedException
{
- //TODO: apply caching
identityStore.removeRelationshipProperties(ctx, relationship, properties);
+
+ cacheSupport.invalidateRelationshipProperties(getCacheNS(ctx), relationship);
+ cacheSupport.putProperties(getCacheNS(ctx), relationship,
getRelationshipProperties(ctx, relationship));
}
public boolean validateCredential(IdentityStoreInvocationContext ctx,
@@ -431,11 +567,10 @@
identityStore.updateCredential(ctx, identityObject, credential);
}
-
-
@Override
public String toString()
{
return "JBossCacheIdentityStoreWrapper (IdentityStore=" +
identityStore.getId() + ")";
}
+
}
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-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/configuration/IdentityConfigurationImpl.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -253,6 +253,7 @@
Map<String, String> cacheProps = new HashMap<String, String>();
String cacheClassName = null;
+ String cacheRegistryName = null;
// Parse all 'cache.' prefixed options
for (String key : metaData.getOptions().keySet())
@@ -267,11 +268,29 @@
{
cacheClassName = metaData.getOptions().get(key).get(0);
}
+
+ if (key.equals("cache.providerRegistryName") &&
metaData.getOptions().get(key).size() > 0)
+ {
+ cacheRegistryName = metaData.getOptions().get(key).get(0);
+ }
}
}
APICacheProvider provider = null;
+ if (cacheRegistryName != null)
+ {
+ try
+ {
+ provider =
(APICacheProvider)configurationContext.getConfigurationRegistry().getObject(cacheRegistryName);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot find APICacheProvider in
ConfigurationRegistry using provided name:" + cacheRegistryName, e);
+ }
+
+ }
+
// Instantiate provider
if (cacheClassName != null)
{
@@ -289,13 +308,13 @@
provider = (APICacheProvider)ct.newInstance();
- provider.initialize(cacheProps);
+ provider.initialize(cacheProps,
(IdentityConfigurationRegistry)configurationContext.getConfigurationRegistry());
}
//IdentitySession session = new IdentitySessionImpl(realmName, repo, mapper);
IdentitySessionConfigurationContext sessionConfigCtx =
- new IdentitySessionConfigurationContext(realmName, configMD, repo, mapper,
provider);
+ new IdentitySessionConfigurationContext(realmName, configMD, repo, mapper,
provider, configurationContext, metaData.getOptions());
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-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/configuration/IdentitySessionConfigurationContext.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -23,9 +23,12 @@
package org.jboss.identity.idm.impl.configuration;
import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.jboss.identity.idm.spi.configuration.IdentityConfigurationContext;
import org.jboss.identity.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
import org.jboss.identity.idm.cache.APICacheProvider;
@@ -39,22 +42,28 @@
private static final long serialVersionUID = 3263619777028197717L;
private final String realmName;
+ private final IdentityConfigurationContext identityConfigurationContext;
private final IdentityConfigurationMetaData identityConfigurationMetaData;
private final IdentityStoreRepository repository;
private final IdentityObjectTypeMapper typeMapper;
private final APICacheProvider apiCacheProvider;
+ private final Map<String, List<String>> realmOptions;
public IdentitySessionConfigurationContext(String realmName,
IdentityConfigurationMetaData
identityConfigurationMetaData,
IdentityStoreRepository repository,
IdentityObjectTypeMapper typeMapper,
- APICacheProvider apiCacheProvider)
+ APICacheProvider apiCacheProvider,
+ IdentityConfigurationContext
identityConfigurationContext,
+ Map<String, List<String>>
realmOptions)
{
this.realmName = realmName;
this.identityConfigurationMetaData = identityConfigurationMetaData;
this.repository = repository;
this.typeMapper = typeMapper;
this.apiCacheProvider = apiCacheProvider;
+ this.identityConfigurationContext = identityConfigurationContext;
+ this.realmOptions = realmOptions;
}
public String getRealmName()
@@ -81,4 +90,14 @@
{
return apiCacheProvider;
}
+
+ public IdentityConfigurationContext getIdentityConfigurationContext()
+ {
+ return identityConfigurationContext;
+ }
+
+ public Map<String, List<String>> getRealmOptions()
+ {
+ return realmOptions;
+ }
}
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -64,10 +64,14 @@
public static final String CACHE_OPTION = "cache";
- public static final String CACHE_CONFIG_FILE_OPTION = "cache.config-file";
+ public static final String CACHE_CONFIG_FILE_OPTION = "cache.configFile";
- public static final String CACHE_PROVIDER_CLASS_OPTION =
"cache.provider.class";
+ public static final String CACHE_PROVIDER_CLASS_OPTION =
"cache.providerClass";
+ public static final String CACHE_PROVIDER_REGISTRY_NAME =
"cache.providerRegistryName";
+
+ public static final String CACHE_SCOPE = "cache.scope";
+
public static final String ALLOW_NOT_DEFINED_IDENTITY_OBJECT_TYPES_OPTION =
"allowNotDefinedIdentityObjectTypes";
private boolean allowNotDefinedIdentityObjectTypes = false;
@@ -106,55 +110,67 @@
if (cacheOption != null &&
cacheOption.equalsIgnoreCase("true"))
{
- String cacheConfig =
configurationMD.getOptionSingleValue(CACHE_CONFIG_FILE_OPTION);
String cacheSupportClass =
configurationMD.getOptionSingleValue(CACHE_PROVIDER_CLASS_OPTION);
+ String cacheRegistryName =
configurationMD.getOptionSingleValue(CACHE_PROVIDER_REGISTRY_NAME);
+ String cacheScope =
configurationMD.getOptionSingleValue(CACHE_PROVIDER_REGISTRY_NAME);
- if (cacheConfig == null)
+ if (cacheSupportClass == null && cacheRegistryName == null)
{
- throw new IdentityException(CACHE_CONFIG_FILE_OPTION + " is missing
in the repository configuration");
+ throw new IdentityException(CACHE_PROVIDER_CLASS_OPTION + " is
missing in the repository configuration");
}
- if (cacheSupportClass == null)
+ IdentityStoreCacheProvider cacheSupport = null;
+
+ Map<String, String> cacheProps = new HashMap<String, String>();
+
+ // Parse all 'cache.' prefixed options
+ for (String key : configurationMD.getOptions().keySet())
{
- throw new IdentityException(CACHE_PROVIDER_CLASS_OPTION + " is
missing in the repository configuration");
+ if (key.startsWith("cache."))
+ {
+ if (configurationMD.getOptions().get(key).size() > 0)
+ {
+ cacheProps.put(key, configurationMD.getOptions().get(key).get(0));
+ }
+ }
}
- ClassLoader classLoader = SecurityActions.getContextClassLoader();
- InputStream cacheConfigInputStream =
classLoader.getResourceAsStream(cacheConfig);
- if (cacheConfigInputStream == null)
+ if (cacheRegistryName != null)
{
- throw new IdentityException("JBoss Cache config file specified in
option \"" + CACHE_CONFIG_FILE_OPTION +
- "\" doesn't exist: " + cacheConfig);
+ try
+ {
+ cacheSupport =
(IdentityStoreCacheProvider)configurationContext.getConfigurationRegistry().getObject(cacheRegistryName);
+ }
+ catch (IdentityException e)
+ {
+ throw new IdentityException("Cannot find
IdentityStoreCacheProvider cache provider instance" +
+ "with provided name:" + cacheRegistryName, e);
+ }
}
-
-
-
- try
+ else
{
- Class cacheClass = null;
- cacheClass = Class.forName(cacheSupportClass);
+ try
+ {
+ Class cacheClass = null;
+ cacheClass = Class.forName(cacheSupportClass);
- Class partypes[] = new Class[1];
- partypes[0] = InputStream.class;
+ Constructor ct = cacheClass.getConstructor();
- Constructor ct = cacheClass.getConstructor(partypes);
- Object argList[] = new Object[1];
- argList[0] = cacheConfigInputStream;
+ cacheSupport = (IdentityStoreCacheProvider)ct.newInstance();
+ cacheSupport.initialize(cacheProps, configurationContext);
- IdentityStoreCacheProvider cacheSupport =
(IdentityStoreCacheProvider)ct.newInstance(argList);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot instantiate cache
provider:" + cacheSupportClass, e);
+ }
+ }
- defaultIdentityStore = new
JBossCacheIdentityStoreWrapper(defaultIdentityStore, cacheSupport);
+ defaultIdentityStore = new
JBossCacheIdentityStoreWrapper(defaultIdentityStore, cacheSupport, cacheScope);
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot instantiate cache provider:"
+ cacheSupportClass, e);
- }
-
-
}
}
@@ -170,52 +186,67 @@
if (cacheOption != null &&
cacheOption.equalsIgnoreCase("true"))
{
- String cacheConfig =
identityStoreMappingMetaData.getOptionSingleValue(CACHE_CONFIG_FILE_OPTION);
+
String cacheSupportClass =
identityStoreMappingMetaData.getOptionSingleValue(CACHE_PROVIDER_CLASS_OPTION);
+ String cacheRegistryName =
identityStoreMappingMetaData.getOptionSingleValue(CACHE_PROVIDER_REGISTRY_NAME);
+ String cacheScope =
identityStoreMappingMetaData.getOptionSingleValue(CACHE_PROVIDER_REGISTRY_NAME);
-
- if (cacheConfig == null)
+ if (cacheSupportClass == null && cacheRegistryName == null)
{
- throw new IdentityException(CACHE_CONFIG_FILE_OPTION + " is missing
in the repository identity-store-mapping configuration");
+ throw new IdentityException(CACHE_PROVIDER_CLASS_OPTION + " is
missing in the <identity-store><options> configuration");
}
- if (cacheSupportClass == null)
+ IdentityStoreCacheProvider cacheSupport = null;
+
+ Map<String, String> cacheProps = new HashMap<String, String>();
+
+ // Parse all 'cache.' prefixed options
+ for (String key : identityStoreMappingMetaData.getOptions().keySet())
{
- throw new IdentityException(CACHE_PROVIDER_CLASS_OPTION + " is
missing in the repository configuration");
+ if (key.startsWith("cache."))
+ {
+ if (identityStoreMappingMetaData.getOptions().get(key).size() > 0)
+ {
+ cacheProps.put(key,
identityStoreMappingMetaData.getOptions().get(key).get(0));
+ }
+ }
}
- ClassLoader classLoader = SecurityActions.getContextClassLoader();
- InputStream cacheConfigInputStream =
classLoader.getResourceAsStream(cacheConfig);
- if (cacheConfigInputStream == null)
+ if (cacheRegistryName != null)
{
- throw new IdentityException("JBoss Cache config file specified in
option \"" + CACHE_CONFIG_FILE_OPTION +
- "\" doesn't exist: " + cacheConfig);
+ try
+ {
+ cacheSupport =
(IdentityStoreCacheProvider)configurationContext.getConfigurationRegistry().getObject(cacheRegistryName);
+ }
+ catch (IdentityException e)
+ {
+ throw new IdentityException("Cannot find
IdentityStoreCacheProvider cache provider instance" +
+ "with provided name:" + cacheRegistryName, e);
+ }
}
-
- try
+ else
{
- Class cacheClass = null;
- cacheClass = Class.forName(cacheSupportClass);
+ try
+ {
+ Class cacheClass = null;
+ cacheClass = Class.forName(cacheSupportClass);
- Class partypes[] = new Class[1];
- partypes[0] = InputStream.class;
+ Constructor ct = cacheClass.getConstructor();
- Constructor ct = cacheClass.getConstructor(partypes);
- Object argList[] = new Object[1];
- argList[0] = cacheConfigInputStream;
+ cacheSupport = (IdentityStoreCacheProvider)ct.newInstance();
+ cacheSupport.initialize(cacheProps, configurationContext);
- IdentityStoreCacheProvider cacheSupport =
(IdentityStoreCacheProvider)ct.newInstance(argList);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot instantiate cache
provider:" + cacheSupportClass, e);
+ }
+ }
- store = new JBossCacheIdentityStoreWrapper(store, cacheSupport);
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot instantiate cache provider:"
+ cacheSupportClass, e);
- }
+ store = new JBossCacheIdentityStoreWrapper(store, cacheSupport, cacheScope);
-
}
if (store == null)
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -374,7 +374,7 @@
RepositoryIdentityStoreSessionImpl repoSession =
(RepositoryIdentityStoreSessionImpl)invocationCtx.getIdentityStoreSession();
IdentityStoreSession targetSession = repoSession.getIdentityStoreSession(id);
- return new SimpleIdentityStoreInvocationContext(targetSession,
invocationCtx.getRealmId());
+ return new SimpleIdentityStoreInvocationContext(targetSession,
invocationCtx.getRealmId(), String.valueOf(this.hashCode()));
}
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -107,7 +107,7 @@
RepositoryIdentityStoreSessionImpl repoSession =
(RepositoryIdentityStoreSessionImpl)invocationCtx.getIdentityStoreSession();
IdentityStoreSession targetSession = repoSession.getIdentityStoreSession(id);
- return new SimpleIdentityStoreInvocationContext(targetSession,
invocationCtx.getRealmId());
+ return new SimpleIdentityStoreInvocationContext(targetSession,
invocationCtx.getRealmId(), String.valueOf(this.hashCode()));
}
Modified:
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/store/SimpleIdentityStoreInvocationContext.java
===================================================================
---
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/store/SimpleIdentityStoreInvocationContext.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-core/src/main/java/org/jboss/identity/idm/impl/store/SimpleIdentityStoreInvocationContext.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -35,7 +35,9 @@
private final String realmId;
- public SimpleIdentityStoreInvocationContext(IdentityStoreSession identityStoreSession,
String realmId)
+ private final String sessionId;
+
+ public SimpleIdentityStoreInvocationContext(IdentityStoreSession identityStoreSession,
String realmId, String sessionId)
{
if (identityStoreSession == null)
{
@@ -44,6 +46,7 @@
this.identityStoreSession = identityStoreSession;
this.realmId = realmId;
+ this.sessionId = sessionId;
}
public IdentityStoreSession getIdentityStoreSession()
@@ -55,4 +58,9 @@
{
return realmId;
}
+
+ public String getSessionId()
+ {
+ return sessionId;
+ }
}
Added:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectRelationshipNameSearch.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectRelationshipNameSearch.java
(rev 0)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectRelationshipNameSearch.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -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.spi.cache;
+
+public interface IdentityObjectRelationshipNameSearch extends Search
+{
+}
Added:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectRelationshipSearch.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectRelationshipSearch.java
(rev 0)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectRelationshipSearch.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -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.spi.cache;
+
+public interface IdentityObjectRelationshipSearch extends Search
+{
+}
Added:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectSearch.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectSearch.java
(rev 0)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityObjectSearch.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -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.spi.cache;
+
+public interface IdentityObjectSearch extends Search
+{
+}
Modified:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityStoreCacheProvider.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityStoreCacheProvider.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/IdentityStoreCacheProvider.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -28,97 +28,113 @@
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
import org.jboss.identity.idm.spi.search.IdentityObjectSearchCriteria;
+import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
import java.util.Map;
import java.util.Collection;
import java.util.Set;
+/**
+ * Cache provider for Identity SPI. Namespaces enable flexible use (per realm or per
session)
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
public interface IdentityStoreCacheProvider
{
-
- void initResidentNodes(Set<String> supportedIdentityObjectTypes,
- Set<String> supportedRelationshipTypes);
- void putIntoCache(IdentityObject io);
+ /**
+ * Initialize provider.
+ * @param properties
+ */
+ void initialize(Map<String, String> properties,
IdentityRepositoryConfigurationContext configurationContext);
- void putIntoCache(IdentityObject io, Map<String, IdentityObjectAttribute>
attributesMap);
- void removeFromCache(IdentityObject io);
+ /**
+ * Generate realm namespace.
+ *
+ * @param storeId - if null will generate root namespace
+ * @return
+ */
+ String getNamespace(String storeId);
- void removeAttributesFromCache(IdentityObject io);
+ /**
+ * Generate namespace based on realm and session ids.
+ *
+ * @param storeId if null will generate root namespace
+ * @param realmId if null will generate store namespace
+ * @return
+ */
+ String getNamespace(String storeId, String realmId);
- IdentityObject getFromCache(String name, IdentityObjectType identityObjectType);
+ /**
+ * Generate namespace based on realm and session ids.
+ *
+ * @param storeId if null will generate root namespace
+ * @param realmId if null will generate store namespace
+ * @param sessionId if null will generate realm namespace
+ * @return
+ */
+ String getNamespace(String storeId, String realmId, String sessionId);
- Map<String, IdentityObjectAttribute> getAttributesFromCache(String name,
IdentityObjectType identityObjectType);
+ void invalidate(String ns);
- IdentityObject getFromCache(String id);
+ //
- void putIdentityObjectSearchIntoCache(IdentityObjectType identityType,
- IdentityObjectSearchCriteria criteria,
- Collection<IdentityObject> results);
+ void putIdentityObjectCount(String ns, String type, int count);
- Collection<IdentityObject> getIdentityObjectSearchFromCache(IdentityObjectType
identityType,
-
IdentityObjectSearchCriteria criteria);
+ int getIdentityObjectCount(String ns, String type);
- void putIdentityObjectSearchToCache(IdentityObject identity,
- IdentityObjectRelationshipType relationshipType,
- boolean parent,
- IdentityObjectSearchCriteria criteria,
- Collection<IdentityObject> results);
+ void invalidateIdentityObjectCount(String ns, String type);
- Collection<IdentityObject> getIdentityObjectSearchFromCache(IdentityObject
identity,
-
IdentityObjectRelationshipType relationshipType,
- boolean parent,
-
IdentityObjectSearchCriteria criteria);
+ void putIdentityObjectSearch(String ns, IdentityObjectSearch search,
Collection<IdentityObject> results);
- void putRelationshipsSearchIntoCache(IdentityObject fromIdentity,
- IdentityObject toIdentity,
- IdentityObjectRelationshipType relationshipType,
- Set<IdentityObjectRelationship> results);
+ Collection<IdentityObject> getIdentityObjectSearch(String ns,
IdentityObjectSearch search);
- Set<IdentityObjectRelationship> getRelationshipsSearchFromCache(IdentityObject
fromIdentity,
- IdentityObject
toIdentity,
-
IdentityObjectRelationshipType relationshipType);
+ void invalidateIdentityObjectSearches(String ns);
- void putRelationshipSearchIntoCache(IdentityObject identity,
- IdentityObjectRelationshipType relationshipType,
- boolean parent,
- boolean named,
- String name,
- Set<IdentityObjectRelationship> results);
+ //
- Set<IdentityObjectRelationship> getRelationshipsSearchFromCache(IdentityObject
identity,
-
IdentityObjectRelationshipType relationshipType,
- boolean parent,
- boolean named,
- String name);
+ void putIdentityObjectRelationshipSearch(String ns, IdentityObjectRelationshipSearch
search, Set<IdentityObjectRelationship> results);
- void invalidateCachedIdentityObjectSearches(IdentityObject io);
+ Set<IdentityObjectRelationship> getIdentityObjectRelationshipSearch(String ns,
IdentityObjectRelationshipSearch search);
- void putIdentityObjectCountIntoCache(IdentityObjectType identityType, int count);
+ void invalidateIdentityObjectRelationshipSearches(String ns);
- int getIdentityObjectCountFromCache(IdentityObjectType identityType);
+ //
- void invalidateCachedIdentityObjectCount(IdentityObjectType identityType);
+ void putIdentityObjectRelationshipNameSearch(String ns,
IdentityObjectRelationshipNameSearch search, Set<String> results);
- void invalidateCachedRelationshipSearches(IdentityObject fromIdentity,
- IdentityObject toIdentity,
- IdentityObjectRelationshipType
relationshipType,
- String relationshipName);
+ Set<String> getIdentityObjectRelationshipNameSearch(String ns,
IdentityObjectRelationshipNameSearch search);
- void invalidateCachedRelationshipSearches(IdentityObject identity1, IdentityObject
identity2, boolean named);
+ void invalidateIdentityObjectRelationshipNameSearches(String ns);
- void invalidateRelationshipNameSearches(String name);
+ //
- void putRelationshipNamesSearchIntoCache(IdentityObjectSearchCriteria criteria,
Set<String> results);
+ void putProperties(String ns, IdentityObjectRelationship relationship, Map<String,
String> properties);
- Set<String> getRelationshipNamesSearchFromCache(IdentityObjectSearchCriteria
criteria);
+ Map<String, String> getProperties(String ns, IdentityObjectRelationship
relationship);
- void putRelationshipNamesSearchIntoCache(IdentityObject identity,
- IdentityObjectSearchCriteria criteria,
- Set<String> results);
+ void invalidateRelationshipProperties(String ns, IdentityObjectRelationship
relationship);
- Set<String> getRelationshipNamesSearchFromCache(IdentityObject identity,
IdentityObjectSearchCriteria criteria);
+ void invalidateRelationshipProperties(String ns);
+ void putProperties(String ns, String name, Map<String, String> properties);
+ Map<String, String> getProperties(String ns, String name);
+
+ void invalidateRelationshipNameProperties(String ns, String relationship);
+
+ void invalidateRelationshipNameProperties(String ns);
+
+ //
+
+ void putIdentityObjectAttributes(String ns, IdentityObject identityObject,
Map<String, IdentityObjectAttribute> attributes);
+
+ Map<String, IdentityObjectAttribute> getIdentityObjectAttributes(String ns,
IdentityObject identityObject);
+
+ void invalidateIdentityObjectAttriubtes(String ns, IdentityObject identityObject);
+
+ void invalidateIdentityObjectAttriubtes(String ns);
+
}
Added: idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/Search.java
===================================================================
--- idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/Search.java
(rev 0)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/cache/Search.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -0,0 +1,38 @@
+/*
+* 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.spi.cache;
+
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchCriteria;
+
+import java.io.Serializable;
+
+public abstract interface Search extends Serializable
+{
+
+ IdentityObjectSearchCriteria getIdentityObjectSearchCriteria();
+
+ void setIdentityObjectSearchCriteria(IdentityObjectSearchCriteria criteria);
+
+
+}
Modified:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreInvocationContext.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreInvocationContext.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStoreInvocationContext.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -35,5 +35,7 @@
IdentityStoreSession getIdentityStoreSession();
String getRealmId();
+
+ String getSessionId();
}
Modified:
idm/trunk/idm-testsuite/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java
===================================================================
---
idm/trunk/idm-testsuite/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-testsuite/src/test/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreTestCase.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -126,6 +126,11 @@
{
return "testRealm";
}
+
+ public String getSessionId()
+ {
+ return "";
+ }
};
Modified:
idm/trunk/idm-testsuite/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java
===================================================================
---
idm/trunk/idm-testsuite/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-testsuite/src/test/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreTestCase.java 2009-11-05
19:23:37 UTC (rev 907)
@@ -114,6 +114,11 @@
{
return "testRealm";
}
+
+ public String getSessionId()
+ {
+ return "";
+ }
};
}
Modified: idm/trunk/idm-testsuite/src/test/resources/test-identity-config-msad-local.xml
===================================================================
---
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-msad-local.xml 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-msad-local.xml 2009-11-05
19:23:37 UTC (rev 907)
@@ -89,11 +89,11 @@
<value>false</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
+ <name>cache.configFile</name>
<value>jboss-cache-config.xml</value>
</option>
</options>
@@ -140,11 +140,11 @@
<value>false</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
+ <name>cache.configFile</name>
<value>jboss-cache-config.xml</value>
</option>
</options>
Modified: idm/trunk/idm-testsuite/src/test/resources/test-identity-config-msad.xml
===================================================================
--- idm/trunk/idm-testsuite/src/test/resources/test-identity-config-msad.xml 2009-11-05
12:19:23 UTC (rev 906)
+++ idm/trunk/idm-testsuite/src/test/resources/test-identity-config-msad.xml 2009-11-05
19:23:37 UTC (rev 907)
@@ -89,11 +89,11 @@
<value>false</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
+ <name>cache.configFile</name>
<value>jboss-cache-config.xml</value>
</option>
</options>
@@ -140,11 +140,11 @@
<value>false</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
+ <name>cache.configFile</name>
<value>jboss-cache-config.xml</value>
</option>
</options>
Modified: idm/trunk/idm-testsuite/src/test/resources/test-identity-config-openldapds.xml
===================================================================
---
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-openldapds.xml 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-openldapds.xml 2009-11-05
19:23:37 UTC (rev 907)
@@ -89,11 +89,11 @@
<value>false</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
+ <name>cache.configFile</name>
<value>jboss-cache-config.xml</value>
</option>
</options>
@@ -140,11 +140,11 @@
<value>false</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
+ <name>cache.configFile</name>
<value>jboss-cache-config.xml</value>
</option>
</options>
Modified: idm/trunk/idm-testsuite/src/test/resources/test-identity-config-redhatds.xml
===================================================================
---
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-redhatds.xml 2009-11-05
12:19:23 UTC (rev 906)
+++
idm/trunk/idm-testsuite/src/test/resources/test-identity-config-redhatds.xml 2009-11-05
19:23:37 UTC (rev 907)
@@ -89,11 +89,11 @@
<value>false</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
+ <name>cache.configFile</name>
<value>jboss-cache-config.xml</value>
</option>
</options>
@@ -140,11 +140,11 @@
<value>false</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
+ <name>cache.configFile</name>
<value>jboss-cache-config.xml</value>
</option>
</options>
Modified: idm/trunk/idm-testsuite/src/test/resources/test-identity-config-sunds.xml
===================================================================
--- idm/trunk/idm-testsuite/src/test/resources/test-identity-config-sunds.xml 2009-11-05
12:19:23 UTC (rev 906)
+++ idm/trunk/idm-testsuite/src/test/resources/test-identity-config-sunds.xml 2009-11-05
19:23:37 UTC (rev 907)
@@ -89,11 +89,11 @@
<value>false</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
+ <name>cache.configFile</name>
<value>jboss-cache-config.xml</value>
</option>
</options>
@@ -140,11 +140,11 @@
<value>false</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
+ <name>cache.configFile</name>
<value>jboss-cache-config.xml</value>
</option>
</options>
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-05
12:19:23 UTC (rev 906)
+++ idm/trunk/idm-testsuite/src/test/resources/test-identity-config.xml 2009-11-05
19:23:37 UTC (rev 907)
@@ -126,15 +126,15 @@
<options>
<option>
<name>cache</name>
- <value>false</value>
+ <value>true</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
- <value>jboss-cache-config.xml</value>
+ <name>cache.configFile</name>
+ <value>jboss-cache.xml</value>
</option>
</options>
</identity-store-mapping>
@@ -177,15 +177,15 @@
<options>
<option>
<name>cache</name>
- <value>false</value>
+ <value>true</value>
</option>
<option>
- <name>cache.provider.class</name>
-
<value>org.jboss.identity.idm.impl.cache.IdentityStoreCacheProviderImpl</value>
+ <name>cache.providerClass</name>
+
<value>org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreCacheProviderImpl</value>
</option>
<option>
- <name>cache.config-file</name>
- <value>jboss-cache-config.xml</value>
+ <name>cache.configFile</name>
+ <value>jboss-cache.xml</value>
</option>
</options>
</identity-store-mapping>