M - the specific model typepublic class DefaultImportResolver<M extends IModel> extends ImportResolver<M>
| Modifier and Type | Field and Description |
|---|---|
private boolean |
allowCycles |
private ModelInfo<M> |
conflictMarker |
static boolean |
IMPORT_WITH_VERSION
Allows to switch easily to the primitive (non-version checking) variant.
|
private java.util.Map<ModelInfo<M>,M> |
localModelOverride |
| Constructor and Description |
|---|
DefaultImportResolver()
Creates a resolver instance which, by default, does not allow cycles in the model imports.
|
DefaultImportResolver(boolean allowCycles)
Creates a resolver instance which may allow cycles.
|
| Modifier and Type | Method and Description |
|---|---|
private java.util.List<ModelImport<M>> |
addConflict(java.util.List<ModelImport<M>> conflicts,
ModelImport<M> conflict)
Adds the given
conflict conflicts to conflicts. |
protected void |
cannotResolveImport(ModelImport<M> imp,
java.util.List<IMessage> messages,
java.net.URI modelURI,
IRestrictionEvaluationContext context)
Is called if
imp can finally not be resolved. |
private void |
checkImportCycles(M model,
java.util.List<IMessage> messages,
java.util.Set<M> done)
Checks the import structure of
model for cycles. |
protected boolean |
checkImported(ModelImport<M> imp,
M model,
java.util.List<IMessage> messages)
Checks the imported interfaces for obvious import problems, such as importing models
with interfaces as a whole.
|
void |
clear()
Clears this instance for reuse.
|
private ModelInfo<M> |
determineMatching(ResolutionContext<M> context,
java.util.List<VersionedModelInfos<M>> versions,
IVersionRestriction restriction)
Determine the model matching the import restrictions.
|
private void |
handleImport(ResolutionContext<M> context,
ModelImport<?> imp,
java.util.List<ModelImport<M>> todo)
Handles an import.
|
private void |
handleImports(ResolutionContext<M> context,
M model,
java.util.List<ModelImport<M>> todo)
Handles all imports for the given model.
|
private java.util.List<ModelImport<M>> |
load(ResolutionContext<M> context,
java.util.HashSet<M> done,
ModelInfo<M> toLoad,
java.util.List<IMessage> messages,
ModelImport<M> imp,
java.util.List<ModelImport<M>> conflicts)
Loads the given model information, checks it for conflicts.
|
private java.util.List<ModelImport<M>> |
resolve(ResolutionContext<M> context,
java.util.HashSet<M> done,
java.util.List<IMessage> messages)
Resolves the import represented by
context. |
private java.util.List<ModelImport<M>> |
resolve(ResolutionContext<M> context,
java.util.HashSet<M> done,
java.util.List<IMessage> messages,
java.util.List<VersionedModelInfos<M>> versions,
ModelImport<M> imp)
Resolves the import / conflict represented by
imp. |
M |
resolve(java.lang.String modelName,
IVersionRestriction restrictions,
java.net.URI baseUri,
IModelRepository<M> repository,
IRestrictionEvaluationContext evaluationContext)
Resolves the denoted model considering the given
restrictions. |
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 given
model and returns
messages on failures. |
private java.util.List<ModelImport<M>> |
resolveImports(ResolutionContext<M> context,
java.util.HashSet<M> done,
java.util.List<IMessage> messages)
Resolves the imports of the model in the given
context and returns
messages on failures. |
private void |
setUnresolved(M model,
java.util.List<ModelImport<M>> conflicts)
Sets the given
model and its import recursively to unresolved. |
private void |
setUnresolved(M model,
ModelImport<M> imp,
java.util.List<ModelImport<M>> conflicts)
Sets the given import in
model and its imports recursively to unresolved. |
addDeferredLoader, getProcessingListener, isTransitiveLoadingEnabled, notifyProcessing, setProcessingListener, setTransitiveLoadingpublic static final boolean IMPORT_WITH_VERSION
private final java.util.Map<ModelInfo<M extends IModel>,M extends IModel> localModelOverride
private boolean allowCycles
public DefaultImportResolver()
public DefaultImportResolver(boolean allowCycles)
allowCycles - if true, allow and resolve cycles, if false emit an errorpublic void clear()
ImportResolverclear in class ImportResolver<M extends IModel>public java.util.List<IMessage> resolveImports(M model, java.net.URI uri, java.util.List<ModelInfo<M>> inProgress, IModelRepository<M> repository, IRestrictionEvaluationContext evaluationContext)
ImportResolvermodel and 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 modify model
as a side effect.resolveImports in class ImportResolver<M extends IModel>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)private void checkImportCycles(M model, java.util.List<IMessage> messages, java.util.Set<M> done)
model for cycles.model - the (root) model to be checkedmessages - which occur during resolution, null or empty
if none (modified as a side effect)done - for detecting cyclic imports (modified as a side effect)private java.util.List<ModelImport<M>> resolveImports(ResolutionContext<M> context, java.util.HashSet<M> done, java.util.List<IMessage> messages)
context and 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.context - the context of the models to be resolveddone - for detecting cyclic imports (modified as a side effect)messages - which occur during resolution, null or empty
if none (modified as a side effect)private void setUnresolved(M model, java.util.List<ModelImport<M>> conflicts)
model and its import recursively to unresolved.model - the model to be set to unresolvedconflicts - the conflicts to unresolve exclusively, i.e., if not null other
imports are not modified, otherwise all imports are set to unresolvedprivate void setUnresolved(M model, ModelImport<M> imp, java.util.List<ModelImport<M>> conflicts)
model and its imports recursively to unresolved.model - the model containing impimp - the import to be set to unresolvedconflicts - the conflicts to unresolve exclusively, i.e., if not null other
imports are not modified, otherwise all imports are set to unresolvedprivate void handleImports(ResolutionContext<M> context, M model, java.util.List<ModelImport<M>> todo)
context - the resolution contextmodel - the model to handle the importstodo - the imports to be handled in the calling step (may be null, then no todo list is built up)private void handleImport(ResolutionContext<M> context, ModelImport<?> imp, java.util.List<ModelImport<M>> todo)
todo.context - the context of the models to be resolved (may be modified as a side effect)imp - the import to be handledtodo - the imports to be handled in the calling step (may be null, then no todo list is built up)private ModelInfo<M> determineMatching(ResolutionContext<M> context, java.util.List<VersionedModelInfos<M>> versions, IVersionRestriction restriction) throws ModelManagementException
context - the import contextversions - the already known and matching model information objectsrestriction - the version restriction (may be null)conflictMarker if no matching
model was determined due to conflicts on all possible candidates)ModelManagementException - in case of restriction evaluation problemsprivate java.util.List<ModelImport<M>> addConflict(java.util.List<ModelImport<M>> conflicts, ModelImport<M> conflict)
conflict conflicts to conflicts. conflicts may be
null and is created then lazily.conflicts - the conflicts set to add the toAdd conflicts toconflict - the conflicts to be addedconflicts if not null, a new list otherwiseprivate java.util.List<ModelImport<M>> resolve(ResolutionContext<M> context, java.util.HashSet<M> done, java.util.List<IMessage> messages, java.util.List<VersionedModelInfos<M>> versions, ModelImport<M> imp)
imp.context - the import contextdone - for detecting cyclic imports (modified as a side effect)messages - which occur during resolution, null or empty
if none (modified as a side effect)versions - the already known and matching model information objectsimp - the import to be resolvedprotected void cannotResolveImport(ModelImport<M> imp, java.util.List<IMessage> messages, java.net.URI modelURI, IRestrictionEvaluationContext context)
imp can finally not be resolved.imp - the import to be resolvedmessages - which occur during resolution, null or empty
if none (modified as a side effect)modelURI - the URI of the modelcontext - the restriction evaluation contextprivate java.util.List<ModelImport<M>> load(ResolutionContext<M> context, java.util.HashSet<M> done, ModelInfo<M> toLoad, java.util.List<IMessage> messages, ModelImport<M> imp, java.util.List<ModelImport<M>> conflicts)
context - the import contextdone - for detecting cyclic imports (modified as a side effect)toLoad - the model to loadmessages - which occur during resolution, null or empty
if none (modified as a side effect)imp - the import to be resolvedconflicts - the actual import conflicts (may be null if none were detected so far)protected boolean checkImported(ModelImport<M> imp, M model, java.util.List<IMessage> messages)
imp - the import to be resolvedmodel - the model which may resolve the importmessages - which occur during resolution, null or empty
if none (modified as a side effect)true if the import is fine, true if problems were detectedpublic M resolve(java.lang.String modelName, IVersionRestriction restrictions, java.net.URI baseUri, IModelRepository<M> repository, IRestrictionEvaluationContext evaluationContext) throws ModelManagementException
ImportResolverrestrictions.resolve in class ImportResolver<M extends IModel>modelName - the name of the modelrestrictions - 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)ModelManagementException - in case of resolution failuresprivate java.util.List<ModelImport<M>> resolve(ResolutionContext<M> context, java.util.HashSet<M> done, java.util.List<IMessage> messages)
context.context - the context to resolve (including the import to resolve)done - for detecting cyclic imports (modified as a side effect)messages - which occur during resolution, null or empty
if none (modified as a side effect)Copyright © 2009 - 2018 SSE. All Rights Reserved.