001 /**
002 * $Id: Synchronized.java,v 1.2 2010/01/26 18:57:17 oboehm Exp $
003 *
004 * Copyright (c) 2008 by Oliver Boehm
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 *
018 * (c)reated 13.11.2008 by oliver (ob@oasd.de)
019 */
020 package patterntesting.annotation.concurrent;
021
022 import java.lang.annotation.*;
023 import java.util.concurrent.TimeUnit;
024
025 /**
026 * Instead of synchronized methods you can mark these methods as
027 * "@Synchronized". The SynchronizedAspect in patterntesting.concurrent
028 * will use ReentrantLock to realize it and to avoid deadlocks.
029 * If you set the log level to TRACE you can get additional information
030 * about the locks and waiting threads.
031 * <br/>
032 * The default value for the timeout is 1800 seconds (30 minutes). If you
033 * want a shorter value you can use the timeout and unit attributes.
034 * Example:
035 * <code>@Synchronized(timeout=10, unit=TimeUnit.SECONDS)</code>
036 * will set the timeout to 10 seconds.
037 *
038 * @see TimeUnit
039 * @author <a href="boehm@javatux.de">oliver</a>
040 * @since 13.11.2008
041 */
042 @Documented
043 @Target({ElementType.METHOD, ElementType.TYPE})
044 @Retention(RetentionPolicy.RUNTIME)
045 public @interface Synchronized {
046
047 /**
048 * The default timeout is 30 minutes (1800 seconds).
049 */
050 long timeout() default 1800L;
051
052 /**
053 * The unit of time (with TimeUnit.SECONDS as default).
054 */
055 TimeUnit unit() default TimeUnit.SECONDS;
056
057 }