KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > test > internal > performance > PerformanceMeterFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.test.internal.performance;
13
14 import java.util.HashSet JavaDoc;
15 import java.util.Set JavaDoc;
16
17 import org.eclipse.test.performance.Performance;
18 import org.eclipse.test.performance.PerformanceMeter;
19
20 import junit.framework.TestCase;
21
22 public abstract class PerformanceMeterFactory {
23     
24     private static Set JavaDoc fScenarios= new HashSet JavaDoc();
25     
26     public PerformanceMeter createPerformanceMeter(String JavaDoc scenario) {
27         assertUniqueScenario(scenario);
28         return doCreatePerformanceMeter(scenario);
29     }
30
31     public PerformanceMeter createPerformanceMeter(TestCase testCase, String JavaDoc monitorId) {
32         return createPerformanceMeter(Performance.getDefault().getDefaultScenarioId(testCase, monitorId));
33     }
34
35     public PerformanceMeter createPerformanceMeter(TestCase testCase) {
36         return createPerformanceMeter(Performance.getDefault().getDefaultScenarioId(testCase));
37     }
38
39     protected abstract PerformanceMeter doCreatePerformanceMeter(String JavaDoc scenario);
40     
41     private static void assertUniqueScenario(String JavaDoc scenario) {
42         if (fScenarios.contains(scenario))
43             throw new IllegalArgumentException JavaDoc();
44         fScenarios.add(scenario);
45     }
46 }
47
Popular Tags