001: /**************************************************************************************
002: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
003: * http://aspectwerkz.codehaus.org *
004: * ---------------------------------------------------------------------------------- *
005: * The software in this package is published under the terms of the LGPL license *
006: * a copy of which has been included with this distribution in the license.txt file. *
007: **************************************************************************************/package test.modifier;
008:
009: import org.codehaus.aspectwerkz.definition.Pointcut;
010: import org.codehaus.aspectwerkz.definition.Pointcut;
011: import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
012:
013: /**
014: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
015: * @Aspect perJVM
016: */
017: public class TestAspect {
018: // ============ Pointcuts ============
019:
020: /**
021: * @Expression call(private * test.modifier.*.*Method(..)) && within(test.modifier.*)
022: */
023: Pointcut call_privateMethod;
024:
025: /**
026: * @Expression call(protected * test.modifier.*.*Method(..)) && within(test.modifier.*)
027: */
028: Pointcut call_protectedMethod;
029:
030: /**
031: * @Expression call(public * test.modifier.*.*Method(..)) && within(test.modifier.*)
032: */
033: Pointcut call_publicMethod;
034:
035: /**
036: * @Expression call(static final * test.modifier.*.*Method(..)) && within(test.modifier.*)
037: */
038: Pointcut call_staticFinalMethod;
039:
040: /**
041: * @Expression execution(private * test.modifier.*.*Method(..))
042: */
043: Pointcut execution_privateMethod;
044:
045: /**
046: * @Expression execution(protected * test.modifier.*.*Method(..))
047: */
048: Pointcut execution_protectedMethod;
049:
050: /**
051: * @Expression execution(public * test.modifier.*.*Method(..))
052: */
053: Pointcut execution_publicMethod;
054:
055: /**
056: * @Expression get(private * test.modifier.*.*Field) && within(test.modifier.*)
057: */
058: Pointcut get_privateField;
059:
060: /**
061: * @Expression get(protected * test.modifier.*.*Field) && within(test.modifier.*)
062: */
063: Pointcut get_protectedField;
064:
065: /**
066: * @Expression get(public * test.modifier.*.*Field) && within(test.modifier.*)
067: */
068: Pointcut get_publicField;
069:
070: /**
071: * @Expression set(private * test.modifier.*.*Field) && within(test.modifier.*)
072: */
073: Pointcut set_privateField;
074:
075: /**
076: * @Expression set(protected * test.modifier.*.*Field) && within(test.modifier.*)
077: */
078: Pointcut set_protectedField;
079:
080: /**
081: * @Expression set(public * test.modifier.*.*Field) && within(test.modifier.*)
082: */
083: Pointcut set_publicField;
084:
085: // ============ Advices ============
086:
087: /**
088: * @Around call_privateMethod || call_publicMethod || call_protectedMethod ||
089: * call_staticFinalMethod
090: */
091: public Object advice_CALL(final JoinPoint joinPoint)
092: throws Throwable {
093: ModifierTest.log("call ");
094: Object result = joinPoint.proceed();
095: ModifierTest.log("call ");
096: return result;
097: }
098:
099: /**
100: * @Around execution_privateMethod || execution_protectedMethod || execution_publicMethod
101: */
102: public Object advice_EXECUTION(final JoinPoint joinPoint)
103: throws Throwable {
104: ModifierTest.log("execution ");
105: Object result = joinPoint.proceed();
106: ModifierTest.log("execution ");
107: return result;
108: }
109:
110: /**
111: * @Around set_privateField || set_protectedField || set_publicField
112: */
113: public Object advice_SET(final JoinPoint joinPoint)
114: throws Throwable {
115: ModifierTest.log("set ");
116: Object result = joinPoint.proceed();
117: ModifierTest.log("set ");
118: return result;
119: }
120:
121: /**
122: * @Around get_privateField || get_protectedField || get_publicField
123: */
124: public Object advice_GET(final JoinPoint joinPoint)
125: throws Throwable {
126: ModifierTest.log("get ");
127: Object result = joinPoint.proceed();
128: ModifierTest.log("get ");
129: return result;
130: }
131: }
|