[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] | 15 | package de.ugoe.cs.autoquest.tasktrees.manager; |
---|
[439] | 16 | |
---|
[1146] | 17 | import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; |
---|
[922] | 18 | import de.ugoe.cs.autoquest.tasktrees.temporalrelation.TemporalRelationshipRuleManager; |
---|
[1146] | 19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; |
---|
| 20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; |
---|
| 21 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; |
---|
| 22 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; |
---|
[439] | 23 | |
---|
| 24 | /** |
---|
[1154] | 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> |
---|
[439] | 30 | * |
---|
[1154] | 31 | * @version 1.0 |
---|
| 32 | * @author pharms |
---|
[439] | 33 | */ |
---|
[557] | 34 | public class ComponentManager { |
---|
| 35 | |
---|
[1154] | 36 | /** |
---|
| 37 | * <p> |
---|
| 38 | * singleton instance of this class |
---|
| 39 | * </p> |
---|
| 40 | */ |
---|
[557] | 41 | private static ComponentManager instance; |
---|
[439] | 42 | |
---|
[1154] | 43 | /** |
---|
| 44 | * <p> |
---|
| 45 | * the default temporal relationship rule manager |
---|
| 46 | * </p> |
---|
| 47 | */ |
---|
[557] | 48 | private TemporalRelationshipRuleManager temporalRelationshipRuleManager; |
---|
[439] | 49 | |
---|
[1154] | 50 | /** |
---|
| 51 | * <p> |
---|
| 52 | * the default task equality rule manager |
---|
| 53 | * </p> |
---|
| 54 | */ |
---|
[1146] | 55 | private TaskEqualityRuleManager taskEqualityRuleManager; |
---|
[439] | 56 | |
---|
[1154] | 57 | /** |
---|
| 58 | * <p> |
---|
| 59 | * the default task builder |
---|
| 60 | * </p> |
---|
| 61 | */ |
---|
[1146] | 62 | private ITaskBuilder taskBuilder; |
---|
[439] | 63 | |
---|
[1154] | 64 | /** |
---|
| 65 | * <p> |
---|
| 66 | * the default task factory |
---|
| 67 | * </p> |
---|
| 68 | */ |
---|
[1146] | 69 | private ITaskFactory taskFactory; |
---|
[439] | 70 | |
---|
[557] | 71 | /** |
---|
[1154] | 72 | * <p> |
---|
| 73 | * returns the default temporal relationship rule manager |
---|
| 74 | * </p> |
---|
| 75 | * |
---|
| 76 | * @return as described |
---|
[557] | 77 | */ |
---|
| 78 | public static TemporalRelationshipRuleManager getTemporalRelationshipRuleManager() { |
---|
| 79 | return getInstance().temporalRelationshipRuleManager; |
---|
| 80 | } |
---|
[439] | 81 | |
---|
[557] | 82 | /** |
---|
[1154] | 83 | * <p> |
---|
| 84 | * returns the default task equality rule manager |
---|
| 85 | * </p> |
---|
| 86 | * |
---|
| 87 | * @return as described |
---|
[557] | 88 | */ |
---|
[1146] | 89 | public static TaskEqualityRuleManager getTaskEqualityRuleManager() { |
---|
| 90 | return getInstance().taskEqualityRuleManager; |
---|
[557] | 91 | } |
---|
[439] | 92 | |
---|
[557] | 93 | /** |
---|
[1154] | 94 | * <p> |
---|
| 95 | * returns the default task builder |
---|
| 96 | * </p> |
---|
| 97 | * |
---|
| 98 | * @return as described |
---|
[557] | 99 | */ |
---|
[1146] | 100 | public static ITaskBuilder getDefaultTaskBuilder() { |
---|
| 101 | return getInstance().taskBuilder; |
---|
[557] | 102 | } |
---|
[439] | 103 | |
---|
[557] | 104 | /** |
---|
[1154] | 105 | * <p> |
---|
| 106 | * returns the default task factory |
---|
| 107 | * </p> |
---|
| 108 | * |
---|
| 109 | * @return as described |
---|
[557] | 110 | */ |
---|
[1146] | 111 | public static ITaskFactory getDefaultTaskFactory() { |
---|
| 112 | return getInstance().taskFactory; |
---|
[557] | 113 | } |
---|
[439] | 114 | |
---|
[557] | 115 | /** |
---|
[1154] | 116 | * <p> |
---|
| 117 | * clears the singleton instance. Needed for test purposes to ensure statelessness between |
---|
| 118 | * tests. |
---|
| 119 | * </p> |
---|
[557] | 120 | */ |
---|
| 121 | public static synchronized void clearInstance() { |
---|
| 122 | instance = null; |
---|
[439] | 123 | } |
---|
| 124 | |
---|
[557] | 125 | /** |
---|
[1154] | 126 | * <p> |
---|
| 127 | * returns the singleton instance of this class |
---|
| 128 | * </p> |
---|
| 129 | * |
---|
| 130 | * @return as described |
---|
[557] | 131 | */ |
---|
| 132 | private static synchronized ComponentManager getInstance() { |
---|
| 133 | if (instance == null) { |
---|
| 134 | instance = new ComponentManager(); |
---|
| 135 | instance.init(); |
---|
| 136 | } |
---|
| 137 | return instance; |
---|
| 138 | } |
---|
[439] | 139 | |
---|
[557] | 140 | /** |
---|
[1154] | 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> |
---|
[557] | 146 | */ |
---|
| 147 | private void init() { |
---|
[1146] | 148 | taskEqualityRuleManager = new TaskEqualityRuleManager(); |
---|
| 149 | taskEqualityRuleManager.init(); |
---|
[439] | 150 | |
---|
[1146] | 151 | taskBuilder = new TaskBuilder(); |
---|
| 152 | taskFactory = new TaskFactory(); |
---|
[1109] | 153 | |
---|
| 154 | temporalRelationshipRuleManager = new TemporalRelationshipRuleManager |
---|
[1146] | 155 | (taskEqualityRuleManager, taskFactory, taskBuilder); |
---|
[1109] | 156 | temporalRelationshipRuleManager.init(); |
---|
[557] | 157 | } |
---|
| 158 | |
---|
[439] | 159 | } |
---|