Class ImportResolver<M extends IModel>
- java.lang.Object
-
- net.ssehub.easy.basics.modelManagement.ImportResolver<M>
-
- Type Parameters:
M- the specific model type
- Direct Known Subclasses:
DefaultImportResolver
public abstract class ImportResolver<M extends IModel> extends java.lang.ObjectBasic implementation of a model import resolver. Import resolvers may have a model processing listener to inform about loading new models. Please note that this listener is not bound to a specific project as it is the case for use withModelManagement. Further, this class enables deferred loading, i.e., (cyclic) models that perform processing of declarations first and then require later subsequent resolution of model elements.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<IDeferredModelLoader<M>>deferredLoadersprivate IModelProcessingListener<M>processingListenerprivate booleantransitiveLoading
-
Constructor Summary
Constructors Constructor Description ImportResolver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDeferredLoader(IDeferredModelLoader<M> loader)Adds a deferred loader.voidclear()Clears this instance for reuse.IModelProcessingListener<M>getProcessingListener()Returns the processing listener.booleanisTransitiveLoadingEnabled()Returns whether transitive loading is enabled.protected voidnotifyProcessing(ModelInfo<M> info, IModelProcessingListener.Type type, boolean started)Notifies the processing listener if defined.abstract Mresolve(java.lang.String modelName, IVersionRestriction restriction, java.net.URI baseUri, IModelRepository<M> repository, IRestrictionEvaluationContext evaluationContext)Resolves the denoted model considering the givenrestrictions.abstract java.util.List<IMessage>resolveImports(M model, java.net.URI uri, java.util.List<ModelInfo<M>> inProgress, IModelRepository<M> repository, IRestrictionEvaluationContext evaluationContext)Resolves the imports of the givenmodeland returns messages on failures.IModelProcessingListener<M>setProcessingListener(IModelProcessingListener<M> processingListener)Defines the actual processing listener.booleansetTransitiveLoading(boolean transitiveLoading)Enables or disables transitive loading.
-
-
-
Field Detail
-
transitiveLoading
private boolean transitiveLoading
-
processingListener
private IModelProcessingListener<M extends IModel> processingListener
-
deferredLoaders
private java.util.List<IDeferredModelLoader<M extends IModel>> deferredLoaders
-
-
Method Detail
-
setProcessingListener
public IModelProcessingListener<M> setProcessingListener(IModelProcessingListener<M> processingListener)
Defines the actual processing listener.- Parameters:
processingListener- the listener (may be null for none)- Returns:
- the previous listener (may be null for none)
-
getProcessingListener
public IModelProcessingListener<M> getProcessingListener()
Returns the processing listener.- Returns:
- the processing listener (may be null)
-
notifyProcessing
protected void notifyProcessing(ModelInfo<M> info, IModelProcessingListener.Type type, boolean started)
Notifies the processing listener if defined.- Parameters:
info- the information object the operation is performed ontype- the processing typestarted- whether the operation started or ended
-
clear
public void clear()
Clears this instance for reuse.
-
resolveImports
public abstract java.util.List<IMessage> resolveImports(M model, java.net.URI uri, java.util.List<ModelInfo<M>> inProgress, IModelRepository<M> repository, IRestrictionEvaluationContext evaluationContext)
Resolves the imports of the givenmodeland returns messages on failures. Exceptions might be appropriate here but the caller shall be able to decide how to handle the level of detail, i.e. whether the first message shall be emitted or all. May modifymodelas a side effect.- Parameters:
model- the model to be resolveduri- the URI of the model to resolve (in order to find the closest model, may be null)inProgress- the model information objects of the models currently being processed at once (may be null)repository- the model repositoryevaluationContext- the context for evaluating import restrictions (variable definitions... interpreted locally)- Returns:
- messages which occur during resolution
-
resolve
public abstract M resolve(java.lang.String modelName, IVersionRestriction restriction, java.net.URI baseUri, IModelRepository<M> repository, IRestrictionEvaluationContext evaluationContext) throws ModelManagementException
Resolves the denoted model considering the givenrestrictions.- Parameters:
modelName- the name of the modelrestriction- the version restriction (may be null if there is none)baseUri- the URI to start resolving from (may be the URI of a model)repository- the model repositoryevaluationContext- the context for evaluating import restrictions (variable definitions... interpreted locally)- Returns:
- the resolved model
- Throws:
ModelManagementException- in case of resolution failures
-
setTransitiveLoading
public boolean setTransitiveLoading(boolean transitiveLoading)
Enables or disables transitive loading. By default, transitive loading is enabled, i.e., while resolution unknown models are loaded and resolved. If disabled, such models are not resolved at all.- Parameters:
transitiveLoading- whether transitive loading is enabled- Returns:
- the value of the transitive loading before setting the value
-
isTransitiveLoadingEnabled
public boolean isTransitiveLoadingEnabled()
Returns whether transitive loading is enabled.- Returns:
trueif transitive loading is enabled,falseelse
-
addDeferredLoader
public void addDeferredLoader(IDeferredModelLoader<M> loader)
Adds a deferred loader.- Parameters:
loader- the loader
-
-