source: branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/manager/ComponentManager.java @ 1733

Last change on this file since 1733 was 1733, checked in by rkrimmel, 10 years ago

Used Eclipse code cleanup

  • Property svn:executable set to *
File size: 3.4 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
26 * required for task tree generation. Such include the temporal relationship
27 * rule manager, the task equality rule manager, the default task builder, as
28 * 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         * clears the singleton instance. Needed for test purposes to ensure
39         * statelessness between tests.
40         * </p>
41         */
42        public static synchronized void clearInstance() {
43                instance = null;
44        }
45
46        /**
47         * <p>
48         * returns the default task builder
49         * </p>
50         *
51         * @return as described
52         */
53        public static ITaskBuilder getDefaultTaskBuilder() {
54                return getInstance().taskBuilder;
55        }
56
57        /**
58         * <p>
59         * returns the default task factory
60         * </p>
61         *
62         * @return as described
63         */
64        public static ITaskFactory getDefaultTaskFactory() {
65                return getInstance().taskFactory;
66        }
67
68        /**
69         * <p>
70         * returns the singleton instance of this class
71         * </p>
72         *
73         * @return as described
74         */
75        private static synchronized ComponentManager getInstance() {
76                if (instance == null) {
77                        instance = new ComponentManager();
78                        instance.init();
79                }
80                return instance;
81        }
82
83        /**
84         * <p>
85         * returns the default temporal relationship rule manager
86         * </p>
87         *
88         * @return as described
89         */
90        public static TemporalRelationshipRuleManager getTemporalRelationshipRuleManager() {
91                return getInstance().temporalRelationshipRuleManager;
92        }
93
94        /**
95         * <p>
96         * singleton instance of this class
97         * </p>
98         */
99        private static ComponentManager instance;
100
101        /**
102         * <p>
103         * the default temporal relationship rule manager
104         * </p>
105         */
106        private TemporalRelationshipRuleManager temporalRelationshipRuleManager;
107
108        /**
109         * <p>
110         * the default task builder
111         * </p>
112         */
113        private ITaskBuilder taskBuilder;
114
115        /**
116         * <p>
117         * the default task factory
118         * </p>
119         */
120        private ITaskFactory taskFactory;
121
122        /**
123         * <p>
124         * initialized the component manager with all it default components which
125         * are the temporal relationship rule manager, the task equality rule
126         * manager, the default task builder, as well as the default task factory.
127         * </p>
128         */
129        private void init() {
130                taskBuilder = new TaskBuilder();
131                taskFactory = new TaskFactory();
132
133                temporalRelationshipRuleManager = new TemporalRelationshipRuleManager(
134                                taskFactory, taskBuilder);
135                temporalRelationshipRuleManager.init();
136        }
137
138}
Note: See TracBrowser for help on using the repository browser.