001: /*
002: * Created on 25 Jul 2006
003: */
004: package uk.org.ponder.rsf.state.guards;
005:
006: /** "Guards" the read or write access of a particular EL path, by allowing logic
007: * supplied in a second bean to execute relative to the access - either before (PRE),
008: * after (POST) or "around" (AROUND) it.
009: *
010: * Note that the scheduling of "POST" guards may be delayed until some later time
011: * in request processing - do not rely on these for "synchronous" guarding,
012: * although their execution *is* guaranteed.
013: *
014: * NB - only POST/WRITE guards are currently supported.
015: * @author Antranig Basman (antranig@caret.cam.ac.uk)
016: *
017: */
018:
019: public class BeanGuard {
020: public static final String READ = "READ";
021: public static final String WRITE = "WRITE";
022:
023: public static final String PRE = "PRE";
024: public static final String POST = "POST";
025: public static final String AROUND = "AROUND";
026:
027: private String guardedpath;
028: private Object guard;
029: private String mode;
030: private String timing;
031: private String guardEL;
032: private String guardMethod;
033: private String guardProperty;
034:
035: /** Sets the guard mode - either READ or WRITE **/
036: public void setGuardMode(String mode) {
037: this .mode = mode;
038: }
039:
040: public String getGuardMode() {
041: return mode;
042: }
043:
044: /** Sets the guard timing - either PRE, POST or AROUND.
045: * WRITE guards default to POST, READ guards default to PRE.
046: * A guard object of type RunnableInvoker will force mode to AROUND.
047: * **/
048:
049: public void setGuardTiming(String timing) {
050: this .timing = timing;
051: }
052:
053: public String getGuardTiming() {
054: return timing;
055: }
056:
057: public void setGuardedPath(String guardedpath) {
058: this .guardedpath = guardedpath;
059: }
060:
061: public String getGuardedPath() {
062: return guardedpath;
063: }
064:
065: public void setGuard(Object guard) {
066: this .guard = guard;
067: }
068:
069: public Object getGuard() {
070: return guard;
071: }
072:
073: /** An EL expression from which the base guard can be determined **/
074: public void setGuardEL(String guardEL) {
075: this .guardEL = guardEL;
076: }
077:
078: public String getGuardEL() {
079: return guardEL;
080: }
081:
082: /** A method to be invoked on a POJO-style validating bean.
083: * If "guardEL" or "guard" is not null,
084: * guardMethod consists of just the method name.
085: * If both guardEL and guard are null, this should be a "long path" of which
086: * the section to the last component is an EL representing guardEL.
087: * If this value and guardProperty is null, assumed to be a
088: * non-POJO validator (e.g. Spring Validator).
089: */
090: public void setGuardMethod(String guardMethod) {
091: this .guardMethod = guardMethod;
092: }
093:
094: public String getGuardMethod() {
095: return guardMethod;
096: }
097:
098: /** A property name on which the guarded object will be set onto the
099: * guard. If both guardEL and guard are null, this should be a "long path"
100: * of which the section to the last component is a EL representing guard EL.
101: */
102: public void setGuardProperty(String guardProperty) {
103: this .guardProperty = guardProperty;
104: }
105:
106: public String getGuardProperty() {
107: return guardProperty;
108: }
109: }
|