1 package org.andromda.core.engine;
2
3 import java.util.Collection;
4 import org.andromda.core.configuration.Configuration;
5 import org.andromda.core.metafacade.ModelValidationMessage;
6
7
8
9
10
11
12
13
14
15
16 public final class Engine
17 {
18
19
20
21
22
23 public static Engine newInstance()
24 {
25 return new Engine();
26 }
27
28
29
30
31 private ModelProcessor modelProcessor;
32
33 private Engine()
34 {
35
36 this.modelProcessor = ModelProcessor.newInstance();
37 }
38
39
40
41
42
43
44
45 public void initialize(final Configuration configuration)
46 {
47 this.modelProcessor.initialize(configuration);
48 }
49
50
51
52
53
54
55
56
57
58
59
60 public ModelValidationMessage[] loadModelsIfNecessary(final Configuration configuration)
61 {
62 ModelValidationMessage[] messages = null;
63 if (configuration != null)
64 {
65 final Collection<ModelValidationMessage> messagesList =
66 this.modelProcessor.loadIfNecessary(configuration.getRepositories());
67 messages =
68 messagesList.toArray(
69 new ModelValidationMessage[messagesList.size()]);
70 }
71 return messages == null ? new ModelValidationMessage[0] : messages;
72 }
73
74
75
76
77
78
79
80
81
82
83 public ModelValidationMessage[] run(final Configuration configuration,
84 boolean lastModifiedCheck, final String historyDir)
85 {
86 ModelValidationMessage[] messages = null;
87 if (configuration != null)
88 {
89 this.modelProcessor.setHistoryDir(historyDir);
90 this.modelProcessor.setLastModifiedCheck(lastModifiedCheck);
91 messages = this.modelProcessor.process(configuration);
92 }
93 return messages == null ? new ModelValidationMessage[0] : messages;
94 }
95
96
97
98
99 public void shutdown()
100 {
101 this.modelProcessor.shutdown();
102 }
103 }