All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dynamicextensionsalfresco.aop.TransactionalAdvice Maven / Gradle / Ivy

Go to download

Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features

There is a newer version: 3.1.0
Show newest version
package com.github.dynamicextensionsalfresco.aop;

import com.github.dynamicextensionsalfresco.annotations.Transactional;

import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.Assert;

/**
 * Provides advice for {@link Transactional}-annotated methods.
 * 

* This implementation invokes {@link Transactional} operations within a {@link RetryingTransactionCallback} * * @author Laurens Fridael * */ public class TransactionalAdvice implements MethodInterceptor { /* Dependencies */ private RetryingTransactionHelper retryingTransactionHelper; /* Main operations */ @Override public Object invoke(final MethodInvocation invocation) throws Throwable { final Transactional transactional = AnnotationUtils.findAnnotation(invocation.getMethod(), Transactional.class); return getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @Override public Object execute() throws Throwable { return invocation.proceed(); } }, transactional.readOnly(), transactional.requiresNew()); } /* Dependencies */ public void setRetryingTransactionHelper(final RetryingTransactionHelper retryingTransactionHelper) { Assert.notNull(retryingTransactionHelper); this.retryingTransactionHelper = retryingTransactionHelper; } protected RetryingTransactionHelper getRetryingTransactionHelper() { return retryingTransactionHelper; } }