Skip to content

Commit

Permalink
Override ClassAttributeStorageFactory.flushAndClearCache
Browse files Browse the repository at this point in the history
#10365
Signed-off-by: TheBestPessimist <cristian@tbp.land>
  • Loading branch information
TheBestPessimist committed Dec 9, 2020
1 parent da442bb commit 3ccfc2d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,9 @@ public interface IHUContext extends IContextAware, IPropertiesContainer
/** @return previously added listeners that want to be notified before an empty HU is destroyed */
List<EmptyHUListener> getEmptyHUListeners();

/**
* Flush the contents stored only in memory.
* Useful for example to persist the HU Attributes.
*/
void flush();
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ public interface IAttributeStorageFactory

void setHUStorageFactory(IHUStorageFactory huStorageFactory);

default void flushAndClearCache() {}
void flushAndClearCache();
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ protected IAttributeStorage getAttributeStorageForModel(final ModelType model)
/**
* Clears internal attribute storages cache and flushes pending saves on {@link #getHUAttributesDAO()}.
*/
@Override
public final void flushAndClearCache()
{
// First thing, clear the cached attribute storages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public IAttributeStorage getAttributeStorageIfHandled(final Object model)

@Override
public final IHUAttributesDAO getHUAttributesDAO()
{
{ // TODO tbp: this exception is false: this.huAttributesDAO is NOT NULL!
throw new HUException("No IHUAttributesDAO found on " + this);
}

Expand Down Expand Up @@ -200,4 +200,13 @@ public IHUStorageFactory getHUStorageFactory()
{
return huStorageFactory;
}

@Override
public void flushAndClearCache()
{
if (huAttributesDAO != null)
{
huAttributesDAO.flushAndClearCache();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,5 @@ public void flushAndClearCache()
{
factory.flushAndClearCache();
}
getHUAttributesDAO().flushAndClearCache();
}
}

0 comments on commit 3ccfc2d

Please sign in to comment.