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
.control
.LttngCoreProviderFactory
;
19 import org
.eclipse
.linuxtools
.lttng
.event
.LttngSyntheticEvent
;
20 import org
.eclipse
.linuxtools
.lttng
.model
.LTTngTreeNode
;
21 import org
.eclipse
.linuxtools
.lttng
.state
.LttngStateException
;
22 import org
.eclipse
.linuxtools
.lttng
.state
.trace
.IStateTraceManager
;
23 import org
.eclipse
.linuxtools
.lttng
.state
.trace
.StateTraceManager
;
24 import org
.eclipse
.linuxtools
.tmf
.component
.TmfEventProvider
;
25 import org
.eclipse
.linuxtools
.tmf
.trace
.ITmfTrace
;
31 public class StateManagerFactoryTestSupport
{
32 // ========================================================================
34 // =======================================================================
36 private static final Map
<String
, IStateTraceManager
> instanceBook
= new HashMap
<String
, IStateTraceManager
>();
37 private static TmfEventProvider
<LttngSyntheticEvent
> feventProvider
= null;
38 // ========================================================================
40 // =======================================================================
43 * Provide a stateManager instance per trace
47 public static IStateTraceManager
getManager(ITmfTrace trace
) {
48 String traceUniqueId
= trace
.getName();
50 if (traceUniqueId
== null) {
54 if (instanceBook
.containsKey(traceUniqueId
)) {
55 return instanceBook
.get(traceUniqueId
);
58 // LttngTraceState traceModel =
59 // StateModelFactory.getStateEntryInstance();
60 IStateTraceManager manager
= null;
62 if (feventProvider
== null) {
63 feventProvider
= LttngCoreProviderFactory
.getEventProvider();
66 // catch construction problems
68 LTTngTreeNode parent
= null;
71 manager
= new StateTraceManager(id
, parent
, traceUniqueId
, trace
, feventProvider
);
72 } catch (LttngStateException e
) {
76 instanceBook
.put(traceUniqueId
, manager
);
81 * Remove previously registered managers
82 * @param traceUniqueId
84 public static void removeManager(String traceUniqueId
) {
85 if (traceUniqueId
!= null && instanceBook
.containsKey(traceUniqueId
)) {
86 instanceBook
.remove(traceUniqueId
);