javax.ejb.AsyncResult Java Examples
The following examples show how to use
javax.ejb.AsyncResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImporterBean.java From eplmp with Eclipse Public License 1.0 | 6 votes |
@Override @Asynchronous @FileImport public Future<ImportResult> importIntoPathData(String workspaceId, File file, String originalFileName, String revisionNote, boolean autoFreezeAfterUpdate, boolean permissiveUpdate) { Locale locale = getLocale(workspaceId); PathDataImporter selectedImporter = selectPathDataImporter(file); Properties properties = PropertiesLoader.loadLocalizedProperties(locale, I18N_CONF, ImporterBean.class); PathDataImporterResult pathDataImporterResult; if (selectedImporter != null) { pathDataImporterResult = selectedImporter.importFile(locale, workspaceId, file, autoFreezeAfterUpdate, permissiveUpdate); } else { List<String> errors = getNoImporterAvailableError(properties); pathDataImporterResult = new PathDataImporterResult(file, new ArrayList<>(), errors, null, null, null); } ImportResult result = doPathDataImport(properties, workspaceId, revisionNote, autoFreezeAfterUpdate, permissiveUpdate, pathDataImporterResult); return new AsyncResult<>(result); }
Example #2
Source File: ParalellizerWorker.java From training with MIT License | 6 votes |
@Asynchronous // SOLUTION //public Integer executeWorkItem(String workItem) { // INITIAL public Future<Integer> executeWorkItem(String workItem) { // SOLUTION int result = workItem.length(); System.out.println("Worker " + workerId + ": Start processing item '" + workItem + "'"); System.out.println("Worker " + workerId + ": " + Thread.currentThread().getName()); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Worker " + workerId + ": Item '" + workItem + "' done."); return new AsyncResult<Integer>(result); // SOLUTION // return result; // INITIAL }
Example #3
Source File: HealthNetworkServiceImpl.java From aerogear-unifiedpush-server with Apache License 2.0 | 6 votes |
@Asynchronous @Override public Future<List<HealthDetails>> networkStatus() { final List<HealthDetails> results = new ArrayList<>(PUSH_NETWORKS.size()); PUSH_NETWORKS.forEach(pushNetwork -> { HealthDetails details = new HealthDetails(); details.start(); details.setDescription(pushNetwork.getName()); if (Ping.isReachable(pushNetwork.getHost(), pushNetwork.getPort())) { details.setTestStatus(Status.OK); details.setResult("online"); } else { details.setResult(String.format("Network not reachable '%s'", pushNetwork.getName())); details.setTestStatus(Status.WARN); } results.add(details); details.stop(); }); return new AsyncResult<>(results); }
Example #4
Source File: ClientInstallationServiceImpl.java From aerogear-unifiedpush-server with Apache License 2.0 | 6 votes |
@Override @Asynchronous public Future<Void> unsubscribeOldTopics(Installation installation) { FCMTopicManager topicManager = new FCMTopicManager((AndroidVariant) installation.getVariant()); Set<String> oldCategories = topicManager.getSubscribedCategories(installation); // Remove current categories from the set of old ones oldCategories.removeAll(convertToNames(installation.getCategories())); // Remove global variant topic because we don't want to unsubscribe it oldCategories.remove(installation.getVariant().getVariantID()); for (String categoryName : oldCategories) { topicManager.unsubscribe(installation, categoryName); } return new AsyncResult<>(null); }
Example #5
Source File: HealthServiceImpl.java From aerogear-unifiedpush-server with Apache License 2.0 | 6 votes |
@Asynchronous @Override public Future<HealthDetails> dbStatus() { HealthDetails details = new HealthDetails(); details.setDescription("Database connection"); details.start(); try { logger.trace("Call the DB if it is online"); healthDao.dbCheck(); details.setTestStatus(Status.OK); details.setResult("connected"); } catch (Exception e) { details.setTestStatus(Status.CRIT); details.setResult(e.getMessage()); } details.stop(); return new AsyncResult<>(details); }
Example #6
Source File: ClientInstallationServiceImpl.java From aerogear-unifiedpush-server with Apache License 2.0 | 5 votes |
@Override @Asynchronous public Future<Void> addInstallation(Variant variant, Installation entity) { // does it already exist ? Installation installation = this.findInstallationForVariantByDeviceToken(variant.getVariantID(), entity.getDeviceToken()); // Needed for the Admin UI Only. Help for setting up Routes entity.setPlatform(variant.getType().getTypeName()); // new device/client ? if (installation == null) { logger.trace("Performing new device/client registration"); // store the installation: storeInstallationAndSetReferences(variant, entity); } else { // We only update the metadata, if the device is enabled: if (installation.isEnabled()) { logger.trace("Updating received metadata for an 'enabled' installation"); // fix variant property of installation object installation.setVariant(variant); // update the entity: this.updateInstallation(installation, entity); } } return new AsyncResult<>(null); }
Example #7
Source File: AsynchInRoleTest.java From tomee with Apache License 2.0 | 5 votes |
@Override @Asynchronous public Future<String> testB(final long callerThreadId) { Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testB"; return new AsyncResult<>("testB"); }
Example #8
Source File: AsynchInRoleTest.java From tomee with Apache License 2.0 | 5 votes |
@Override @Asynchronous public Future<String> testB(final long callerThreadId) { Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testB"; return new AsyncResult<>("testB"); }
Example #9
Source File: AsynchInRoleTest.java From tomee with Apache License 2.0 | 5 votes |
@Override @Asynchronous public Future<String> testB(final long callerThreadId) { Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId); Assert.assertFalse(sessionContext.wasCancelCalled()); try { Thread.sleep(3000L); } catch (final InterruptedException e) { //Ignore } Assert.assertTrue(sessionContext.wasCancelCalled()); lastInvokeMethod = "testB"; return new AsyncResult<>("echoB"); }
Example #10
Source File: JobProcessor.java From tomee with Apache License 2.0 | 5 votes |
@Asynchronous @Lock(READ) @AccessTimeout(-1) public Future<String> addJob(String jobName) { // Pretend this job takes a while doSomeHeavyLifting(); // Return our result return new AsyncResult<String>(jobName); }
Example #11
Source File: AsynchTest.java From tomee with Apache License 2.0 | 5 votes |
@Override @Asynchronous public Future<String> testB(final long callerThreadId) { Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testB"; return new AsyncResult<>("testB"); }
Example #12
Source File: ClientInstallationServiceImpl.java From aerogear-unifiedpush-server with Apache License 2.0 | 5 votes |
@Override @Asynchronous public Future<Void> removeInstallationsForVariantByDeviceTokens(String variantID, Set<String> deviceTokens) { // collect inactive installations for the given variant: List<Installation> inactiveInstallations = installationDao.findInstallationsForVariantByDeviceTokens(variantID, deviceTokens); // get rid of them this.removeInstallations(inactiveInstallations); return new AsyncResult<>(null); }
Example #13
Source File: AsyncEJB.java From java-course-ee with MIT License | 5 votes |
@Asynchronous public Future<String> sayHello() { try { log.debug("Start sayHello method"); for (int i = 0; i < 10; i++) { Thread.sleep(1000); log.debug("Still sleeping"); } } catch (InterruptedException ex) { } log.debug("Return result"); return new AsyncResult<String>("përshëndetje"); }
Example #14
Source File: TheSlowWork.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 5 votes |
@Asynchronous public Future<Integer> add(int a, int b){ LOG.info("Adding!"); try { Thread.sleep(Math.round(Math.random()*1500)); } catch (InterruptedException e) { } LOG.info("Added!"); return new AsyncResult<Integer>(a+b); }
Example #15
Source File: TheatreBooker.java From packt-java-ee-7-code-samples with GNU General Public License v2.0 | 5 votes |
@Asynchronous @Override public Future<String> bookSeatAsync(int seatId) { try { Thread.sleep(10000); bookSeat(seatId); return new AsyncResult<>("Booked seat: " + seatId + ". Money left: " + money); } catch (NoSuchSeatException | SeatBookedException | NotEnoughMoneyException | InterruptedException e) { return new AsyncResult<>(e.getMessage()); } }
Example #16
Source File: TheatreBooker.java From packt-java-ee-7-code-samples with GNU General Public License v2.0 | 5 votes |
@Asynchronous @Override public Future<String> bookSeatAsync(int seatId) { try { Thread.sleep(10000); bookSeat(seatId); return new AsyncResult<>("Booked seat: " + seatId + ". Money left: " + money); } catch (NoSuchSeatException | SeatBookedException | NotEnoughMoneyException | InterruptedException e) { return new AsyncResult<>(e.getMessage()); } }
Example #17
Source File: AsynchTest.java From tomee with Apache License 2.0 | 5 votes |
@Override @Asynchronous public Future<String> testB(final long callerThreadId) { Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testB"; return new AsyncResult<>("testB"); }
Example #18
Source File: AsynchTest.java From tomee with Apache License 2.0 | 5 votes |
@Override @Asynchronous public Future<String> testB(final long callerThreadId) { Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId); Assert.assertFalse(sessionContext.wasCancelCalled()); try { Thread.sleep(3000L); } catch (final InterruptedException e) { //Ignore } Assert.assertTrue(sessionContext.wasCancelCalled()); lastInvokeMethod = "testB"; return new AsyncResult<>("echoB"); }
Example #19
Source File: AsyncPostContructTest.java From tomee with Apache License 2.0 | 4 votes |
@Asynchronous public Future<Boolean> async() { asyncStart.set(System.nanoTime()); asyncInstance.set(this); return new AsyncResult<>(true); }
Example #20
Source File: AsynchTest.java From tomee with Apache License 2.0 | 4 votes |
@Override public Future<String> testC(final long callerThreadId) { Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testC"; return new AsyncResult<>("testC"); }
Example #21
Source File: AsynchTest.java From tomee with Apache License 2.0 | 4 votes |
@Override public Future<String> testC(final long callerThreadId) { Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testC"; return new AsyncResult<>("testC"); }
Example #22
Source File: AsynchTest.java From tomee with Apache License 2.0 | 4 votes |
@Override public Future<String> testB(final long callerThreadId) { Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testB"; return new AsyncResult<>("testB" + callerThreadId); }
Example #23
Source File: AsynchInRoleTest.java From tomee with Apache License 2.0 | 4 votes |
@Override public Future<String> testC(final long callerThreadId) { Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testC"; return new AsyncResult<>("testC"); }
Example #24
Source File: AsynchInRoleTest.java From tomee with Apache License 2.0 | 4 votes |
@Override public Future<String> testB(final long callerThreadId) { Assert.assertFalse("testB should be executed in asynchronous mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testB"; return new AsyncResult<>("testB" + callerThreadId); }
Example #25
Source File: AsynchTest.java From tomee with Apache License 2.0 | 4 votes |
@Override public Future<String> testC(final long callerThreadId) { Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testC"; return new AsyncResult<>("testC"); }
Example #26
Source File: AsynchInRoleTest.java From tomee with Apache License 2.0 | 4 votes |
@Override public Future<String> testC(final long callerThreadId) { Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testC"; return new AsyncResult<>("testC"); }
Example #27
Source File: AsynchInRoleTest.java From tomee with Apache License 2.0 | 4 votes |
@Override public Future<String> testC(final long callerThreadId) { Assert.assertTrue("testC should be executed in blocing mode", Thread.currentThread().getId() == callerThreadId); lastInvokeMethod = "testC"; return new AsyncResult<>("testC"); }
Example #28
Source File: CheckInvalidAsynchronousAnnotationsTest.java From tomee with Apache License 2.0 | 4 votes |
public Future<String> validReturnType() { return new AsyncResult<>("returning from async call"); }
Example #29
Source File: CheckInvalidAsynchronousAnnotationsTest.java From tomee with Apache License 2.0 | 4 votes |
@Asynchronous public Future<String> validReturnType() { return new AsyncResult<>("returning from async call"); }
Example #30
Source File: Executor.java From tomee with Apache License 2.0 | 4 votes |
@Asynchronous public <T> Future<T> submit(Callable<T> task) throws Exception { return new AsyncResult<T>(task.call()); }