001package org.javasimon.aop; 002 003import java.lang.annotation.ElementType; 004import java.lang.annotation.Retention; 005import java.lang.annotation.RetentionPolicy; 006import java.lang.annotation.Target; 007 008/** 009 * Annotation to mark classes and/or methods that should be monitored. A method is monitored when it is annotated, 010 * or when it is in a class that is annotated (or any of it's subclasses). {@link org.javasimon.Stopwatch} is used 011 * as a monitor. 012 * <p/> 013 * The Stopwatch name consists of a "name" part and a "suffix" part - these parts are provided using parameters of 014 * the annotation. Rules are as follows: 015 * <ul> 016 * <li>If method annotation has the name parameter it will be the name of the Stopwatch (suffix is ignored).</li> 017 * <li>Default name part is the fully qualified class name.</li> 018 * <li>Default suffix part is the name of the current method.</li> 019 * <li>Name can be overruled by class annotation parameter, this can be overruled by method annotation parameter.</li> 020 * <li>Suffix parameter overrules default method name. Suffix parameter is ignored on the class annotation.</li> 021 * </ul> 022 * If no parameter is used, name of the Stopwatch will be: {@code fully.qualified.ClassName.methodName} 023 * <p/> 024 * Current name resolution applies since version 3.1. 025 * 026 * @author Erik van Oosten 027 * @author <a href="mailto:virgo47@gmail.com">Richard "Virgo" Richter</a> 028 */ 029@Retention(value = RetentionPolicy.RUNTIME) 030@Target({ElementType.METHOD, ElementType.TYPE}) 031public @interface Monitored { 032 /** 033 * Returns the name for the {@link org.javasimon.Stopwatch} without its possible suffix - default is the class name. 034 * Using the parameter on the method annotation overrides name from the class. 035 * 036 * @return name of the used monitor 037 */ 038 String name() default ""; 039 040 /** 041 * Part added after the name part (which defaults to the class name or is specified on the class annotation). This 042 * parameter is ignored for the class annotation or if the name parameter was specified on the method 043 * annotation. If not ignored, it is added to the Stopwatch name after the Simon name separator (.). 044 * 045 * @return suffix to be added to the name of the monitor 046 */ 047 String suffix() default ""; 048}