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;
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;