Author: bdaw
Date: 2009-02-02 08:39:43 -0500 (Mon, 02 Feb 2009)
New Revision: 271
Added:
idm/trunk/idm/src/test/resources/jboss-cache-config.xml
idm/trunk/parent/logging.properties
Removed:
idm/trunk/idm/src/test/resources/logging.properties
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
idm/trunk/idm/src/test/resources/organization-test-config.xml
idm/trunk/parent/pom.xml
Log:
- add option to wrap any store in repository with cache
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java 2009-02-02
06:07:32 UTC (rev 270)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java 2009-02-02
13:39:43 UTC (rev 271)
@@ -317,7 +317,7 @@
if (getLog().isLoggable(Level.FINER))
{
- getLog().finer(this.toString() + "IdentityObject storred in cache: " +
io.getName() + "; " + io.getId());
+ getLog().finer(this.toString() + "IdentityObject stored in cache: " +
io.getName() + "; " + io.getId());
}
}
@@ -350,7 +350,7 @@
if (getLog().isLoggable(Level.FINER))
{
- getLog().finer(this.toString() + "IdentityObject storred in cache with
attributes map: " + io.getName() + "; " + io.getId()
+ getLog().finer(this.toString() + "IdentityObject stored in cache with
attributes map: " + io.getName() + "; " + io.getId()
+ "; type=" + io.getIdentityType().getName() );
}
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-02-02
06:07:32 UTC (rev 270)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-02-02
13:39:43 UTC (rev 271)
@@ -48,6 +48,7 @@
import java.util.Collection;
import java.util.Set;
import java.util.logging.Logger;
+import java.io.File;
/**
* IdentityStore implementation that wraps another IdentityStore and uses JBossCache to
cache results.
@@ -71,26 +72,16 @@
// with many updates it can add additional cost
private boolean reloadAttributesToCacheOnUpdate = true;
- public JBossCacheIdentityStoreWrapper(IdentityStore identityStore)
+ public JBossCacheIdentityStoreWrapper(IdentityStore identityStore, String
cacheConfigurationFile) throws IdentityException
{
this.identityStore = identityStore;
-
Configuration config = new Configuration();
-
-// config.setTransactionManagerLookupClass(
GenericTransactionManagerLookup.class.getName() );
-//
-// config.setIsolationLevel(IsolationLevel.READ_COMMITTED);
-//
-// config.setCacheMode(Configuration.CacheMode.LOCAL);
-//
-// config.setLockAcquisitionTimeout(15000);
-
CacheFactory factory = new DefaultCacheFactory();
- this.cache = factory.createCache(config);
+ this.cache = factory.createCache(cacheConfigurationFile);
this.cache.start();
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java 2009-02-02
06:07:32 UTC (rev 270)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/AbstractIdentityStoreRepository.java 2009-02-02
13:39:43 UTC (rev 271)
@@ -31,12 +31,14 @@
import
org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
import org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreMappingMetaData;
import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.impl.cache.JBossCacheIdentityStoreWrapper;
import java.util.Set;
import java.util.Map;
import java.util.HashSet;
import java.util.List;
import java.util.HashMap;
+import java.io.File;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -52,8 +54,12 @@
protected IdentityStore defaultIdentityStore;
protected AttributeStore defaultAttributeStore;
-
+ public static final String CACHE_OPTION = "cache";
+
+ public static final String CACHE_CONFIG_FILE_OPTION = "cache.config-file";
+
+
public void bootstrap(IdentityRepositoryConfigurationMetaData configurationMD,
Map<String, IdentityStore> bootstrappedIdentityStores,
Map<String, AttributeStore> bootstrappedAttributeStores)
throws IdentityException
@@ -70,6 +76,28 @@
if (isId != null && bootstrappedIdentityStores.keySet().contains(isId))
{
defaultIdentityStore = bootstrappedIdentityStores.get(isId);
+
+ String cacheOption = configurationMD.getOptionSingleValue(CACHE_OPTION);
+
+ if (cacheOption != null &&
cacheOption.equalsIgnoreCase("true"))
+ {
+ String cacheConfig =
configurationMD.getOptionSingleValue(CACHE_CONFIG_FILE_OPTION);
+
+ if (cacheConfig == null)
+ {
+ throw new IdentityException(CACHE_CONFIG_FILE_OPTION + " is missing
in the repository configuration");
+ }
+
+ File cacheConfigFile = new File(cacheConfig);
+
+ if(!cacheConfigFile.exists())
+ {
+ throw new IdentityException("JBoss Cache config file specified in
option \"" + CACHE_CONFIG_FILE_OPTION +
+ "\" doesn't exist: " + cacheConfig);
+ }
+
+ defaultIdentityStore = new
JBossCacheIdentityStoreWrapper(defaultIdentityStore, cacheConfig);
+ }
}
for (IdentityStoreMappingMetaData identityStoreMappingMetaData :
configurationMD.getIdentityStoreToIdentityObjectTypeMappings())
@@ -79,6 +107,28 @@
IdentityStore store = bootstrappedIdentityStores.get(storeId);
+ String cacheOption =
identityStoreMappingMetaData.getOptionSingleValue(CACHE_OPTION);
+
+ if (cacheOption != null &&
cacheOption.equalsIgnoreCase("true"))
+ {
+ String cacheConfig =
identityStoreMappingMetaData.getOptionSingleValue(CACHE_CONFIG_FILE_OPTION);
+
+ if (cacheConfig == null)
+ {
+ throw new IdentityException(CACHE_CONFIG_FILE_OPTION + " is missing
in the repository identity-store-mapping configuration");
+ }
+
+ File cacheConfigFile = new File(cacheConfig);
+
+ if(!cacheConfigFile.exists())
+ {
+ throw new IdentityException("JBoss Cache config file specified in
option \"" + CACHE_CONFIG_FILE_OPTION +
+ "\" doesn't exist: " + cacheConfig);
+ }
+
+ store = new JBossCacheIdentityStoreWrapper(store, cacheConfig);
+ }
+
if (store == null)
{
throw new IdentityException("Mapped IdentityStore not available: "
+ storeId);
Added: idm/trunk/idm/src/test/resources/jboss-cache-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/jboss-cache-config.xml (rev
0)
+++ idm/trunk/idm/src/test/resources/jboss-cache-config.xml 2009-02-02 13:39:43 UTC (rev
271)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
+
+</jbosscache>
\ No newline at end of file
Deleted: idm/trunk/idm/src/test/resources/logging.properties
===================================================================
--- idm/trunk/idm/src/test/resources/logging.properties 2009-02-02 06:07:32 UTC (rev 270)
+++ idm/trunk/idm/src/test/resources/logging.properties 2009-02-02 13:39:43 UTC (rev 271)
@@ -1,61 +0,0 @@
-# Properties file which configures the operation of the JDK
-# logging facility.
-
-# The system will look for this config file, first using
-# a System property specified at startup:
-#
-# >java -Djava.util.logging.config.file=myLoggingConfigFilePath
-#
-# If this property is not specified, then the config file is
-# retrieved from its default location at:
-#
-# JDK_HOME/jre/lib/logging.properties
-
-# Global logging properties.
-# ------------------------------------------
-# The set of handlers to be loaded upon startup.
-# Comma-separated list of class names.
-# (? LogManager docs say no comma here, but JDK example has comma.)
-handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
-
-# Default global logging level.
-# Loggers and Handlers may override this level
-.level=FINER
-
-# Loggers
-# ------------------------------------------
-# Loggers are usually attached to packages.
-# Here, the level for each package is specified.
-# The global level is used by default, so levels
-# specified here simply act as an override.
-
-#myapp.ui.level=ALL
-#myapp.business.level=CONFIG
-#myapp.data.level=SEVERE
-
-# Handlers
-# -----------------------------------------
-
-# --- ConsoleHandler ---
-# Override of global logging level
-java.util.logging.ConsoleHandler.level=FINER
-java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
-
-# --- FileHandler ---
-# Override of global logging level
-java.util.logging.FileHandler.level=ALL
-
-# Naming style for the output file:
-# (The output file is placed in the directory
-# defined by the "user.home" System property.)
-java.util.logging.FileHandler.pattern=%h/java%u.log
-
-# Limiting size of output file in bytes:
-java.util.logging.FileHandler.limit=50000
-
-# Number of output files to cycle through, by appending an
-# integer to the base file name:
-java.util.logging.FileHandler.count=1
-
-# Style of output (Simple or XML):
-java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
\ No newline at end of file
Modified: idm/trunk/idm/src/test/resources/organization-test-config.xml
===================================================================
--- idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-02-02 06:07:32 UTC
(rev 270)
+++ idm/trunk/idm/src/test/resources/organization-test-config.xml 2009-02-02 13:39:43 UTC
(rev 271)
@@ -83,7 +83,16 @@
<identity-object-type>ORGANIZATION_UNIT</identity-object-type>
<identity-object-type>DEPARTMENT</identity-object-type>
</identity-object-types>
- <options/>
+ <options>
+ <option>
+ <name>cache</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>cache.config-file</name>
+
<value>src/test/resources/jboss-cache-config.xml</value>
+ </option>
+ </options>
</identity-store-mapping>
</identity-store-mappings>
<options>
@@ -121,7 +130,16 @@
<identity-object-type>ORGANIZATION_UNIT</identity-object-type>
<identity-object-type>OFFICE</identity-object-type>
</identity-object-types>
- <options/>
+ <options>
+ <option>
+ <name>cache</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>cache.config-file</name>
+
<value>src/test/resources/jboss-cache-config.xml</value>
+ </option>
+ </options>
</identity-store-mapping>
</identity-store-mappings>
<options>
Copied: idm/trunk/parent/logging.properties (from rev 260,
idm/trunk/idm/src/test/resources/logging.properties)
===================================================================
--- idm/trunk/parent/logging.properties (rev 0)
+++ idm/trunk/parent/logging.properties 2009-02-02 13:39:43 UTC (rev 271)
@@ -0,0 +1,63 @@
+# Properties file which configures the operation of the JDK
+# logging facility.
+
+# The system will look for this config file, first using
+# a System property specified at startup:
+#
+# >java -Djava.util.logging.config.file=myLoggingConfigFilePath
+#
+# If this property is not specified, then the config file is
+# retrieved from its default location at:
+#
+# JDK_HOME/jre/lib/logging.properties
+
+# Global logging properties.
+# ------------------------------------------
+# The set of handlers to be loaded upon startup.
+# Comma-separated list of class names.
+# (? LogManager docs say no comma here, but JDK example has comma.)
+handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+# Loggers and Handlers may override this level
+.level=SEVERE
+
+# Loggers
+# ------------------------------------------
+# Loggers are usually attached to packages.
+# Here, the level for each package is specified.
+# The global level is used by default, so levels
+# specified here simply act as an override.
+
+#myapp.ui.level=ALL
+#myapp.business.level=CONFIG
+#myapp.data.level=SEVERE
+
+org.jboss.identity.idm.level=FINER
+
+# Handlers
+# -----------------------------------------
+
+# --- ConsoleHandler ---
+# Override of global logging level
+java.util.logging.ConsoleHandler.level=ALL
+java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
+
+# --- FileHandler ---
+# Override of global logging level
+java.util.logging.FileHandler.level=ALL
+
+# Naming style for the output file:
+# (The output file is placed in the directory
+# defined by the "user.home" System property.)
+java.util.logging.FileHandler.pattern=%h/java%u.log
+
+# Limiting size of output file in bytes:
+java.util.logging.FileHandler.limit=50000
+
+# Number of output files to cycle through, by appending an
+# integer to the base file name:
+java.util.logging.FileHandler.count=1
+
+# Style of output (Simple or XML):
+java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
\ No newline at end of file
Modified: idm/trunk/parent/pom.xml
===================================================================
--- idm/trunk/parent/pom.xml 2009-02-02 06:07:32 UTC (rev 270)
+++ idm/trunk/parent/pom.xml 2009-02-02 13:39:43 UTC (rev 271)
@@ -1,101 +1,107 @@
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>3</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.identity</groupId>
- <artifactId>idm-parent</artifactId>
- <packaging>pom</packaging>
- <version>1.0.0-SNAPSHOT</version>
- <name>JBoss Identity IDM- Parent</name>
- <
url>http://labs.jboss.org/portal/jbosssecurity/</url>
- <description>JBoss Identity is a cross-cutting project that handles identity
needs for the JEMS projects</description>
- <licenses>
- <license>
- <name>lgpl</name>
- <
url>http://repository.jboss.com/licenses/lgpl.txt</url>
- </license>
- </licenses>
- <organization>
- <name>JBoss Inc.</name>
- <url>http://www.jboss.org</url>
- </organization>
- <scm>
-
<
connection>scm:svn:http://anonsvn.jboss.org/repos/jbossidentity/idm/tr...
-
<
developerConnection>scm:svn:https://svn.jboss.org/repos/jbossidentity/...
- </scm>
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>3</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.identity</groupId>
+ <artifactId>idm-parent</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>JBoss Identity IDM- Parent</name>
+ <
url>http://labs.jboss.org/portal/jbosssecurity/</url>
+ <description>JBoss Identity is a cross-cutting project that handles identity
needs for the JEMS projects</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <
url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+ <scm>
+
<
connection>scm:svn:http://anonsvn.jboss.org/repos/jbossidentity/idm/tr...
+
<
developerConnection>scm:svn:https://svn.jboss.org/repos/jbossidentity/...
+ </scm>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <configuration>
-
<
tagBase>https://svn.jboss.org/repos/jbossidentity/tags</tagBase>
- </configuration>
- </plugin>
- </plugins>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <printSummary>true</printSummary>
- <disableXmlReport>false</disableXmlReport>
- <testFailureIgnore>false</testFailureIgnore>
- <includes>
- <include>**/*TestCase.java</include>
- </includes>
- <forkMode>pertest</forkMode>
- <argLine>${surefire.jvm.args}</argLine>
- <useFile>false</useFile>
- <trimStackTrace>false</trimStackTrace>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+
<
tagBase>https://svn.jboss.org/repos/jbossidentity/tags</tagBase>
+ </configuration>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <printSummary>true</printSummary>
+ <disableXmlReport>false</disableXmlReport>
+ <testFailureIgnore>false</testFailureIgnore>
+ <includes>
+ <include>**/*TestCase.java</include>
+ </includes>
+ <forkMode>pertest</forkMode>
+ <argLine>${surefire.jvm.args}</argLine>
+ <useFile>false</useFile>
+ <trimStackTrace>false</trimStackTrace>
+ <systemProperties>
+ <property>
+ <name>java.util.logging.config.file</name>
+ <value>../parent/logging.properties</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <layout>default</layout>
- <
url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <
url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
- <repository>
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshots Repository</name>
- <layout>default</layout>
- <
url>http://snapshots.jboss.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
- </repositories>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <
url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
</project>