DATAJPA-28 - Changed invocation order of createIsNewStrategy(…).

Lazily initializing the IsNewAware on first access now as classes implementing the method might wanna delegate to a template method using a constructor parameter. If createIsNewStrategy(…) is called from our constructor already the subclasses additional constructor arguments are not available yet.
This commit is contained in:
Oliver Gierke
2011-02-22 21:42:49 +01:00
parent dd45054da2
commit 7753b9b446

View File

@@ -33,7 +33,7 @@ public abstract class RepositorySupport<T, ID extends Serializable> implements
Repository<T, ID> {
private final Class<T> domainClass;
private final IsNewAware isNewStrategy;
private IsNewAware isNewStrategy;
/**
@@ -45,8 +45,6 @@ public abstract class RepositorySupport<T, ID extends Serializable> implements
Assert.notNull(domainClass);
this.domainClass = domainClass;
this.isNewStrategy = createIsNewStrategy(domainClass);
Assert.notNull(isNewStrategy);
}
@@ -81,6 +79,11 @@ public abstract class RepositorySupport<T, ID extends Serializable> implements
*/
protected IsNewAware getIsNewStrategy() {
if (isNewStrategy == null) {
this.isNewStrategy = createIsNewStrategy(domainClass);
Assert.notNull(isNewStrategy);
}
return isNewStrategy;
}
}