001 /******************************************************************************* 002 * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian 003 * Thomschke. 004 * 005 * All Rights Reserved. This program and the accompanying materials 006 * are made available under the terms of the Eclipse Public License v1.0 007 * which accompanies this distribution, and is available at 008 * http://www.eclipse.org/legal/epl-v10.html 009 * 010 * Contributors: 011 * Sebastian Thomschke - initial implementation. 012 *******************************************************************************/ 013 package net.sf.oval.guard; 014 015 import java.lang.annotation.Documented; 016 import java.lang.annotation.ElementType; 017 import java.lang.annotation.Retention; 018 import java.lang.annotation.RetentionPolicy; 019 import java.lang.annotation.Target; 020 021 /** 022 * After the annotated method has been executed the condition is evaluated.<br> 023 * <br> 024 * In case of constraint violations the method will throw an ConstraintsViolatedException. 025 * 026 * @author Sebastian Thomschke 027 */ 028 @Documented 029 @Retention(RetentionPolicy.RUNTIME) 030 @Target({ElementType.METHOD}) 031 public @interface Post 032 { 033 /** 034 * error code passed to the ConstraintViolation object 035 */ 036 String errorCode() default "net.sf.oval.guard.Post"; 037 038 /** 039 * Formula in the given expression language describing the constraint. the formula must return true if the constraint is satisfied. 040 * <br> 041 * available variables are:<br> 042 * <b>_args[]</b> -> the current parameter values<br> 043 * <b>_old</b> -> the old values<br> 044 * <b>_returns</b> -> the method's return value 045 * <b>_this</b> -> the validated bean<br> 046 * additionally variables named accordingly to the parameters are available<br> 047 */ 048 String expr(); 049 050 /** 051 * the expression language that is used 052 */ 053 String lang(); 054 055 /** 056 * message to be used for the ContraintsViolatedException 057 * 058 * @see net.sf.oval.exception.ConstraintsViolatedException 059 */ 060 String message() default "net.sf.oval.guard.Post.violated"; 061 062 /** 063 * Formula that is evaluated prior method execution.<br> 064 * The returned value can later be accessed in the constraint expression via the variable <b>_old</b> 065 */ 066 String old() default ""; 067 068 /** 069 * The associated constraint profiles. 070 */ 071 String[] profiles() default {}; 072 073 /** 074 * severity passed to the ConstraintViolation object 075 */ 076 int severity() default 0; 077 }