Java源码示例:javax.ejb.Timeout

示例1
@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());

}
 
示例2
@Timeout
public void timeout(Timer timer) {
    if (timer.equals(simulationTimer)){
        sim.run();
    }
    else if (timer.equals(hourlySalesTimer)){
        hourlySalesGenerator.run();
    }
}
 
示例3
@Timeout
public void timeout(Timer timer) {
    if (timer.equals(simulationTimer)){
        sim.run();
    }
    else if (timer.equals(hourlySalesTimer)){
        hourlySalesGenerator.run();
    }
}
 
示例4
/**
 * Handles the timer event.
 */
@Timeout
public void handleTimer(@SuppressWarnings("unused") Timer timer) {
	if (logFile != null) {
		handleOnChange(logFile);
	}
}
 
示例5
/**
 * Handles the timer event.
 */
@Timeout
public void handleTimer(@SuppressWarnings("unused") Timer timer) {
    if (logFile != null) {
        handleOnChange(logFile);
    }
}
 
示例6
/**
 * Handles the timer event.
 */
@Timeout
public void handleTimer(@SuppressWarnings("unused") Timer timer) {
    if (logFile != null) {
        handleOnChange(logFile);
    }
}
 
示例7
@Timeout
public void tick() {
	if (active) {
		System.out.println("Business fires event");
		businessEvent.fire(new BusinessEvent("second = " + new Date().getSeconds()));
	}
}
 
示例8
@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();
    }
}
 
示例9
@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);
    }
}
 
示例10
@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();
}
 
示例11
@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());
}
 
示例12
@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());
}
 
示例13
@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());
}
 
示例14
/**
 * 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);

    }

}
 
示例15
@Timeout
public void handleTimeout(Timer timer) {
    String lplatformId = (String) timer.getInfo();
    CreateLPlatform lplatform = cache.findLplatform(lplatformId);
    lplatform.setLplatformStatus("NORMAL");
}
 
示例16
@Timeout
public void onTimeout(Timer timer) {
	Long businessId = (Long) timer.getInfo();
	System.out.println("Processing businessId: " + businessId);
	flag = true;
}
 
示例17
@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());
}
 
示例18
@Timeout
private void timeout(Timer timer) {
    final EventConfig config = (EventConfig) timer.getInfo();

    beanManager.fireEvent(config.getEvent(), config.getQualifiers());
}
 
示例19
@Timeout
public void method(final Timer timer) {
}
 
示例20
@Timeout
public void colorTimeout(final Timer timer) {
}
 
示例21
@Timeout
public Object bar(final Object m) {
    return null;
}
 
示例22
@Timeout
public void foo(final javax.ejb.Timer timer) {
}
 
示例23
@Timeout
public void bar(final javax.ejb.Timer timer) {
}
 
示例24
@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");
}
 
示例25
@Timeout
public void ejbT() {
    fail("This method should not be invoked, we might confuse the auto-created timers and timeout timer");
}
 
示例26
@Timeout
public void timeout(final Timer timer) {
    System.out.println("@Timeout on " + timer.getInfo());
    sema.release();
}
 
示例27
@Timeout
public void timeout(final Timer timer) {
    final long actual = System.currentTimeMillis() - ((Long) timer.getInfo() + 1000 * ok + 3000);
    assertEquals(0, actual, 500);
    ok++;
}
 
示例28
@Timeout
public void timeout(final Timer timer) {
    System.out.println("@Timeout");
    sema.release();
}
 
示例29
@Timeout
public void timeout(final Timer t) {
    System.out.println(t.getInfo());
}
 
示例30
@Timeout
@Timed(name = "schedule")
public void scheduledMethod() {
    counter.count();
}