1
|
|
|
package com.hltech.vaunt.generator; |
2
|
|
|
|
3
|
|
|
import com.hltech.vaunt.core.VauntSerializer; |
4
|
|
|
import com.hltech.vaunt.core.domain.model.Service; |
5
|
|
|
import com.hltech.vaunt.generator.domain.representation.RepresentationExtractor; |
6
|
|
|
import com.hltech.vaunt.generator.domain.representation.RepresentationWriter; |
7
|
|
|
import lombok.RequiredArgsConstructor; |
8
|
|
|
|
9
|
|
|
import java.io.IOException; |
10
|
|
|
import java.util.Properties; |
11
|
|
|
|
12
|
|
|
@RequiredArgsConstructor |
13
|
|
|
public class VauntGenerator { |
14
|
|
|
|
15
|
|
|
private final RepresentationExtractor extractor; |
16
|
|
|
private final RepresentationWriter writer; |
17
|
|
|
|
18
|
|
|
public VauntGenerator() { |
19
|
|
|
VauntSerializer serializer = new VauntSerializer(); |
20
|
|
|
extractor = new RepresentationExtractor(serializer); |
21
|
|
|
writer = new RepresentationWriter(serializer); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public void writeVauntFile(String packageRoot, String serviceName, String targetDirectory) { |
25
|
|
|
writeVauntFile(packageRoot, serviceName, targetDirectory, new Properties()); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public void writeVauntFile(String packageRoot, String serviceName, String targetDirectory, Properties props) { |
29
|
|
|
try { |
30
|
|
|
writer.writeServiceRepresentation( |
31
|
|
|
serviceRepresentation(packageRoot, serviceName, props), targetDirectory); |
32
|
|
|
} catch (IOException ex) { |
33
|
|
|
throw new VauntGenerationException("Error when trying to write service representation to file", ex); |
34
|
|
|
} |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
private Service serviceRepresentation(String packageRoot, String serviceName, Properties props) { |
38
|
|
|
return extractor.extractServiceRepresentation(packageRoot, serviceName, props); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|