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
Basic 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 with
ModelManagement. 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
FieldsModifier and TypeFieldDescriptionprivate List<IDeferredModelLoader<M>> private IModelProcessingListener<M> private boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDeferredLoader(IDeferredModelLoader<M> loader) Adds a deferred loader.voidclear()Clears this instance for reuse.Returns the processing listener.booleanReturns whether transitive loading is enabled.protected voidnotifyProcessing(ModelInfo<M> info, IModelProcessingListener.Type type, boolean started) Notifies the processing listener if defined.abstract Mresolve(String modelName, IVersionRestriction restriction, URI baseUri, IModelRepository<M> repository, IRestrictionEvaluationContext evaluationContext) Resolves the denoted model considering the givenrestrictions.resolveImports(M model, URI uri, List<ModelInfo<M>> inProgress, IModelRepository<M> repository, IRestrictionEvaluationContext evaluationContext) Resolves the imports of the givenmodeland returns messages on failures.setProcessingListener(IModelProcessingListener<M> processingListener) Defines the actual processing listener.booleansetTransitiveLoading(boolean transitiveLoading) Enables or disables transitive loading.
-
Field Details
-
transitiveLoading
private boolean transitiveLoading -
processingListener
-
deferredLoaders
-
-
Constructor Details
-
ImportResolver
public ImportResolver()
-
-
Method Details
-
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
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 List<IMessage> resolveImports(M model, URI uri, 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(String modelName, IVersionRestriction restriction, 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
Adds a deferred loader.- Parameters:
loader- the loader
-