1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.tests
.state
;
15 import java
.util
.HashMap
;
18 import org
.eclipse
.linuxtools
.lttng
.state
.StateManager
;
19 import org
.eclipse
.linuxtools
.lttng
.state
.model
.LttngTraceState
;
20 import org
.eclipse
.linuxtools
.lttng
.state
.model
.StateModelFactory
;
26 public class StateManagerFactoryTestSupport
{
27 // ========================================================================
29 // =======================================================================
31 private static final Map
<String
, StateManager
> instanceBook
= new HashMap
<String
, StateManager
>();
33 // ========================================================================
35 // =======================================================================
38 * Provide a stateManager instance per trace
42 public static StateManager
getManager(String traceUniqueId
) {
43 if (traceUniqueId
== null) {
47 if (instanceBook
.containsKey(traceUniqueId
)) {
48 return instanceBook
.get(traceUniqueId
);
51 LttngTraceState traceModel
= StateModelFactory
.getStateEntryInstance();
52 StateStacksHandlerTestSupport stateInputHandler
= new StateStacksHandlerTestSupport(traceModel
);
53 StateManager manager
= new StateManager(stateInputHandler
);
55 instanceBook
.put(traceUniqueId
, manager
);
60 * Remove previously registered managers
61 * @param traceUniqueId
63 public static void removeManager(String traceUniqueId
) {
64 if (traceUniqueId
!= null && instanceBook
.containsKey(traceUniqueId
)) {
65 instanceBook
.remove(traceUniqueId
);