use of org.activityinfo.server.endpoint.gwtrpc.RemoteExecutionContext in project activityinfo by bedatadriven.
the class CommandTestCase2 method execute.
protected <T extends CommandResult> T execute(Command<T> command) throws CommandException {
User user;
if (AuthenticationModuleStub.getCurrentUser().getUserId() == 0) {
user = new User();
user.setName("Anonymous");
user.setEmail("Anonymous@anonymous");
} else {
user = new User();
user.setId(AuthenticationModuleStub.getCurrentUser().getUserId());
user.setEmail("foo@foo.com");
user.setName("Foo Name");
user.setLocale("en");
}
ThreadLocalLocaleProvider.pushLocale(user.getLocaleObject());
try {
RemoteExecutionContext context = new RemoteExecutionContext(injector);
T result = context.startExecute(command);
// normally each request and so each handleCommand() gets its own
// EntityManager, but here successive requests in the same test
// will share an EntityManager, which can be bad if there are
// collections
// still living in the first-level cache
//
// I think these command tests should ultimately become real end-to-end
// tests and so would go through the actual servlet process, but for the
// moment,
// we'll just add this work aroudn that clears the cache after each
// command.
injector.getInstance(EntityManager.class).clear();
return result;
} finally {
ThreadLocalLocaleProvider.popLocale();
}
}
use of org.activityinfo.server.endpoint.gwtrpc.RemoteExecutionContext in project activityinfo by bedatadriven.
the class DispatcherSyncImpl method execute.
@Override
public <C extends Command<R>, R extends CommandResult> R execute(C command) throws CommandException {
if (RemoteExecutionContext.inProgress()) {
return RemoteExecutionContext.current().execute(command);
} else {
User user = new User();
user.setId(userProvider.get().getUserId());
user.setEmail(userProvider.get().getEmail());
user.setLocale(userProvider.get().getUserLocale());
RemoteExecutionContext context = new RemoteExecutionContext(injector);
return context.startExecute(command);
}
}
Aggregations