Author: adamw
Date: 2008-06-23 11:04:41 -0400 (Mon, 23 Jun 2008)
New Revision: 81
Modified:
trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java
trunk/src/main/org/jboss/envers/event/VersionsEventListener.java
Log:
ENVERS-7: making revisioning of collection changes configurable
Modified: trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java 2008-06-23
14:43:04 UTC (rev 80)
+++ trunk/src/main/org/jboss/envers/configuration/VersionsConfiguration.java 2008-06-23
15:04:41 UTC (rev 81)
@@ -55,6 +55,9 @@
private VersionsSyncManager versionsSyncManager;
private Map<String, EntityConfiguration> entitiesConfigurations;
+ // Should a revision be generated when a not-owned relation field changes
+ private boolean generateRevisionsForCollections;
+
// Map versions entity name -> entity name
private Map<String, String> entityNamesForVersionsEntityNames = new
HashMap<String, String>();
@@ -191,8 +194,16 @@
}
}
+ private void configureFromProperties(Properties properties) {
+ String generateRevisionsForCollectionsStr =
properties.getProperty("org.jboss.envers.revisionOnCollectionChange",
+ "true");
+ generateRevisionsForCollections =
Boolean.parseBoolean(generateRevisionsForCollectionsStr);
+ }
+
@SuppressWarnings({"unchecked"})
- public void configure(final Configuration cfg) {
+ public void configure(Configuration cfg) {
+ configureFromProperties(cfg.getProperties());
+
YReflectionManager reflectionManager = getReflectionManager(cfg);
verEntCfg = VersionsEntitiesConfiguration.get(cfg, reflectionManager);
@@ -291,6 +302,10 @@
return entityNamesForVersionsEntityNames.get(versionsEntityName);
}
+ public boolean isGenerateRevisionsForCollections() {
+ return generateRevisionsForCollections;
+ }
+
public RelationDescription getRelationDescription(String entityName, String
propertyName) {
EntityConfiguration entCfg = entitiesConfigurations.get(entityName);
RelationDescription relDesc = entCfg.getRelationDescription(propertyName);
Modified: trunk/src/main/org/jboss/envers/event/VersionsEventListener.java
===================================================================
--- trunk/src/main/org/jboss/envers/event/VersionsEventListener.java 2008-06-23 14:43:04
UTC (rev 80)
+++ trunk/src/main/org/jboss/envers/event/VersionsEventListener.java 2008-06-23 15:04:41
UTC (rev 81)
@@ -45,6 +45,11 @@
private void generateCollectionChangeWorkUnits(VersionsSync verSync, EntityPersister
entityPersister,
String entityName, Object[] newState,
Object[] oldState) {
+ // Checking if this is enabled in configuration ...
+ if (!verCfg.isGenerateRevisionsForCollections()) {
+ return;
+ }
+
// Checks every property of the entity, if it is an "owned" relation to
another entity.
// If the value of that property changed, and the relation is bi-directional, a
new revision
// for the related entity is generated.
Show replies by date