[Minor] Added StrolchAgent.runAsWithResult()
This commit is contained in:
parent
b99ef252a9
commit
b7ce4b355c
|
@ -129,14 +129,29 @@ public class StrolchAgent {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ComponentContainer#runAsAgent(PrivilegedRunnable)
|
||||
* @see PrivilegeHandler#runAs(String, PrivilegedRunnable)
|
||||
*/
|
||||
public void runAs(String systemUser, PrivilegedRunnable runnable) throws PrivilegeException, Exception {
|
||||
getPrivilegeHandler().runAs(systemUser, runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PrivilegeHandler#runAsAgent(PrivilegedRunnable)
|
||||
*/
|
||||
public void runAsAgent(PrivilegedRunnable runnable) throws PrivilegeException, Exception {
|
||||
getPrivilegeHandler().runAsAgent(runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ComponentContainer#runAsAgentWithResult(PrivilegedRunnableWithResult)
|
||||
* @see PrivilegeHandler#runAsAgentWithResult(PrivilegedRunnableWithResult)
|
||||
*/
|
||||
public <T> T runAsWithResult(String systemUser, PrivilegedRunnableWithResult<T> runnable)
|
||||
throws PrivilegeException, Exception {
|
||||
return getPrivilegeHandler().runAsWithResult(systemUser, runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PrivilegeHandler#runAsAgentWithResult(PrivilegedRunnableWithResult)
|
||||
*/
|
||||
public <T> T runAsAgentWithResult(PrivilegedRunnableWithResult<T> runnable) throws PrivilegeException, Exception {
|
||||
return getPrivilegeHandler().runAsAgentWithResult(runnable);
|
||||
|
|
|
@ -264,6 +264,11 @@ public class DefaultStrolchPrivilegeHandler extends StrolchComponent implements
|
|||
.runWithResult(StrolchConstants.SYSTEM_USER_AGENT, new StrolchSystemActionWithResult<>(runnable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T runAsWithResult(String username, PrivilegedRunnableWithResult<T> runnable) throws Exception {
|
||||
return this.privilegeHandler.runWithResult(username, new StrolchSystemActionWithResult<>(runnable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrivilegeContext openAgentSystemUserContext() throws PrivilegeException {
|
||||
return this.privilegeHandler.openSystemUserContext(StrolchConstants.SYSTEM_USER_AGENT);
|
||||
|
|
|
@ -298,6 +298,24 @@ public interface PrivilegeHandler {
|
|||
*/
|
||||
<T> T runAsAgentWithResult(PrivilegedRunnableWithResult<T> runnable) throws PrivilegeException, Exception;
|
||||
|
||||
/**
|
||||
* Run the given {@link PrivilegedRunnableWithResult} as the given system user
|
||||
*
|
||||
* @param username
|
||||
* the system username
|
||||
* @param runnable
|
||||
* the runnable to perform
|
||||
*
|
||||
* @return the result
|
||||
*
|
||||
* @throws PrivilegeException
|
||||
* if there is something wrong
|
||||
* @throws Exception
|
||||
* if anything else goes wrong during execution
|
||||
*/
|
||||
<T> T runAsWithResult(String username, PrivilegedRunnableWithResult<T> runnable)
|
||||
throws PrivilegeException, Exception;
|
||||
|
||||
/**
|
||||
* Opens a {@link PrivilegeContext} as the system user {@link StrolchConstants#SYSTEM_USER_AGENT}
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue