1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
2 | // |
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
4 | // you may not use this file except in compliance with the License. |
---|
5 | // You may obtain a copy of the License at |
---|
6 | // |
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
8 | // |
---|
9 | // Unless required by applicable law or agreed to in writing, software |
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
12 | // See the License for the specific language governing permissions and |
---|
13 | // limitations under the License. |
---|
14 | |
---|
15 | package de.ugoe.cs.autoquest.tasktrees.manager; |
---|
16 | |
---|
17 | import de.ugoe.cs.autoquest.tasktrees.temporalrelation.TemporalRelationshipRuleManager; |
---|
18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; |
---|
19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; |
---|
20 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; |
---|
21 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; |
---|
22 | |
---|
23 | /** |
---|
24 | * <p> |
---|
25 | * The component manager is the central reference for the distinct submodules required for |
---|
26 | * task tree generation. Such include the temporal relationship rule manager, the task equality |
---|
27 | * rule manager, the default task builder, as well as the default task factory. |
---|
28 | * </p> |
---|
29 | * |
---|
30 | * @version 1.0 |
---|
31 | * @author pharms |
---|
32 | */ |
---|
33 | public class ComponentManager { |
---|
34 | |
---|
35 | /** |
---|
36 | * <p> |
---|
37 | * singleton instance of this class |
---|
38 | * </p> |
---|
39 | */ |
---|
40 | private static ComponentManager instance; |
---|
41 | |
---|
42 | /** |
---|
43 | * <p> |
---|
44 | * the default temporal relationship rule manager |
---|
45 | * </p> |
---|
46 | */ |
---|
47 | private TemporalRelationshipRuleManager temporalRelationshipRuleManager; |
---|
48 | |
---|
49 | /** |
---|
50 | * <p> |
---|
51 | * the default task builder |
---|
52 | * </p> |
---|
53 | */ |
---|
54 | private ITaskBuilder taskBuilder; |
---|
55 | |
---|
56 | /** |
---|
57 | * <p> |
---|
58 | * the default task factory |
---|
59 | * </p> |
---|
60 | */ |
---|
61 | private ITaskFactory taskFactory; |
---|
62 | |
---|
63 | /** |
---|
64 | * <p> |
---|
65 | * returns the default temporal relationship rule manager |
---|
66 | * </p> |
---|
67 | * |
---|
68 | * @return as described |
---|
69 | */ |
---|
70 | public static TemporalRelationshipRuleManager getTemporalRelationshipRuleManager() { |
---|
71 | return getInstance().temporalRelationshipRuleManager; |
---|
72 | } |
---|
73 | |
---|
74 | /** |
---|
75 | * <p> |
---|
76 | * returns the default task builder |
---|
77 | * </p> |
---|
78 | * |
---|
79 | * @return as described |
---|
80 | */ |
---|
81 | public static ITaskBuilder getDefaultTaskBuilder() { |
---|
82 | return getInstance().taskBuilder; |
---|
83 | } |
---|
84 | |
---|
85 | /** |
---|
86 | * <p> |
---|
87 | * returns the default task factory |
---|
88 | * </p> |
---|
89 | * |
---|
90 | * @return as described |
---|
91 | */ |
---|
92 | public static ITaskFactory getDefaultTaskFactory() { |
---|
93 | return getInstance().taskFactory; |
---|
94 | } |
---|
95 | |
---|
96 | /** |
---|
97 | * <p> |
---|
98 | * clears the singleton instance. Needed for test purposes to ensure statelessness between |
---|
99 | * tests. |
---|
100 | * </p> |
---|
101 | */ |
---|
102 | public static synchronized void clearInstance() { |
---|
103 | instance = null; |
---|
104 | } |
---|
105 | |
---|
106 | /** |
---|
107 | * <p> |
---|
108 | * returns the singleton instance of this class |
---|
109 | * </p> |
---|
110 | * |
---|
111 | * @return as described |
---|
112 | */ |
---|
113 | private static synchronized ComponentManager getInstance() { |
---|
114 | if (instance == null) { |
---|
115 | instance = new ComponentManager(); |
---|
116 | instance.init(); |
---|
117 | } |
---|
118 | return instance; |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * <p> |
---|
123 | * initialized the component manager with all it default components which are the temporal |
---|
124 | * relationship rule manager, the task equality rule manager, the default task builder, as |
---|
125 | * well as the default task factory. |
---|
126 | * </p> |
---|
127 | */ |
---|
128 | private void init() { |
---|
129 | taskBuilder = new TaskBuilder(); |
---|
130 | taskFactory = new TaskFactory(); |
---|
131 | |
---|
132 | temporalRelationshipRuleManager = |
---|
133 | new TemporalRelationshipRuleManager(taskFactory, taskBuilder); |
---|
134 | temporalRelationshipRuleManager.init(); |
---|
135 | } |
---|
136 | |
---|
137 | } |
---|