[New] Added StrolchComponent.runAsWithResult()

This commit is contained in:
Robert von Burg 2020-03-24 13:23:55 +01:00
parent 87a845dd74
commit de361f7ca6
1 changed files with 20 additions and 0 deletions

View File

@ -339,6 +339,26 @@ public class StrolchComponent {
this.container.getPrivilegeHandler().runAs(username, runnable);
}
/**
* Performs the given {@link PrivilegedRunnable} as the given system user
*
* @param username
* the name of the system user to perform the action as
* @param runnable
* the runnable to perform
*
* @return the result
*
* @throws PrivilegeException
* if the given username is not allowed to perform the action
* @throws Exception
* if anything else goes wrong during execution
*/
protected <T> T runAsWithResult(String username, PrivilegedRunnableWithResult<T> runnable)
throws PrivilegeException, Exception {
return this.container.getPrivilegeHandler().runWithResult(username, runnable);
}
/**
* Performs the given {@link PrivilegedRunnable} as the given system user
*