]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/aspects/ContentProviderAspect.java
Terminated draft of TestResultDetail Implementation for the RCP UI.
[gpl/argeo-slc.git] / eclipse / plugins / org.argeo.slc.client.core / src / main / java / org / argeo / slc / client / aspects / ContentProviderAspect.java
index 0cd9c28d775b675e392e44ea10beccc9fdb3311b..5f853b62f94f194e37de81b6cc0904cb7423a489 100644 (file)
@@ -3,6 +3,8 @@ package org.argeo.slc.client.aspects;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.Around;
 import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.eclipse.ui.internal.ViewSite;
 import org.hibernate.LockMode;
 import org.hibernate.SessionFactory;
 
@@ -23,20 +25,32 @@ public class ContentProviderAspect {
 
        private SessionFactory sessionFactory;
 
+       // We select here only getters from classes of the contentprovider package
+       // that need to get data from hibernate
+
+       // PointCuts
+       @Pointcut("(execution (* org.argeo.slc.client.contentprovider.ProcessListTableLabelProvider.get*(..)) && args(o,..))"
+                       + " || (execution (* org.argeo.slc.client.contentprovider.ProcessDetailContentProvider.get*(..)) && args(o,..))"
+                       + " || (execution (* org.argeo.slc.client.contentprovider.ResultDetailContentProvider.getElements(..)) && args(o,..))")
+       void contentProviderGetterWrapper(Object o) {
+       }
+
        // Advices
-       @Around("execution (* org.argeo.slc.client.contentprovider.*.get*(Object, int))")
-       public Object aroundGetVariable(ProceedingJoinPoint thisJoinPoint)
+       @Around("contentProviderGetterWrapper(o)")
+       public Object aroundGetWrapper(ProceedingJoinPoint thisJoinPoint, Object o)
                        throws Throwable {
 
-               Object o = thisJoinPoint.getArgs()[0];
+//             if (o instanceof ViewSite) {
+//                     return thisJoinPoint.proceed();
+//             }
 
                // TODO : find a mean to handle session & manager with txManager
                // in order to not have to re-begin a transaction here.
                sessionFactory.getCurrentSession().beginTransaction();
-               
+
                // reassociate a transient instance with a session (LockMode.NONE).
                sessionFactory.getCurrentSession().lock(o, LockMode.NONE);
-               
+
                Object result = thisJoinPoint.proceed();
                sessionFactory.getCurrentSession().getTransaction().commit();
                return result;