-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
69 additions
and
2 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
42 changes: 42 additions & 0 deletions
42
base/src/main/java/org/ndx/agile/architecture/base/providers/FromDsl.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,42 @@ | ||
package org.ndx.agile.architecture.base.providers; | ||
|
||
import java.io.File; | ||
|
||
import javax.enterprise.inject.Alternative; | ||
import javax.inject.Inject; | ||
|
||
import org.apache.deltaspike.core.api.config.ConfigProperty; | ||
import org.ndx.agile.architecture.base.ArchitectureModelProvider; | ||
import org.ndx.agile.architecture.base.enhancers.ModelElementKeys; | ||
|
||
import com.structurizr.Workspace; | ||
import com.structurizr.dsl.StructurizrDslParser; | ||
import com.structurizr.dsl.StructurizrDslParserException; | ||
|
||
@Alternative | ||
public class FromDsl implements ArchitectureModelProvider { | ||
|
||
private static final String WORKSPACE_DSL = ModelElementKeys.PREFIX + "dsl"; | ||
@Inject | ||
@ConfigProperty(name = WORKSPACE_DSL, defaultValue = "src/architecture/resources/workspace.dsl") File workspace; | ||
|
||
@Override | ||
public Workspace describeArchitecture() { | ||
if(!workspace.exists()) { | ||
throw new UnsupportedOperationException(String.format( | ||
"Parsing a workspace.dsl file supposes the file exists.\n" | ||
+ "We tried to read file %s but there was nothing.\n" | ||
+ "Please either move that file into that location or set the property %s", | ||
workspace.getAbsolutePath(), | ||
WORKSPACE_DSL)); | ||
} | ||
StructurizrDslParser parser = new StructurizrDslParser(); | ||
try { | ||
parser.parse(workspace); | ||
} catch (StructurizrDslParserException e) { | ||
throw new RuntimeException("Can't read workspace.dsl", e); | ||
} | ||
return parser.getWorkspace(); | ||
} | ||
|
||
} |
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