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

Last change on this file was 2238, checked in by pharms, 7 years ago
  • solved some findbugs issues
  • Property svn:executable set to *
File size: 3.6 KB
RevLine 
[1113]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
[922]15package de.ugoe.cs.autoquest.tasktrees.manager;
[439]16
[922]17import de.ugoe.cs.autoquest.tasktrees.temporalrelation.TemporalRelationshipRuleManager;
[1146]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;
[439]22
23/**
[1154]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>
[439]29 *
[1154]30 * @version 1.0
31 * @author pharms
[439]32 */
[557]33public class ComponentManager {
34   
[1154]35    /**
36     * <p>
37     * singleton instance of this class
38     * </p>
39     */
[557]40    private static ComponentManager instance;
[439]41
[1154]42    /**
43     * <p>
44     * the default temporal relationship rule manager
45     * </p>
46     */
[557]47    private TemporalRelationshipRuleManager temporalRelationshipRuleManager;
[439]48
[1154]49    /**
50     * <p>
51     * the default task builder
52     * </p>
53     */
[1146]54    private ITaskBuilder taskBuilder;
[439]55
[1154]56    /**
57     * <p>
58     * the default task factory
59     * </p>
60     */
[1146]61    private ITaskFactory taskFactory;
[439]62
[557]63    /**
[1154]64     * <p>
65     * returns the default temporal relationship rule manager
66     * </p>
67     *
68     * @return as described
[557]69     */
70    public static TemporalRelationshipRuleManager getTemporalRelationshipRuleManager() {
71        return getInstance().temporalRelationshipRuleManager;
72    }
[439]73
[557]74    /**
[1154]75     * <p>
76     * returns the default task builder
77     * </p>
78     *
79     * @return as described
[557]80     */
[1146]81    public static ITaskBuilder getDefaultTaskBuilder() {
82        return getInstance().taskBuilder;
[557]83    }
[439]84
[557]85    /**
[1154]86     * <p>
87     * returns the default task factory
88     * </p>
89     *
90     * @return as described
[557]91     */
[1146]92    public static ITaskFactory getDefaultTaskFactory() {
93        return getInstance().taskFactory;
[557]94    }
[439]95
[557]96    /**
[1154]97     * <p>
98     * clears the singleton instance. Needed for test purposes to ensure statelessness between
99     * tests.
100     * </p>
[557]101     */
102    public static synchronized void clearInstance() {
103        instance = null;
[439]104    }
105
[557]106    /**
[1154]107     * <p>
108     * returns the singleton instance of this class
109     * </p>
110     *
111     * @return as described
[557]112     */
113    private static synchronized ComponentManager getInstance() {
114        if (instance == null) {
115            instance = new ComponentManager();
116            instance.init();
117        }
118        return instance;
119    }
[439]120
[557]121    /**
[1154]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>
[557]127     */
128    private void init() {
[1146]129        taskBuilder = new TaskBuilder();
130        taskFactory = new TaskFactory();
[1109]131
[1189]132        temporalRelationshipRuleManager =
133            new TemporalRelationshipRuleManager(taskFactory, taskBuilder);
[557]134    }
135
[439]136}
Note: See TracBrowser for help on using the repository browser.