| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
package org.apache.tapestry5.internal.transform; |
| 16 | |
|
| 17 | |
import org.apache.tapestry5.annotations.Log; |
| 18 | |
import org.apache.tapestry5.ioc.MethodAdvice; |
| 19 | |
import org.apache.tapestry5.ioc.internal.services.LoggingAdvice; |
| 20 | |
import org.apache.tapestry5.ioc.services.ExceptionTracker; |
| 21 | |
import org.apache.tapestry5.model.MutableComponentModel; |
| 22 | |
import org.apache.tapestry5.services.*; |
| 23 | |
|
| 24 | |
import java.util.List; |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
public class LogWorker implements ComponentClassTransformWorker |
| 32 | |
{ |
| 33 | |
private final ExceptionTracker exceptionTracker; |
| 34 | |
|
| 35 | |
public LogWorker(ExceptionTracker exceptionTracker) |
| 36 | 58 | { |
| 37 | 58 | this.exceptionTracker = exceptionTracker; |
| 38 | 58 | } |
| 39 | |
|
| 40 | |
public void transform(ClassTransformation transformation, MutableComponentModel model) |
| 41 | |
{ |
| 42 | 810 | List<TransformMethodSignature> signatures = transformation.findMethodsWithAnnotation(Log.class); |
| 43 | |
|
| 44 | 810 | if (signatures.isEmpty()) return; |
| 45 | |
|
| 46 | |
|
| 47 | 24 | final MethodAdvice loggingAdvice = new LoggingAdvice(model.getLogger(), exceptionTracker); |
| 48 | |
|
| 49 | |
|
| 50 | 24 | ComponentMethodAdvice advice = new ComponentMethodAdvice() |
| 51 | |
{ |
| 52 | 24 | public void advise(ComponentMethodInvocation invocation) |
| 53 | |
{ |
| 54 | 186 | loggingAdvice.advise(invocation); |
| 55 | 184 | } |
| 56 | |
}; |
| 57 | |
|
| 58 | 24 | for (TransformMethodSignature signature : signatures) |
| 59 | 28 | transformation.advise(signature, advice); |
| 60 | 24 | } |
| 61 | |
} |