]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
a55b797ec0a97e35138b2d067b8d4367fdef25ec
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.aspect;
2
3 import org.aspectj.lang.ProceedingJoinPoint;
4 import org.aspectj.lang.annotation.Around;
5 import org.aspectj.lang.annotation.Aspect;
6 import org.aspectj.lang.annotation.Pointcut;
7
8 import org.collectionspace.services.client.Profiler;
9
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
12
13 @Aspect
14 public class BlobProfileAspect {
15         private static final Logger logger = LoggerFactory.getLogger(BlobProfileAspect.class);
16         private static int indent = 0;
17         
18         private int pushIndent() {
19                 return indent++;
20         }
21         
22         private int popIndent() {
23                 return --indent;
24         }
25
26
27         @Around("blobResourceCreateMethods()")
28     public Object profile(ProceedingJoinPoint pjp) throws Throwable {
29                 Object result = null;
30                 
31                 // Start profiler
32         Profiler profiler = new Profiler(pjp.getSignature().toShortString(), pushIndent());
33         profiler.start();
34
35         try {
36                         Object[] args = pjp.getArgs(); // gets us a read-only copy of the argument(s)
37             result = pjp.proceed();     // finish the call
38         } finally {
39             // No cleanup needed.
40         }
41         
42         profiler.stop();
43         popIndent();
44         
45         return result;
46     }
47
48         /**
49          * Setup a pointcut for all the Blob methods related to creating a new blob
50          */
51         @Pointcut("execution(* org.nuxeo.ecm.platform.filemanager.service.extension.AbstractFileImporter.create(..))")
52     public void nuxeoImagePluginCutPoint() {}
53         
54         @Pointcut("execution(* org.collectionspace.services.common.imaging.nuxeo.NuxeoBlobUtils.createDocumentFromBlob(..))")
55     public void createDocumentFromBlobCutPoint() {}
56         
57     @Pointcut("execution(* org.collectionspace.services.blob.BlobResource.create(..))")
58     public void blobResourceCreateCutPoint() {}
59     
60     @Pointcut("execution(* org.collectionspace.services.blob.BlobResource.createBlob(..))")
61     public void blobResourceCreatBlobCutPoint() {}
62     
63     @Pointcut("execution(void org.collectionspace.services.common.blob.BlobInput.createBlobFile(..))")
64     public void blobUtilCreatBlobFile() {}
65     
66     @Pointcut("createDocumentFromBlobCutPoint()"
67                 + " || blobResourceCreateCutPoint()"
68                 + " || blobResourceCreatBlobCutPoint()"
69                 + " || blobUtilCreatBlobFile()"
70                 + " || nuxeoImagePluginCutPoint()")
71     public void blobResourceCreateMethods() {}
72
73 }