source: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/manager/ComponentManager.java @ 1154

Last change on this file since 1154 was 1154, checked in by pharms, 11 years ago
  • improved java doc
  • Property svn:executable set to *
File size: 4.3 KB
Line 
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
15package de.ugoe.cs.autoquest.tasktrees.manager;
16
17import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager;
18import de.ugoe.cs.autoquest.tasktrees.temporalrelation.TemporalRelationshipRuleManager;
19import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder;
20import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;
21import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder;
22import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory;
23
24/**
25 * <p>
26 * The component manager is the central reference for the distinct submodules required for
27 * task tree generation. Such include the temporal relationship rule manager, the task equality
28 * rule manager, the default task builder, as well as the default task factory.
29 * </p>
30 *
31 * @version 1.0
32 * @author pharms
33 */
34public class ComponentManager {
35   
36    /**
37     * <p>
38     * singleton instance of this class
39     * </p>
40     */
41    private static ComponentManager instance;
42
43    /**
44     * <p>
45     * the default temporal relationship rule manager
46     * </p>
47     */
48    private TemporalRelationshipRuleManager temporalRelationshipRuleManager;
49
50    /**
51     * <p>
52     * the default task equality rule manager
53     * </p>
54     */
55    private TaskEqualityRuleManager taskEqualityRuleManager;
56
57    /**
58     * <p>
59     * the default task builder
60     * </p>
61     */
62    private ITaskBuilder taskBuilder;
63
64    /**
65     * <p>
66     * the default task factory
67     * </p>
68     */
69    private ITaskFactory taskFactory;
70
71    /**
72     * <p>
73     * returns the default temporal relationship rule manager
74     * </p>
75     *
76     * @return as described
77     */
78    public static TemporalRelationshipRuleManager getTemporalRelationshipRuleManager() {
79        return getInstance().temporalRelationshipRuleManager;
80    }
81
82    /**
83     * <p>
84     * returns the default task equality rule manager
85     * </p>
86     *
87     * @return as described
88     */
89    public static TaskEqualityRuleManager getTaskEqualityRuleManager() {
90        return getInstance().taskEqualityRuleManager;
91    }
92
93    /**
94     * <p>
95     * returns the default task builder
96     * </p>
97     *
98     * @return as described
99     */
100    public static ITaskBuilder getDefaultTaskBuilder() {
101        return getInstance().taskBuilder;
102    }
103
104    /**
105     * <p>
106     * returns the default task factory
107     * </p>
108     *
109     * @return as described
110     */
111    public static ITaskFactory getDefaultTaskFactory() {
112        return getInstance().taskFactory;
113    }
114
115    /**
116     * <p>
117     * clears the singleton instance. Needed for test purposes to ensure statelessness between
118     * tests.
119     * </p>
120     */
121    public static synchronized void clearInstance() {
122        instance = null;
123    }
124
125    /**
126     * <p>
127     * returns the singleton instance of this class
128     * </p>
129     *
130     * @return as described
131     */
132    private static synchronized ComponentManager getInstance() {
133        if (instance == null) {
134            instance = new ComponentManager();
135            instance.init();
136        }
137        return instance;
138    }
139
140    /**
141     * <p>
142     * initialized the component manager with all it default components which are the temporal
143     * relationship rule manager, the task equality rule manager, the default task builder, as
144     * well as the default task factory.
145     * </p>
146     */
147    private void init() {
148        taskEqualityRuleManager = new TaskEqualityRuleManager();
149        taskEqualityRuleManager.init();
150
151        taskBuilder = new TaskBuilder();
152        taskFactory = new TaskFactory();
153
154        temporalRelationshipRuleManager = new TemporalRelationshipRuleManager
155            (taskEqualityRuleManager, taskFactory, taskBuilder);
156        temporalRelationshipRuleManager.init();
157    }
158
159}
Note: See TracBrowser for help on using the repository browser.