public <T> T execute(Command<T> command) {
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
if (environment==null) {
throw new JbpmException("no environment for verifying authorization");
}
MessageSession messageSession = environment.get(MessageSession.class);
if (messageSession==null) {
throw new JbpmException("no message session for executing command asynchronously");
}
String userId = (propagateUserId ? environment.getAuthenticatedUserId() : null);
messageSession.send(new AsyncCommandMessage(command, userId));
return null;
}