List of usage examples for java.util.concurrent Callable Callable
Callable
From source file:com.linkedin.pinot.core.query.scheduler.FCFSQueryScheduler.java
@Override public ListenableFuture<DataTable> submit(final QueryRequest queryRequest) { ListenableFuture<DataTable> queryResultFuture = queryRunners.submit(new Callable<DataTable>() { @Override/*from w w w.j av a 2 s.co m*/ public DataTable call() { return queryExecutor.processQuery(queryRequest); } }); return queryResultFuture; }
From source file:de.cubeisland.engine.core.webapi.CommandController.java
@Action public ApiResponse command(ApiRequest request, final @Value("cmd") String command) { User authUser = request.getAuthUser(); final ApiCommandSender sender = authUser == null ? new ApiServerSender(core, mapper) : new ApiUser(core, authUser, mapper); Future<ApiResponse> future = core.getTaskManager().callSync(new Callable<ApiResponse>() { @Override/* w w w . ja v a 2 s . c om*/ public ApiResponse call() throws Exception { core.getCommandManager().runCommand(sender, command); ApiResponse apiResponse = new ApiResponse(); apiResponse.setContent(sender.flush()); return apiResponse; } }); try { return future.get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return null; } catch (ExecutionException e) { return new ApiResponse(); } }
From source file:net.sf.mmm.persistence.impl.hibernate.EnversTest.java
@Test public void testPersistence() throws Exception { TransactionExecutor transactionExecutor = SpringContainerPool.getInstance(SPRING_XML) .get(TransactionExecutor.class); // MutableUserSession session = (MutableUserSession) UserSessionAccess.getSession(); // session.setUser(TestUser.DEFAULT_USER); SecurityContextHolder.getContext().setAuthentication(TestUser.DEFAULT_USER); DummyRevisionedFooEntity foo = transactionExecutor .doInTransaction(new Callable<DummyRevisionedFooEntity>() { public DummyRevisionedFooEntity call() throws Exception { return createAndSave(); }// w w w.j ava 2 s . c o m }); final Long fooId = foo.getId(); // shutdown and restart to ensure we really read from DB SpringContainerPool.dispose(SPRING_XML); transactionExecutor = SpringContainerPool.getInstance(SPRING_XML).get(TransactionExecutor.class); transactionExecutor.doInTransaction(new Callable<Void>() { public Void call() throws Exception { readAndUpdate(fooId); return null; } }); // shutdown and restart to ensure we really read from DB SpringContainerPool.dispose(SPRING_XML); transactionExecutor = SpringContainerPool.getInstance(SPRING_XML).get(TransactionExecutor.class); transactionExecutor.doInTransaction(new Callable<Void>() { public Void call() throws Exception { readAgainAndDelete(fooId); return null; } }); }
From source file:org.mayocat.webhooks.Webhooks.java
public void notifyHook(final Webhook event, final Object payload) { WebhooksSettings hooksSettings = configurationService.getSettings(WebhooksSettings.class); List<Hook> hooks = FluentIterable.from(hooksSettings.getHooks().getValue()).filter(hookMatchesEvent(event)) .toList();//from w w w.ja va2 s .co m for (final Hook hook : hooks) { Executors.newSingleThreadExecutor().submit(new Callable<Void>() { @Override public Void call() throws Exception { doNotifyHook(event, hook, payload); return null; } }); } }
From source file:org.jasig.portlet.blackboardvcportlet.dao.impl.ServerQuotaDaoImplTest.java
@Test public void testEmptyQueries() throws Exception { this.execute(new Callable<Object>() { @Override/*from ww w .ja v a2s .c o m*/ public Object call() { final ServerQuota serverQuota = serverQuotaDao.getServerQuota(); assertNull(serverQuota); return null; } }); this.execute(new Callable<Object>() { @Override public Object call() { serverQuotaDao.deleteServerQuota(); return null; } }); }
From source file:org.jasig.portlet.blackboardvcportlet.dao.impl.MultimediaDaoImplTest.java
@Test public void testEmptyQueries() throws Exception { this.execute(new Callable<Object>() { @Override//from ww w .j a va 2 s . c o m public Object call() { final Set<Multimedia> multimedias = dao.getAllMultimedia(); assertEquals(0, multimedias.size()); return null; } }); }
From source file:org.jasig.portlet.blackboardvcportlet.dao.impl.PresentationDaoImplTest.java
@Test public void testEmptyQueries() throws Exception { this.execute(new Callable<Object>() { @Override/*from w w w. ja va 2 s. c om*/ public Object call() { final Set<Presentation> presentation = dao.getAllPresentations(); assertEquals(0, presentation.size()); return null; } }); }
From source file:com.microsoft.windowsazure.management.ManagementIntegrationTestBase.java
protected static void createManagementClient(Configuration config) { managementClient = ManagementService.create(config); addClient((ServiceClient<?>) managementClient, new Callable<Void>() { @Override/*from w ww . j a va2 s .c o m*/ public Void call() throws Exception { createService(); return null; } }); }
From source file:net.javacrumbs.futureconverter.common.test.spring.SpringOriginalFutureTestHelper.java
@Override public ListenableFuture<String> createFinishedFuture() { return executor.submitListenable(new Callable<String>() { @Override/*from ww w . j a v a 2 s . com*/ public String call() throws Exception { return AbstractConverterTest.VALUE; } }); }
From source file:com.sishuok.chapter3.web.controller.CallableController.java
@RequestMapping("/callable3") @ResponseBody/*from www . j a v a2 s.c o m*/ public Callable<Object> callable3() { return new Callable<Object>() { @Override public Object call() throws Exception { Thread.sleep(2L * 1000); //? return new User(1, "zhang"); } }; }