Example usage for javax.ejb Timer getSchedule

List of usage examples for javax.ejb Timer getSchedule

Introduction

In this page you can find the example usage for javax.ejb Timer getSchedule.

Prototype

public ScheduleExpression getSchedule()
        throws java.lang.IllegalStateException, javax.ejb.NoSuchObjectLocalException, javax.ejb.EJBException;

Source Link

Document

Get the schedule expression corresponding to this timer.

Usage

From source file:eu.agilejava.snoop.scan.SnoopClient.java

public void register(final String clientId) {
    sendMessage(REGISTER_ENDPOINT, clientId);

    ScheduleExpression schedule = new ScheduleExpression();
    schedule.second("*/10").minute("*").hour("*").start(Calendar.getInstance().getTime());

    TimerConfig config = new TimerConfig();
    config.setPersistent(false);//from  w  w  w .  ja v  a2  s. com

    Timer timer = timerService.createCalendarTimer(schedule, config);

    LOGGER.config(() -> timer.getSchedule().toString());
}

From source file:eu.agilejava.snoop.eureka.scan.EurekaClient.java

@PostConstruct
private void init() {

    LOGGER.config("Checking if snoop eureka is enabled");
    LOGGER.config(() -> "YES: " + SnoopEurekaExtensionHelper.isEurekaEnabled());

    if (SnoopEurekaExtensionHelper.isEurekaEnabled()) {

        readProperties();/*from  www.  j  ava  2 s.  c o m*/

        EurekaConfig eurekaConfig = new EurekaConfig();
        eurekaConfig.setHostName(applicationName);
        eurekaConfig.setApp(applicationName);
        eurekaConfig.setIpAddr("localhost");
        eurekaConfig.setPort(8080);
        eurekaConfig.setStatus("UP");
        eurekaConfig.setHomePageUrl(applicationHome);

        Entity<InstanceConfig> entity = Entity.entity(new InstanceConfig(eurekaConfig),
                MediaType.APPLICATION_JSON);

        Response response = ClientBuilder.newClient().target(serviceUrl + "apps/" + applicationName).request()
                .post(entity);

        LOGGER.config(() -> "POST resulted in: " + response.getStatus() + ", " + response.getEntity());

        ScheduleExpression schedule = new ScheduleExpression();
        schedule.second("*/10").minute("*").hour("*").start(Calendar.getInstance().getTime());

        TimerConfig config = new TimerConfig();
        config.setPersistent(false);

        Timer timer = timerService.createCalendarTimer(schedule, config);

        LOGGER.config(() -> timer.getSchedule().toString());

    } else {
        LOGGER.config("Snoop Eureka is not enabled. Use @EnableEurekaClient!");
    }
}

From source file:eu.agilejava.snoop.scan.SnoopRegistrationClient.java

public void register(final String clientId) {

    sendMessage(REGISTER_ENDPOINT, applicationConfig.toJSON());

    ScheduleExpression schedule = new ScheduleExpression();
    schedule.second("*/10").minute("*").hour("*").start(Calendar.getInstance().getTime());

    TimerConfig config = new TimerConfig();
    config.setPersistent(false);/* www .  ja  v a2 s.c o m*/

    Timer timer = timerService.createCalendarTimer(schedule, config);

    LOGGER.config(() -> timer.getSchedule().toString());
}