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

Last change on this file since 1189 was 1189, checked in by pharms, 11 years ago
  • remove a find bugs warning
  • Property svn:executable set to *
File size: 3.7 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.temporalrelation.TemporalRelationshipRuleManager;
18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder;
19import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;
20import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder;
21import 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 */
33public 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}
Note: See TracBrowser for help on using the repository browser.