diff --git a/base/pom.xml b/base/pom.xml
index 0e693215..e6402585 100644
--- a/base/pom.xml
+++ b/base/pom.xml
@@ -32,6 +32,10 @@
+
+ com.structurizr
+ structurizr-dsl
+
com.structurizr
structurizr-plantuml
diff --git a/base/src/main/java/org/ndx/agile/architecture/base/ArchitectureDocumentationBuilder.java b/base/src/main/java/org/ndx/agile/architecture/base/ArchitectureDocumentationBuilder.java
index 301d23a5..63faa913 100644
--- a/base/src/main/java/org/ndx/agile/architecture/base/ArchitectureDocumentationBuilder.java
+++ b/base/src/main/java/org/ndx/agile/architecture/base/ArchitectureDocumentationBuilder.java
@@ -1,9 +1,12 @@
package org.ndx.agile.architecture.base;
import java.io.IOException;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.se.SeContainer;
import javax.enterprise.inject.se.SeContainerInitializer;
import javax.inject.Inject;
@@ -38,7 +41,7 @@ public static void main(String[] args) throws Throwable {
@Inject Logger logger;
@Inject @UsesComponent(description = "Adds information to initial architecture description") ArchitectureEnhancer enhancer;
- @Inject @UsesComponent(description = "Generates initial architecture description") ArchitectureModelProvider provider;
+ @Inject @UsesComponent(description = "Generates initial architecture description") @Any Instance availableProviders;
/**
* Run method that will allow the description to be invoked and augmentations to be performed
@@ -46,8 +49,21 @@ public static void main(String[] args) throws Throwable {
* @throws IOException
*/
public void run() throws IOException {
- Workspace workspace = provider.describeArchitecture();
+ Workspace workspace = getArchitecture();
logger.info("Architecture has been described. Now enhancing it (including writing the diagrams)!");
enhancer.enhance(workspace);
}
+
+ private Workspace getArchitecture() {
+ for(ArchitectureModelProvider provider : availableProviders) {
+ try {
+ return provider.describeArchitecture();
+ } catch(Throwable e) {
+ logger.log(Level.WARNING,
+ String.format("model provider %s failed to load any workspace", provider.getClass().getName()),
+ e);
+ }
+ }
+ throw new UnsupportedOperationException("There is no instance of ArchitectureModelProvider defined in project, and no workspace.dsl file to parse");
+ }
}
diff --git a/base/src/main/java/org/ndx/agile/architecture/base/providers/FromDsl.java b/base/src/main/java/org/ndx/agile/architecture/base/providers/FromDsl.java
new file mode 100644
index 00000000..ddca20af
--- /dev/null
+++ b/base/src/main/java/org/ndx/agile/architecture/base/providers/FromDsl.java
@@ -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();
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 8279ac78..9e875454 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,6 +97,11 @@
deltaspike-core-impl
1.9.5
+
+ com.structurizr
+ structurizr-dsl
+ 1.18.0
+
com.structurizr
structurizr-client