1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.tools.visualizer.maven; |
12 | |
|
13 | |
import org.mule.tools.visualizer.MuleVisualizer; |
14 | |
import org.mule.tools.visualizer.config.GraphConfig; |
15 | |
import org.mule.tools.visualizer.config.GraphEnvironment; |
16 | |
import org.mule.util.FileUtils; |
17 | |
|
18 | |
import java.io.IOException; |
19 | |
import java.util.Iterator; |
20 | |
import java.util.LinkedList; |
21 | |
import java.util.List; |
22 | |
|
23 | |
import org.apache.maven.plugin.AbstractMojo; |
24 | |
import org.apache.maven.plugin.MojoExecutionException; |
25 | |
import org.apache.maven.plugin.MojoFailureException; |
26 | |
|
27 | |
|
28 | |
public class MuleVisualizerPlugin extends AbstractMojo |
29 | |
{ |
30 | |
|
31 | |
|
32 | 4 | private List files = new LinkedList(); |
33 | |
|
34 | |
|
35 | |
private String exec; |
36 | |
|
37 | |
|
38 | |
private String outputdir; |
39 | |
|
40 | |
|
41 | |
private String outputfile; |
42 | |
|
43 | |
|
44 | |
private String caption; |
45 | |
|
46 | |
|
47 | |
private String mappings; |
48 | |
|
49 | |
|
50 | |
private boolean keepdotfiles; |
51 | |
|
52 | |
|
53 | |
private boolean combinefiles; |
54 | |
|
55 | |
|
56 | |
private String urls; |
57 | |
|
58 | |
|
59 | |
private String config; |
60 | |
|
61 | |
|
62 | |
private String workingdir; |
63 | |
|
64 | |
|
65 | |
private boolean showconnectors; |
66 | |
|
67 | |
|
68 | |
private boolean showmodels; |
69 | |
|
70 | |
|
71 | |
private boolean showconfig; |
72 | |
|
73 | |
|
74 | |
private boolean showagents; |
75 | |
|
76 | |
|
77 | |
private boolean showtransformers; |
78 | |
|
79 | |
|
80 | |
private boolean showall; |
81 | |
|
82 | |
|
83 | |
private String templateprops; |
84 | |
|
85 | |
public MuleVisualizerPlugin() |
86 | 4 | { |
87 | |
try |
88 | |
{ |
89 | 4 | setWorkingdir(FileUtils.getResourcePath("target", getClass())); |
90 | |
} |
91 | 0 | catch (Exception e) |
92 | |
{ |
93 | 0 | setWorkingdir(null); |
94 | 4 | } |
95 | 4 | } |
96 | |
|
97 | |
public void execute() throws MojoExecutionException, MojoFailureException |
98 | |
{ |
99 | 4 | dumpParameters(); |
100 | |
|
101 | |
try |
102 | |
{ |
103 | 4 | GraphConfig config = buildConfig(); |
104 | 4 | GraphEnvironment environment = new GraphEnvironment(config); |
105 | 4 | MuleVisualizer visualizer = new MuleVisualizer(environment); |
106 | 4 | visualizer.visualize(files); |
107 | |
} |
108 | 0 | catch (Exception e) |
109 | |
{ |
110 | 0 | throw new MojoExecutionException("Failed to run visualizer: " + e.getMessage(), e); |
111 | 4 | } |
112 | 4 | } |
113 | |
|
114 | |
private void dumpParameters() |
115 | |
{ |
116 | 4 | Iterator file = getFiles().iterator(); |
117 | 8 | while (file.hasNext()) |
118 | |
{ |
119 | 4 | getLog().info("file: " + file.next().toString()); |
120 | |
} |
121 | 4 | getLog().info("workingdir: " + getWorkingdir()); |
122 | 4 | getLog().info("outputdir: " + getOutputdir()); |
123 | 4 | } |
124 | |
|
125 | |
protected GraphConfig buildConfig() throws IOException |
126 | |
{ |
127 | |
|
128 | 4 | GraphConfig config = new GraphConfig(); |
129 | 4 | config.loadProperties(getConfig()); |
130 | 4 | config.setWorkingDirectory(getWorkingdir()); |
131 | 4 | config.setFiles(getFiles()); |
132 | 4 | config.loadTemplateProps(getTemplateprops()); |
133 | 4 | config.setOutputDirectory(getOutputdir()); |
134 | 4 | config.setOutputFilename(getOutputfile()); |
135 | 4 | config.setCaption(getCaption()); |
136 | 4 | config.setExecuteCommand(getExec()); |
137 | 4 | config.setKeepDotFiles(isKeepdotfiles()); |
138 | 4 | config.setCombineFiles(isCombinefiles()); |
139 | 4 | config.setShowAll(isShowall()); |
140 | 4 | if (!config.isShowAll()) |
141 | |
{ |
142 | 4 | config.setShowAgents(isShowagents()); |
143 | 4 | config.setShowConfig(isShowconfig()); |
144 | 4 | config.setShowConnectors(isShowconnectors()); |
145 | 4 | config.setShowModels(isShowmodels()); |
146 | 4 | config.setShowTransformers(isShowtransformers()); |
147 | |
} |
148 | 4 | config.setMappingsFile(getMappings()); |
149 | 4 | config.setUrlsFile(getUrls()); |
150 | 4 | return config; |
151 | |
} |
152 | |
|
153 | |
public void setFiles(List files) |
154 | |
{ |
155 | 4 | this.files = files; |
156 | 4 | } |
157 | |
|
158 | |
public List getFiles() |
159 | |
{ |
160 | 8 | return files; |
161 | |
} |
162 | |
|
163 | |
public void setOutputdir(String outputdir) |
164 | |
{ |
165 | 4 | this.outputdir = outputdir; |
166 | 4 | } |
167 | |
|
168 | |
public String getOutputdir() |
169 | |
{ |
170 | 8 | return outputdir; |
171 | |
} |
172 | |
|
173 | |
public void setExec(String exec) |
174 | |
{ |
175 | 0 | this.exec = exec; |
176 | 0 | } |
177 | |
|
178 | |
public String getExec() |
179 | |
{ |
180 | 4 | return exec; |
181 | |
} |
182 | |
|
183 | |
public void setOutputfile(String outputfile) |
184 | |
{ |
185 | 0 | this.outputfile = outputfile; |
186 | 0 | } |
187 | |
|
188 | |
public String getOutputfile() |
189 | |
{ |
190 | 4 | return outputfile; |
191 | |
} |
192 | |
|
193 | |
public void setCaption(String caption) |
194 | |
{ |
195 | 0 | this.caption = caption; |
196 | 0 | } |
197 | |
|
198 | |
public String getCaption() |
199 | |
{ |
200 | 4 | return caption; |
201 | |
} |
202 | |
|
203 | |
public void setMappings(String mappings) |
204 | |
{ |
205 | 0 | this.mappings = mappings; |
206 | 0 | } |
207 | |
|
208 | |
public String getMappings() |
209 | |
{ |
210 | 4 | return mappings; |
211 | |
} |
212 | |
|
213 | |
public void setKeepdotfiles(boolean keepdotfiles) |
214 | |
{ |
215 | 0 | this.keepdotfiles = keepdotfiles; |
216 | 0 | } |
217 | |
|
218 | |
public boolean isKeepdotfiles() |
219 | |
{ |
220 | 4 | return keepdotfiles; |
221 | |
} |
222 | |
|
223 | |
public void setCombinefiles(boolean combinefiles) |
224 | |
{ |
225 | 0 | this.combinefiles = combinefiles; |
226 | 0 | } |
227 | |
|
228 | |
public boolean isCombinefiles() |
229 | |
{ |
230 | 4 | return combinefiles; |
231 | |
} |
232 | |
|
233 | |
public void setUrls(String urls) |
234 | |
{ |
235 | 0 | this.urls = urls; |
236 | 0 | } |
237 | |
|
238 | |
public String getUrls() |
239 | |
{ |
240 | 4 | return urls; |
241 | |
} |
242 | |
|
243 | |
public void setConfig(String config) |
244 | |
{ |
245 | 0 | this.config = config; |
246 | 0 | } |
247 | |
|
248 | |
public String getConfig() |
249 | |
{ |
250 | 4 | return config; |
251 | |
} |
252 | |
|
253 | |
public void setWorkingdir(String workingdir) |
254 | |
{ |
255 | 4 | this.workingdir = workingdir; |
256 | 4 | } |
257 | |
|
258 | |
public String getWorkingdir() |
259 | |
{ |
260 | 8 | return workingdir; |
261 | |
} |
262 | |
|
263 | |
public void setShowconnectors(boolean showconnectors) |
264 | |
{ |
265 | 0 | this.showconnectors = showconnectors; |
266 | 0 | } |
267 | |
|
268 | |
public boolean isShowconnectors() |
269 | |
{ |
270 | 4 | return showconnectors; |
271 | |
} |
272 | |
|
273 | |
public void setShowmodels(boolean showmodels) |
274 | |
{ |
275 | 0 | this.showmodels = showmodels; |
276 | 0 | } |
277 | |
|
278 | |
public boolean isShowmodels() |
279 | |
{ |
280 | 4 | return showmodels; |
281 | |
} |
282 | |
|
283 | |
public void setShowconfig(boolean showconfig) |
284 | |
{ |
285 | 0 | this.showconfig = showconfig; |
286 | 0 | } |
287 | |
|
288 | |
public boolean isShowconfig() |
289 | |
{ |
290 | 4 | return showconfig; |
291 | |
} |
292 | |
|
293 | |
public void setShowagents(boolean showagents) |
294 | |
{ |
295 | 0 | this.showagents = showagents; |
296 | 0 | } |
297 | |
|
298 | |
public boolean isShowagents() |
299 | |
{ |
300 | 4 | return showagents; |
301 | |
} |
302 | |
|
303 | |
public void setShowtransformers(boolean showtransformers) |
304 | |
{ |
305 | 0 | this.showtransformers = showtransformers; |
306 | 0 | } |
307 | |
|
308 | |
public boolean isShowtransformers() |
309 | |
{ |
310 | 4 | return showtransformers; |
311 | |
} |
312 | |
|
313 | |
public void setShowall(boolean showall) |
314 | |
{ |
315 | 0 | this.showall = showall; |
316 | 0 | } |
317 | |
|
318 | |
public boolean isShowall() |
319 | |
{ |
320 | 4 | return showall; |
321 | |
} |
322 | |
|
323 | |
public void setTemplateprops(String templateprops) |
324 | |
{ |
325 | 0 | this.templateprops = templateprops; |
326 | 0 | } |
327 | |
|
328 | |
public String getTemplateprops() |
329 | |
{ |
330 | 4 | return templateprops; |
331 | |
} |
332 | |
} |