patterntesting.runtime.monitor.JamonMonitorFactory Maven / Gradle / Ivy
Go to download
PatternTesting Runtime (patterntesting-rt) is the runtime component for
the PatternTesting framework. It provides the annotations and base classes
for the PatternTesting testing framework (e.g. patterntesting-check,
patterntesting-concurrent or patterntesting-exception) but can be also
used standalone for classpath monitoring or profiling.
It uses AOP and AspectJ to perform this feat.
The newest version!
/*
* $Id: JamonMonitorFactory.java,v 1.6 2009/12/19 22:34:09 oboehm Exp $
*
* Copyright (c) 2008 by Oliver Boehm
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* (c)reated 27.12.2008 by oliver ([email protected])
*/
package patterntesting.runtime.monitor;
import java.util.*;
import org.aspectj.lang.Signature;
import patterntesting.runtime.util.SignatureHelper;
import com.jamonapi.*;
/**
* This is a thin wrapper around com.jamonapi.MonitorFactory to keep the
* ProfileStatistic class clean from com.jamonapi dependencies.
*
* @author oliver
* @since 27.12.2008
* @version $Revision: 1.6 $
*/
public class JamonMonitorFactory {
/**
* Reset.
*/
public static void reset() {
MonitorFactory.reset();
}
/**
* Start.
*
* @param label the label
*
* @return the profile monitor
*/
public static ProfileMonitor start(String label) {
Monitor mon = MonitorFactory.start(label);
return new JamonMonitor(mon);
}
/**
* Adds the monitors.
*
* @param labels the labels
*/
public static void addMonitors(List labels) {
for (String label : labels) {
addMonitor(label);
}
}
/**
* Adds the monitor.
*
* @param label the label
*/
public static void addMonitor(String label) {
MonitorFactory.start(label);
}
/**
* Gets the monitor.
*
* @param sig the signature
*
* @return the monitor
*/
public static ProfileMonitor getMonitor(Signature sig) {
String label = SignatureHelper.getAsString(sig);
ProfileMonitor mon = JamonMonitorFactory.start(label);
return mon;
}
/**
* Gets the monitors.
*
* @return the monitors
*/
public static ProfileMonitor[] getMonitors() {
MonitorComposite rootMonitor = MonitorFactory.getRootMonitor();
Monitor[] monitors = rootMonitor.getMonitors();
if (monitors == null) {
return new JamonMonitor[0];
}
ProfileMonitor[] profMonitors = new JamonMonitor[monitors.length];
for (int i = 0; i < monitors.length; i++) {
profMonitors[i] = new JamonMonitor(monitors[i]);
}
return profMonitors;
}
}
/**
* $Log: JamonMonitorFactory.java,v $
* Revision 1.6 2009/12/19 22:34:09 oboehm
* trailing spaces removed
*
* Revision 1.5 2009/09/25 14:49:43 oboehm
* javadocs completed with the help of JAutodoc
*
* Revision 1.4 2009/04/06 07:08:53 oboehm
* detection of never called constructors implemented
*
* Revision 1.3 2009/04/03 21:30:09 oboehm
* with (Abstract)ProfileAspect it is now possible
* to find methods/constructors which are never called
*
* $Source: /cvsroot/patterntesting/PatternTesting08/patterntesting-rt/src/main/java/patterntesting/runtime/monitor/JamonMonitorFactory.java,v $
*/