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

com.github.dynamicextensionsalfresco.aop.RunAsSystemAdvice 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 java.lang.reflect.InvocationTargetException;

import com.github.dynamicextensionsalfresco.annotations.RunAs;

import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

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

* This implementation invokes {@link RunAs} operations within a {@link RunAsWork} callback. */ public class RunAsSystemAdvice implements MethodInterceptor { @Override public Object invoke(final MethodInvocation invocation) throws Throwable { return AuthenticationUtil.runAs(new RunAsWork() { @Override public Object doWork() throws Exception { try { return invocation.proceed(); } catch (final Throwable e) { throw new InvocationTargetException(e); } } }, AuthenticationUtil.getSystemUserName()); } }