-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lazy wrappers around diagram generators to make server init more …
…robust
- Loading branch information
Showing
17 changed files
with
121 additions
and
36 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
15 changes: 15 additions & 0 deletions
15
ditaa/src/main/java/org/asciidoctor/diagram/ditaa/DitaaDiagramGenerator.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,15 @@ | ||
package org.asciidoctor.diagram.ditaa; | ||
|
||
import org.asciidoctor.diagram.DiagramGenerator; | ||
import org.asciidoctor.diagram.LazyDiagramGenerator; | ||
|
||
public class DitaaDiagramGenerator extends LazyDiagramGenerator { | ||
public DitaaDiagramGenerator() { | ||
super("ditaa"); | ||
} | ||
|
||
@Override | ||
protected DiagramGenerator createGenerator() throws Exception { | ||
return new Ditaa(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
ditaa/src/main/resources/META-INF/services/org.asciidoctor.diagram.DiagramGenerator
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 |
---|---|---|
@@ -1 +1 @@ | ||
org.asciidoctor.diagram.ditaa.Ditaa | ||
org.asciidoctor.diagram.ditaa.DitaaDiagramGenerator |
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
15 changes: 15 additions & 0 deletions
15
plantuml/src/main/java/org/asciidoctor/diagram/plantuml/PlantUMLDiagramGenerator.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,15 @@ | ||
package org.asciidoctor.diagram.plantuml; | ||
|
||
import org.asciidoctor.diagram.DiagramGenerator; | ||
import org.asciidoctor.diagram.LazyDiagramGenerator; | ||
|
||
public class PlantUMLDiagramGenerator extends LazyDiagramGenerator { | ||
public PlantUMLDiagramGenerator() { | ||
super("plantuml"); | ||
} | ||
|
||
@Override | ||
protected DiagramGenerator createGenerator() throws Exception { | ||
return new PlantUML(); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
.../src/main/java/org/asciidoctor/diagram/plantuml/PlantUMLPreprocessorDiagramGenerator.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,15 @@ | ||
package org.asciidoctor.diagram.plantuml; | ||
|
||
import org.asciidoctor.diagram.DiagramGenerator; | ||
import org.asciidoctor.diagram.LazyDiagramGenerator; | ||
|
||
public class PlantUMLPreprocessorDiagramGenerator extends LazyDiagramGenerator { | ||
public PlantUMLPreprocessorDiagramGenerator() { | ||
super("plantumlpreprocessor"); | ||
} | ||
|
||
@Override | ||
protected DiagramGenerator createGenerator() throws Exception { | ||
return new PlantUMLPreprocessorDiagramGenerator(); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
plantuml/src/main/resources/META-INF/services/org.asciidoctor.diagram.DiagramGenerator
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
org.asciidoctor.diagram.plantuml.PlantUML | ||
org.asciidoctor.diagram.plantuml.PlantUMLPreprocessor | ||
org.asciidoctor.diagram.plantuml.PlantUMLDiagramGenerator | ||
org.asciidoctor.diagram.plantuml.PlantUMLPreprocessorDiagramGenerator |
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
36 changes: 36 additions & 0 deletions
36
server/src/main/java/org/asciidoctor/diagram/LazyDiagramGenerator.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,36 @@ | ||
package org.asciidoctor.diagram; | ||
|
||
import java.io.IOException; | ||
|
||
public abstract class LazyDiagramGenerator implements NamedDiagramGenerator { | ||
private final String name; | ||
private DiagramGenerator diagramGenerator; | ||
private IOException loadError; | ||
|
||
public LazyDiagramGenerator(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
protected abstract DiagramGenerator createGenerator() throws Exception; | ||
|
||
public ResponseData generate(Request request) throws IOException { | ||
if (loadError != null) { | ||
throw loadError; | ||
} | ||
|
||
if (diagramGenerator == null) { | ||
try { | ||
diagramGenerator = createGenerator(); | ||
} catch (Exception e) { | ||
loadError = new IOException(getName() + " is could not be initialised", e); | ||
throw loadError; | ||
} | ||
} | ||
|
||
return diagramGenerator.generate(request); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
server/src/main/java/org/asciidoctor/diagram/NamedDiagramGenerator.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,5 @@ | ||
package org.asciidoctor.diagram; | ||
|
||
public interface NamedDiagramGenerator extends DiagramGenerator { | ||
String getName(); | ||
} |
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
15 changes: 15 additions & 0 deletions
15
...turizr/src/main/java/org/asciidoctor/diagram/structurizr/StructurizrDiagramGenerator.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,15 @@ | ||
package org.asciidoctor.diagram.structurizr; | ||
|
||
import org.asciidoctor.diagram.DiagramGenerator; | ||
import org.asciidoctor.diagram.LazyDiagramGenerator; | ||
|
||
public class StructurizrDiagramGenerator extends LazyDiagramGenerator { | ||
public StructurizrDiagramGenerator() { | ||
super("structurizr"); | ||
} | ||
|
||
@Override | ||
protected DiagramGenerator createGenerator() throws Exception { | ||
return new Structurizr(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
structurizr/src/main/resources/META-INF/services/org.asciidoctor.diagram.DiagramGenerator
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 |
---|---|---|
@@ -1 +1 @@ | ||
org.asciidoctor.diagram.structurizr.Structurizr | ||
org.asciidoctor.diagram.structurizr.StructurizrDiagramGenerator |
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
15 changes: 15 additions & 0 deletions
15
syntrax/src/main/java/org/asciidoctor/diagram/syntrax/SyntraxDiagramGenerator.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,15 @@ | ||
package org.asciidoctor.diagram.syntrax; | ||
|
||
import org.asciidoctor.diagram.DiagramGenerator; | ||
import org.asciidoctor.diagram.LazyDiagramGenerator; | ||
|
||
public class SyntraxDiagramGenerator extends LazyDiagramGenerator { | ||
public SyntraxDiagramGenerator() { | ||
super("syntrax"); | ||
} | ||
|
||
@Override | ||
protected DiagramGenerator createGenerator() throws Exception { | ||
return new Syntrax(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
syntrax/src/main/resources/META-INF/services/org.asciidoctor.diagram.DiagramGenerator
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 |
---|---|---|
@@ -1 +1 @@ | ||
org.asciidoctor.diagram.syntrax.Syntrax | ||
org.asciidoctor.diagram.syntrax.SyntraxDiagramGenerator |