Example usage for org.springframework.aop.aspectj MethodInvocationProceedingJoinPoint proceed

List of usage examples for org.springframework.aop.aspectj MethodInvocationProceedingJoinPoint proceed

Introduction

In this page you can find the example usage for org.springframework.aop.aspectj MethodInvocationProceedingJoinPoint proceed.

Prototype

@Override
    public Object proceed() throws Throwable 

Source Link

Usage

From source file:org.geppetto.persistence.db.BundleClassLoaderAspect.java

public Object setClassLoader(MethodInvocationProceedingJoinPoint pjp) throws Throwable {
    // Save a reference to the classloader of the caller
    ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
    // Get a reference to the classloader of the owning bundle
    ClassLoader serviceLoader = pjp.getTarget().getClass().getClassLoader();
    // Set the class loader of the current thread to the class loader of the
    // owner of the bundle
    Thread.currentThread().setContextClassLoader(serviceLoader);

    Object returnValue = null;//w w  w  .j a  v a  2 s.  co m

    try {
        // Make the actual call to the method.
        returnValue = pjp.proceed();
    } finally {
        // Reset the classloader of this Thread to the original
        // classloader of the method invoker.
        Thread.currentThread().setContextClassLoader(oldLoader);
    }

    return returnValue;
}