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

stark.activerecord.internal.EntityManagerTransactionAdvice.scala Maven / Gradle / Ivy

The newest version!
package stark.activerecord.internal

import java.lang.reflect.{AccessibleObject, Method}

import org.apache.tapestry5.plastic.{MethodAdvice, MethodInvocation}
import org.springframework.transaction.interceptor.TransactionInterceptor

/**
 * entity manager interceptor
 * @author Jun Tsai
 * @since 2016-01-03
 */
class EntityManagerTransactionAdvice(interceptor: TransactionInterceptor,method:Method) extends  MethodAdvice {
  def advise (methodInvocation: MethodInvocation) {
    interceptor.invoke (new org.aopalliance.intercept.MethodInvocation{
      def getMethod: Method = method
      def getArguments: Array[AnyRef] = {
        throw new UnsupportedOperationException
      }
      @throws (classOf[Throwable] )
      def proceed: AnyRef = {
        methodInvocation.proceed
        methodInvocation.getReturnValue
      }
      def getThis: AnyRef = {
        methodInvocation.getInstance()
      }
      def getStaticPart: AccessibleObject = {
        throw new UnsupportedOperationException
      }
    })
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy