[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 | |
---|
[922] | 17 | import de.ugoe.cs.autoquest.tasktrees.temporalrelation.TemporalRelationshipRuleManager; |
---|
[1146] | 18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; |
---|
| 19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; |
---|
| 20 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; |
---|
| 21 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; |
---|
[439] | 22 | |
---|
| 23 | /** |
---|
[1154] | 24 | * <p> |
---|
[1733] | 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. |
---|
[1154] | 29 | * </p> |
---|
[439] | 30 | * |
---|
[1154] | 31 | * @version 1.0 |
---|
| 32 | * @author pharms |
---|
[439] | 33 | */ |
---|
[557] | 34 | public class ComponentManager { |
---|
[439] | 35 | |
---|
[1733] | 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 | } |
---|
[439] | 45 | |
---|
[1733] | 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 | } |
---|
[439] | 56 | |
---|
[1733] | 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 | } |
---|
[439] | 67 | |
---|
[1733] | 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 | } |
---|
[439] | 82 | |
---|
[1733] | 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 | } |
---|
[439] | 93 | |
---|
[1733] | 94 | /** |
---|
| 95 | * <p> |
---|
| 96 | * singleton instance of this class |
---|
| 97 | * </p> |
---|
| 98 | */ |
---|
| 99 | private static ComponentManager instance; |
---|
[439] | 100 | |
---|
[1733] | 101 | /** |
---|
| 102 | * <p> |
---|
| 103 | * the default temporal relationship rule manager |
---|
| 104 | * </p> |
---|
| 105 | */ |
---|
| 106 | private TemporalRelationshipRuleManager temporalRelationshipRuleManager; |
---|
[439] | 107 | |
---|
[1733] | 108 | /** |
---|
| 109 | * <p> |
---|
| 110 | * the default task builder |
---|
| 111 | * </p> |
---|
| 112 | */ |
---|
| 113 | private ITaskBuilder taskBuilder; |
---|
[439] | 114 | |
---|
[1733] | 115 | /** |
---|
| 116 | * <p> |
---|
| 117 | * the default task factory |
---|
| 118 | * </p> |
---|
| 119 | */ |
---|
| 120 | private ITaskFactory taskFactory; |
---|
[1109] | 121 | |
---|
[1733] | 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(); |
---|
[557] | 132 | |
---|
[1733] | 133 | temporalRelationshipRuleManager = new TemporalRelationshipRuleManager( |
---|
| 134 | taskFactory, taskBuilder); |
---|
| 135 | temporalRelationshipRuleManager.init(); |
---|
| 136 | } |
---|
| 137 | |
---|
[439] | 138 | } |
---|