javax.ejb.Timeout Java Examples
The following examples show how to use
javax.ejb.Timeout.
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: EurekaClient.java From snoop with MIT License | 6 votes |
@Timeout public void health(Timer timer) { LOGGER.config(() -> "health update: " + Calendar.getInstance().getTime()); LOGGER.config(() -> "Next: " + timer.getNextTimeout()); EurekaConfig eurekaConfig = new EurekaConfig(); eurekaConfig.setStatus("UP"); Entity<InstanceConfig> entity = Entity.entity(new InstanceConfig(eurekaConfig), MediaType.APPLICATION_JSON); Response response = ClientBuilder.newClient() .target(serviceUrl + "apps/" + applicationName + "/" + applicationName) .request() .put(entity); LOGGER.config(() -> "PUT resulted in: " + response.getStatus() + ", " + response.getEntity()); }
Example #2
Source File: SingletonSimulationBean.java From marathonv5 with Apache License 2.0 | 5 votes |
@Timeout public void timeout(Timer timer) { if (timer.equals(simulationTimer)){ sim.run(); } else if (timer.equals(hourlySalesTimer)){ hourlySalesGenerator.run(); } }
Example #3
Source File: FarmerBrown.java From tomee with Apache License 2.0 | 5 votes |
@Timeout public void timeout(Timer timer) { if ("plantTheCorn".equals(timer.getInfo())) { plantTheCorn(); } else if ("harvestTheCorn".equals(timer.getInfo())) { harvestTheCorn(); } else if ("checkOnTheDaughters".equals(timer.getInfo())) { checkOnTheDaughters(); } }
Example #4
Source File: Business.java From training with MIT License | 5 votes |
@Timeout public void tick() { if (active) { System.out.println("Business fires event"); businessEvent.fire(new BusinessEvent("second = " + new Date().getSeconds())); } }
Example #5
Source File: TransactionRegistryInTimeoutTest.java From tomee with Apache License 2.0 | 5 votes |
@Timeout @Lock(LockType.WRITE) public void timerFired() { try { final String jndi = "java:comp/TransactionSynchronizationRegistry"; final TransactionSynchronizationRegistry txRegistry = (TransactionSynchronizationRegistry) new InitialContext().lookup(jndi); assertNotNull(txRegistry); assertNotNull(context.lookup(jndi)); assertNotNull(registry); txRegistry.registerInterposedSynchronization(sync); } catch (final NamingException e) { throw new IllegalStateException(e); } }
Example #6
Source File: Initializer.java From development with Apache License 2.0 | 5 votes |
/** * Handles the timer event. */ @Timeout public void handleTimer(@SuppressWarnings("unused") Timer timer) { if (logFile != null) { handleOnChange(logFile); } }
Example #7
Source File: Initializer.java From development with Apache License 2.0 | 5 votes |
/** * Handles the timer event. */ @Timeout public void handleTimer(@SuppressWarnings("unused") Timer timer) { if (logFile != null) { handleOnChange(logFile); } }
Example #8
Source File: Initializer.java From development with Apache License 2.0 | 5 votes |
/** * Handles the timer event. */ @Timeout public void handleTimer(@SuppressWarnings("unused") Timer timer) { if (logFile != null) { handleOnChange(logFile); } }
Example #9
Source File: SingleActionTimerTest.java From tomee with Apache License 2.0 | 5 votes |
@Timeout public void programmaticTimeout(final Timer timer) { if (!TIMER_NAME.equals(timer.getInfo())) { return; } final int i = this.counter.incrementAndGet(); System.out.println("SingleActionTimer: Timeout " + i); this.createTimer(); }
Example #10
Source File: SingletonSimulationBean.java From marathonv5 with Apache License 2.0 | 5 votes |
@Timeout public void timeout(Timer timer) { if (timer.equals(simulationTimer)){ sim.run(); } else if (timer.equals(hourlySalesTimer)){ hourlySalesGenerator.run(); } }
Example #11
Source File: GetTimerTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public void timeout(final Timer timer) { System.out.println("@Timeout"); sema.release(); }
Example #12
Source File: GetAllTimersTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public void timeout(final Timer t) { System.out.println(t.getInfo()); }
Example #13
Source File: InitialIntervalTimerTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public void timeout(final Timer timer) { final long actual = System.currentTimeMillis() - ((Long) timer.getInfo() + 1000 * ok + 3000); assertEquals(0, actual, 500); ok++; }
Example #14
Source File: QuartzPersistenceForEJBTimersTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public void timeout(final Timer timer) { System.out.println("@Timeout on " + timer.getInfo()); sema.release(); }
Example #15
Source File: TimedMethodTimerBean.java From metrics-cdi with Apache License 2.0 | 4 votes |
@Timeout @Timed(name = "schedule") public void scheduledMethod() { counter.count(); }
Example #16
Source File: ScheduleTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public void ejbT() { fail("This method should not be invoked, we might confuse the auto-created timers and timeout timer"); }
Example #17
Source File: ScheduleTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public void ejbT(final javax.ejb.Timer timer) { fail("This method should not be invoked, we might confuse the auto-created timers and timeout timer"); }
Example #18
Source File: CheckInvalidTimeoutTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public void bar(final javax.ejb.Timer timer) { }
Example #19
Source File: CheckInvalidTimeoutTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public void foo(final javax.ejb.Timer timer) { }
Example #20
Source File: CheckInvalidTimeoutTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public Object bar(final Object m) { return null; }
Example #21
Source File: InheritenceTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public void colorTimeout(final Timer timer) { }
Example #22
Source File: TimeoutMetaTest.java From tomee with Apache License 2.0 | 4 votes |
@Timeout public void method(final Timer timer) { }
Example #23
Source File: Scheduler.java From tomee with Apache License 2.0 | 4 votes |
@Timeout private void timeout(Timer timer) { final EventConfig config = (EventConfig) timer.getInfo(); beanManager.fireEvent(config.getEvent(), config.getQualifiers()); }
Example #24
Source File: SnoopRegistrationClient.java From snoop with MIT License | 4 votes |
@Timeout public void health(Timer timer) { LOGGER.config(() -> "health update: " + Calendar.getInstance().getTime()); LOGGER.config(() -> "Next: " + timer.getNextTimeout()); sendMessage(STATUS_ENDPOINT + applicationConfig.getServiceName(), applicationConfig.toJSON()); }
Example #25
Source File: MyTimerBean.java From training with MIT License | 4 votes |
@Timeout public void onTimeout(Timer timer) { Long businessId = (Long) timer.getInfo(); System.out.println("Processing businessId: " + businessId); flag = true; }
Example #26
Source File: FinishSystemCreationTimer.java From development with Apache License 2.0 | 4 votes |
@Timeout public void handleTimeout(Timer timer) { String lplatformId = (String) timer.getInfo(); CreateLPlatform lplatform = cache.findLplatform(lplatformId); lplatform.setLplatformStatus("NORMAL"); }
Example #27
Source File: TimerServiceBean.java From development with Apache License 2.0 | 4 votes |
/** * Handles the timers as soon as they are expired and the container invokes * this callback method. If the timer is not a periodic timer, it will also * be re-initialized. * * @param timer * The expired timer provided by the system. */ @Timeout public void handleTimer(Timer timer) { logger.logInfo(Log4jLogger.SYSTEM_LOG, LogMessageIdentifier.INFO_TIMER_TIMEOUT_RETRIEVED, String.valueOf(timer.getInfo())); // initial assumption on the outcome of the business logic invocation is // to that it failed boolean outcome = false; TimerType timerType = (TimerType) timer.getInfo(); long currentTime = System.currentTimeMillis(); // 1. create the timer processing data entry in the database, required // to avoid other nodes from handling the same task TimerProcessing processingData = createTimerProcessing(timerType, currentTime); // 2. handle the timer if (processingData != null) { try { switch (timerType) { case ORGANIZATION_UNCONFIRMED: outcome = accMgmt.removeOverdueOrganizations(currentTime); break; case RESTRICTED_SUBSCRIPTION_USAGE_PERIOD: outcome = subMgmt.expireOverdueSubscriptions(currentTime); break; case TENANT_PROVISIONING_TIMEOUT: outcome = subMgmt .notifyAboutTimedoutSubscriptions(currentTime); break; case BILLING_INVOCATION: outcome = bm.startBillingRun(currentTime); outcome = ps.chargeForOutstandingBills() && outcome; break; case DISCOUNT_END_CHECK: outcome = accMgmt .sendDiscountEndNotificationMail(currentTime); break; case INACTIVE_ON_BEHALF_USERS_REMOVAL: outcome = idServiceLocal.removeInactiveOnBehalfUsers(); break; case USER_NUM_CHECK: outcome = accMgmt.checkUserNum(); break; default: logger.logError(LogMessageIdentifier.ERROR_TIMER_TIMEOUT_FOR_UNKNOWN_TYPE); } } catch (Exception e) { logger.logError(Log4jLogger.SYSTEM_LOG, e, LogMessageIdentifier.ERROR_HANDLE_TIMER_FAILED); } // 3. update the created timer processing entry, update the duration // field and the success flag updateTimerProcessing(processingData, outcome); } else { logger.logInfo(Log4jLogger.SYSTEM_LOG, LogMessageIdentifier.INFO_TIMER_NO_HANDLING); } }
Example #28
Source File: Bot.java From monolith with Apache License 2.0 | 4 votes |
@Timeout public void book(Timer timer) { // Select a show at random Show show = selectAtRandom(showService.getAll(new MultivaluedHashMap<String, String>())); // Select a performance at random Performance performance = selectAtRandom(show.getPerformances()); String requestor = selectAtRandom(BOOKERS); BookingRequest bookingRequest = new BookingRequest(performance, requestor); List<TicketPrice> possibleTicketPrices = new ArrayList<TicketPrice>(show.getTicketPrices()); List<Integer> indicies = selectAtRandom(MAX_TICKET_REQUESTS < possibleTicketPrices.size() ? MAX_TICKET_REQUESTS : possibleTicketPrices.size()); StringBuilder message = new StringBuilder("==========================\n") .append("Booking by ") .append(requestor) .append(" at ") .append(new Date().toString()) .append("\n") .append(performance) .append("\n") .append("~~~~~~~~~~~~~~~~~~~~~~~~~\n"); for (int index : indicies) { int no = random.nextInt(MAX_TICKETS_PER_REQUEST); TicketPrice price = possibleTicketPrices.get(index); bookingRequest.addTicketRequest(new TicketRequest(price, no)); message .append(no) .append(" of ") .append(price.getSection()) .append("\n"); } Response response = bookingService.createBooking(bookingRequest); if(response.getStatus() == Response.Status.OK.getStatusCode()) { message.append("SUCCESSFUL\n") .append("~~~~~~~~~~~~~~~~~~~~~~~~~\n"); } else { message.append("FAILED:\n") .append(((Map<String, Object>) response.getEntity()).get("errors")) .append("~~~~~~~~~~~~~~~~~~~~~~~~~\n"); } event.fire(message.toString()); }
Example #29
Source File: Bot.java From monolith with Apache License 2.0 | 4 votes |
@Timeout public void book(Timer timer) { // Select a show at random Show show = selectAtRandom(showService.getAll(new MultivaluedHashMap<String, String>())); // Select a performance at random Performance performance = selectAtRandom(show.getPerformances()); String requestor = selectAtRandom(BOOKERS); BookingRequest bookingRequest = new BookingRequest(performance, requestor); List<TicketPrice> possibleTicketPrices = new ArrayList<TicketPrice>(show.getTicketPrices()); List<Integer> indicies = selectAtRandom(MAX_TICKET_REQUESTS < possibleTicketPrices.size() ? MAX_TICKET_REQUESTS : possibleTicketPrices.size()); StringBuilder message = new StringBuilder("==========================\n") .append("Booking by ") .append(requestor) .append(" at ") .append(new Date().toString()) .append("\n") .append(performance) .append("\n") .append("~~~~~~~~~~~~~~~~~~~~~~~~~\n"); for (int index : indicies) { int no = random.nextInt(MAX_TICKETS_PER_REQUEST); TicketPrice price = possibleTicketPrices.get(index); bookingRequest.addTicketRequest(new TicketRequest(price, no)); message .append(no) .append(" of ") .append(price.getSection()) .append("\n"); } Response response = bookingService.createBooking(bookingRequest); if(response.getStatus() == Response.Status.OK.getStatusCode()) { message.append("SUCCESSFUL\n") .append("~~~~~~~~~~~~~~~~~~~~~~~~~\n"); } else { message.append("FAILED:\n") .append(((Map<String, Object>) response.getEntity()).get("errors")) .append("~~~~~~~~~~~~~~~~~~~~~~~~~\n"); } event.fire(message.toString()); }
Example #30
Source File: Bot.java From monolith with Apache License 2.0 | 4 votes |
@Timeout public void book(Timer timer) { // Select a show at random Show show = selectAtRandom(showService.getAll(new MultivaluedHashMap<String, String>())); // Select a performance at random Performance performance = selectAtRandom(show.getPerformances()); String requestor = selectAtRandom(BOOKERS); BookingRequest bookingRequest = new BookingRequest(performance, requestor); List<TicketPrice> possibleTicketPrices = new ArrayList<TicketPrice>(show.getTicketPrices()); List<Integer> indicies = selectAtRandom(MAX_TICKET_REQUESTS < possibleTicketPrices.size() ? MAX_TICKET_REQUESTS : possibleTicketPrices.size()); StringBuilder message = new StringBuilder("==========================\n") .append("Booking by ") .append(requestor) .append(" at ") .append(new Date().toString()) .append("\n") .append(performance) .append("\n") .append("~~~~~~~~~~~~~~~~~~~~~~~~~\n"); for (int index : indicies) { int no = random.nextInt(MAX_TICKETS_PER_REQUEST); TicketPrice price = possibleTicketPrices.get(index); bookingRequest.addTicketRequest(new TicketRequest(price, no)); message .append(no) .append(" of ") .append(price.getSection()) .append("\n"); } Response response = bookingService.createBooking(bookingRequest); if(response.getStatus() == Response.Status.OK.getStatusCode()) { message.append("SUCCESSFUL\n") .append("~~~~~~~~~~~~~~~~~~~~~~~~~\n"); } else { message.append("FAILED:\n") .append(((Map<String, Object>) response.getEntity()).get("errors")) .append("~~~~~~~~~~~~~~~~~~~~~~~~~\n"); } event.fire(message.toString()); }