-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scope: fix involving scoped import overrides, a new ScopePruningModul…
…e is now responsible for pruning unsolicited scopes
- Loading branch information
Showing
6 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/com/noleme/vault/parser/module/scope/ScopePruningModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.noleme.vault.parser.module.scope; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.noleme.vault.container.register.Definitions; | ||
import com.noleme.vault.container.register.ScopedDefinitions; | ||
import com.noleme.vault.exception.VaultParserException; | ||
import com.noleme.vault.parser.module.VaultModule; | ||
|
||
/** | ||
* @author Pierre LECERF ([email protected]) | ||
* Created on 27/12/2021 | ||
*/ | ||
public class ScopePruningModule implements VaultModule | ||
{ | ||
@Override | ||
public String identifier() | ||
{ | ||
return "scopes"; | ||
} | ||
|
||
@Override | ||
public void process(ObjectNode node, Definitions definitions) throws VaultParserException | ||
{ | ||
/* We loop over all scoped definitions and check if they are still actively referenced (ie. the ScopedImportExtractor did find services using them) */ | ||
for (ScopedDefinitions scope : definitions.scopes().values()) | ||
{ | ||
if (scope.isActivelyReferenced()) | ||
continue; | ||
|
||
for (String inactiveScopedService : scope.services().keys()) | ||
definitions.services().remove(inactiveScopedService); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters