1 | package de.uka.ipd.sdq.probespec.framework; |
2 | |
3 | import de.uka.ipd.sdq.probespec.framework.concurrency.ConcurrentSampleBlackboard; |
4 | import de.uka.ipd.sdq.probespec.framework.concurrency.ThreadManager; |
5 | |
6 | /** |
7 | * This factory creates instances of {@link ISampleBlackboard} for the various |
8 | * {@link BlackboardType}s. |
9 | * |
10 | * @author Philipp Merkle |
11 | * |
12 | */ |
13 | public class BlackboardFactory { |
14 | |
15 | /** |
16 | * Creates a blackboard of the specified type. If a {@link BlackboardType#CONCURRENT} blackboard |
17 | * is to be created, a <code>threadManager</code> is expected; otherwise, this parameter may |
18 | * be <code>null</code>. |
19 | * |
20 | * @param type |
21 | * the type of the blackboard to create |
22 | * @param threadManager |
23 | * the {@link ThreadManager}, if creating a {@link BlackboardType#CONCURRENT} |
24 | * blackboard; <code>null</code> else |
25 | * @return the created blackboard |
26 | */ |
27 | public static ISampleBlackboard createBlackboard(BlackboardType type, ThreadManager threadManager) { |
28 | switch (type) { |
29 | case SIMPLE: |
30 | return new SampleBlackboard(); |
31 | case CONCURRENT: |
32 | return new ConcurrentSampleBlackboard(threadManager); |
33 | case NONE: |
34 | return new NullSampleBlackboard(); |
35 | } |
36 | |
37 | throw new RuntimeException("Could not create a blackboard of type " + type.toString() |
38 | + ", as it is unknown how to handle this type."); |
39 | } |
40 | |
41 | } |