public abstract class AbstractCachingRuntimeRepository extends AbstractRuntimeRepository
To be performant and thread safe we use the double checking ideom as it is discribed by doug lea.
Since we use Java 5 there is a threadsafe way to do so:
First of all we have a not synchronized look in the cache. As we assume that the cache itself is
implemented with a ConcurrentHashMap this lookup would see the real state of the map. If
there is no object yet we have to enter a synchronized block. This block is synchronized for
every cache instance so we could handle calls for different objects at same time. In this
synchonized block it is important to check again if there is an cached object now because another
thread may created one meantime (double-check). Again this only works for
ConcurrentHashMap. If there still is no object cached we create a new one. As long we are
in the synchronized block, every other thread is blocked. After the new object is created we put
it in the cache and the ConcurrentHashMap ensures that it is stored completely
initialized before another thread would get access.
There is still potentially more performance by synchronizing for different keys instead of blocking for every cache instance. This would be more complicated and should be well-considered.
| Constructor and Description |
|---|
AbstractCachingRuntimeRepository(String name,
ICacheFactory cacheFactory,
ClassLoader cl) |
| Modifier and Type | Method and Description |
|---|---|
protected List<XmlAdapter<?,?>> |
getAllInternalEnumXmlAdapters(IRuntimeRepository repository)
Returns all enumeration XmlAdapters available in this repository that generated by
Faktor-IPS.
|
protected <T> T |
getCustomRuntimeObjectInternal(Class<T> type,
String ipsObjectQualifiedName)
Same as
AbstractRuntimeRepository.getCustomRuntimeObject(Class, String) but searches only in this repository
and not the ones this repository depends on. |
protected <T> List<T> |
getEnumValuesInternal(Class<T> clazz)
Returns the list of enumeration values of the enumeration type that is identified by its
class which is provided to it.
|
protected abstract <T> T |
getNotCachedCustomObject(Class<T> type,
String ipsObjectQualifiedName) |
protected abstract <T> List<T> |
getNotCachedEnumValues(Class<T> clazz) |
protected abstract List<XmlAdapter<?,?>> |
getNotCachedEnumXmlAdapter(IRuntimeRepository repository) |
protected abstract IProductComponent |
getNotCachedProductComponent(String id) |
protected abstract IProductComponentGeneration |
getNotCachedProductComponentGeneration(GenerationId generationId) |
protected abstract ITable<?> |
getNotCachedTable(String qualifiedTableName) |
protected IProductComponentGeneration |
getProductComponentGenerationInternal(String id,
DateTime validFrom) |
protected IProductComponent |
getProductComponentInternal(String id)
Same as getProductComponent(String id) but searches only in this repository and not the ones,
this repository depends on.
|
protected ITable<?> |
getTableInternal(String qualifiedTableName)
Same as
AbstractRuntimeRepository.getTable(String)) but searches only in this repository and not the ones,
this repository depends on. |
protected void |
initCaches(ClassLoader cl) |
addDirectlyReferencedRepository, addEnumValueLookupService, getAllIpsTestCases, getAllIpsTestCases, getAllModelTypeImplementationClasses, getAllModelTypeImplementationClasses, getAllProductComponentIds, getAllProductComponentIds, getAllProductComponents, getAllProductComponents, getAllProductComponents, getAllProductComponents, getAllProductComponents, getAllProductComponentsInternal, getAllReferencedRepositories, getAllTables, getAllTables, getClassLoader, getCustomRuntimeObject, getDirectlyReferencedRepositories, getEnumValue, getEnumValue, getEnumValueLookupService, getEnumValues, getEnumValuesDefinedInType, getExistingEnumValue, getExistingProductComponent, getExistingProductComponentGeneration, getFormulaEvaluatorFactory, getIpsTest, getIpsTest, getIpsTestCase, getIpsTestCase, getIpsTestCaseInternal, getIpsTestCasesStartingWith, getIpsTestCasesStartingWith, getIpsTestSuite, getIpsTestSuite, getLatestProductComponentGeneration, getLatestProductComponentGenerationInternal, getModelType, getModelType, getModelType, getName, getNextProductComponentGeneration, getNextProductComponentGenerationInternal, getNumberOfProductComponentGenerations, getNumberOfProductComponentGenerationsInternal, getPreviousProductComponentGeneration, getPreviousProductComponentGenerationInternal, getProductComponent, getProductComponent, getProductComponentGeneration, getProductComponentGenerationInternal, getProductComponentGenerations, getProductComponentGenerations, getProductComponentInternal, getRuntimeRepositoryLookup, getTable, getTable, getTableInternal, newJAXBContext, newJAXBContext, removeEnumValueLookupService, setFormulaEvaluatorFactory, setRuntimeRepositoryLookup, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisModifiablepublic AbstractCachingRuntimeRepository(String name, ICacheFactory cacheFactory, ClassLoader cl)
protected void initCaches(ClassLoader cl)
protected IProductComponent getProductComponentInternal(String id)
AbstractRuntimeRepositorygetProductComponentInternal in class AbstractRuntimeRepositoryprotected abstract IProductComponent getNotCachedProductComponent(String id)
protected IProductComponentGeneration getProductComponentGenerationInternal(String id, DateTime validFrom)
protected abstract IProductComponentGeneration getNotCachedProductComponentGeneration(GenerationId generationId)
protected <T> List<T> getEnumValuesInternal(Class<T> clazz)
AbstractRuntimeRepositorygetEnumValuesInternal in class AbstractRuntimeRepositoryprotected ITable<?> getTableInternal(String qualifiedTableName)
AbstractRuntimeRepositoryAbstractRuntimeRepository.getTable(String)) but searches only in this repository and not the ones,
this repository depends on.getTableInternal in class AbstractRuntimeRepositoryprotected List<XmlAdapter<?,?>> getAllInternalEnumXmlAdapters(IRuntimeRepository repository)
AbstractRuntimeRepositorygetAllInternalEnumXmlAdapters in class AbstractRuntimeRepositoryrepository - the runtime repository that needs to be used by the XmlAdapters that are
returned by this methodprotected abstract List<XmlAdapter<?,?>> getNotCachedEnumXmlAdapter(IRuntimeRepository repository)
protected <T> T getCustomRuntimeObjectInternal(Class<T> type, String ipsObjectQualifiedName)
AbstractRuntimeRepositoryAbstractRuntimeRepository.getCustomRuntimeObject(Class, String) but searches only in this repository
and not the ones this repository depends on.getCustomRuntimeObjectInternal in class AbstractRuntimeRepositoryCopyright © 2020. All rights reserved.