1 | |
package com.aurea.maven.plugins.sonic.sdm.util; |
2 | |
|
3 | |
import org.apache.maven.plugin.logging.Log; |
4 | |
import org.apache.maven.project.MavenProject; |
5 | |
|
6 | |
import com.aurea.maven.plugins.sonic.utils.DependencyAnalyzer; |
7 | |
|
8 | |
public class ESBDeploymentModelBuilder { |
9 | |
|
10 | |
public static final String XARS_DIR_NAME = "xars"; |
11 | |
public static final String SDM_DIR_NAME = "sdm"; |
12 | |
public static final String TAILOR_DIR_NAME = "tailor"; |
13 | |
public static final String SDM_SNIPPET_DIR_NAME = "sdm-snippets"; |
14 | |
public static final String DEFAULT_SDM_HOST_VALUE = "ESBHost"; |
15 | |
public static final String DEFAULT_XAR_HOST_VALUE = "XARHost"; |
16 | |
|
17 | 0 | private Log log = null; |
18 | 0 | private MavenProject project = null; |
19 | 0 | private DependencyAnalyzer depAnalyzer = null; |
20 | 0 | private ESBDeploymentModel model = null; |
21 | |
|
22 | 0 | private ESBModelContribution[] contributions = null; |
23 | |
|
24 | 0 | public ESBDeploymentModelBuilder(MavenProject project, Log log) { |
25 | 0 | this.project = project; |
26 | 0 | this.log = log; |
27 | |
|
28 | 0 | contributions = new ESBModelContribution[] { |
29 | |
new XarFileContribution(ESBDeploymentModel.CONTRIB_XAR_FILES, this), |
30 | |
new ESBProcessesContribution(ESBDeploymentModel.CONTRIB_PROCESSES, this), |
31 | |
new ESBServiceTypesContribution(ESBDeploymentModel.CONTRIB_SERVICETYPES, this), |
32 | |
new ESBServicesContribution(ESBDeploymentModel.CONTRIB_SERVICES, this) |
33 | |
}; |
34 | 0 | } |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
public ESBDeploymentModel getModel() throws Exception { |
42 | 0 | getLog().info("Building ESB Deployment Model..."); |
43 | |
|
44 | 0 | if (model == null) { |
45 | 0 | model = new ESBDeploymentModel(); |
46 | 0 | model.setProject(project); |
47 | |
|
48 | 0 | for(ESBModelContribution contrib: contributions) { |
49 | 0 | model.setModelObject(contrib.getContributionName(), contrib.getContribution()); |
50 | |
} |
51 | |
} |
52 | |
|
53 | 0 | return model; |
54 | |
} |
55 | |
|
56 | |
public DependencyAnalyzer getDepAnalyzer() { |
57 | 0 | if (depAnalyzer == null) { |
58 | 0 | depAnalyzer = new DependencyAnalyzer(getDependencyDirectory()); |
59 | |
} |
60 | 0 | return depAnalyzer; |
61 | |
} |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
public String getOutputDirectory() { |
67 | 0 | return project.getBuild().getDirectory(); |
68 | |
} |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
public String getDependencyDirectory() { |
74 | 0 | return getOutputDirectory() + "/dependency"; |
75 | |
} |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
public String getTestDependencyDirectory() { |
81 | 0 | return getOutputDirectory() + "/sonicesb/testDependency"; |
82 | |
} |
83 | |
|
84 | |
public String getESBVersion() { |
85 | 0 | return project.getProperties().getProperty("esb.version", "7.6.0"); |
86 | |
} |
87 | |
|
88 | |
public String getSDMDir() { |
89 | 0 | return getOutputDirectory() + "/" + SDM_DIR_NAME; |
90 | |
} |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
public String getPackageXarDir() { |
98 | 0 | return getOutputDirectory() + "/sonicesb/packageXar/fileSystem"; |
99 | |
} |
100 | |
|
101 | |
public Log getLog() { |
102 | 0 | return log; |
103 | |
} |
104 | |
} |