Java 类javax.ejb.Schedule 实例源码

项目:task-app    文件:RunTimer.java   
@Schedule(minute = "*/1", hour = "*", persistent = false)
public void runTasks() {
    if (!taskRunner.isBusy()) {
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("Run tasks started.");
        }
        taskRunner.runTasks();
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("Run tasks finished.");
        }

        if (taskAppService.getDeleteEnabled()) {
            deleteFinishedTasks();
        }

        if (taskAppService.getTimeoutEnabled()) {
            interruptTasks();
        }
    }

}
项目:packt-java-ee-7-code-samples    文件:AutomaticSellerService.java   
/**
 * @throws NoSuchSeatException
 *             if this is throw here, then this is a programming error
 */
@Schedule(hour = "*", minute = "*/1", persistent = false)
public void automaticCustomer() throws NoSuchSeatException {
    final Optional<Seat> seatOptional = findFreeSeat();

    if (!seatOptional.isPresent()) {
        cancelTimers();
        logger.info("Scheduler gone!");
        return; // No more seats
    }

    final Seat seat = seatOptional.get();

    try {
        theatreBox.buyTicket(seat.getId());
    } catch (SeatBookedException e) {
        // do nothing, user booked this seat in the meantime
    }

    logger.info("Somebody just booked seat number " + seat.getId());
}
项目:packt-java-ee-7-code-samples    文件:AutomaticSellerService.java   
/**
 * @throws NoSuchSeatException
 *             if this is throw here, then this is a programming error
 */
@Schedule(hour = "*", minute = "*/1", persistent = false)
public void automaticCustomer() throws NoSuchSeatException {
    final Optional<Seat> seatOptional = findFreeSeat();

    if (!seatOptional.isPresent()) {
        cancelTimers();
        logger.info("Scheduler gone!");
        return; // No more seats
    }

    final Seat seat = seatOptional.get();

    try {
        theatreBox.buyTicket(seat.getId());
    } catch (SeatBookedException e) {
        // do nothing, user booked this seat in the meantime
    }

    logger.info("Somebody just booked seat number " + seat.getId());
}
项目:packt-java-ee-7-code-samples    文件:AutomaticSellerService.java   
@Schedule(hour = "*", minute = "*", second = "*/30", persistent = false)
public void automaticCustomer() {
    final Optional<Seat> seatOptional = findFreeSeat();

    if (!seatOptional.isPresent()) {
        cancelTimers();
        logger.info("Scheduler gone!");
        return; // No more seats
    }

    final Seat seat = seatOptional.get();

    theatreBox.buyTicket(seat.getId());

    logger.info("Somebody just booked seat number " + seat.getId());
}
项目:tubewarder    文件:AliveStatusUpdater.java   
@Schedule(minute = "*", hour = "*", second = "*/15", persistent = false)
private void scheduledMoveItemsOfDeadSystems() {
    if (isMaster()) {
        LOG.info("Checking for queue items of dead systems in cluster (this is the cluster's master: ID="+SystemIdentifier.getIdentifier()+")");
        List<System> deadSystems = getSystemDao().getAllDeadWithQueueItems(getSystemDeadSeconds());
        if (deadSystems != null && deadSystems.size() > 0) {
            List<System> aliveSystems =  getSystemDao().getAllAlive(getSystemDeadSeconds());
            for (System deadSystem : deadSystems) {
                Integer sourceId = deadSystem.getSystemId();
                Integer targetId = aliveSystems.get(ThreadLocalRandom.current().nextInt(aliveSystems.size())).getSystemId();
                LOG.info("Moving dangling queue items from source ID=" + sourceId + " to target ID=" + targetId);
                getSendQueueItemDao().moveItems(sourceId, targetId);
            }
            LOG.info("Finished moving dangling queue items");
        }
    }
}
项目:subetha    文件:CleanupBean.java   
/**
 * Cleans up held {@link Subscription}s and {@link Mail}
 **/
@Schedule(minute="*/15", hour="*")
public void cleanup()
{
    log.log(Level.FINE,"Starting cleanup");
    log.log(Level.FINE,"em is {0}", this.em);
    try
    {
        if(!isRunning)
        {
            isRunning = true;
            this.cleanupHeldSubscriptions();
            this.cleanupHeldMail();
        }
        else
        {
            log.warning("Attempted to start cleanup while one is already running; skipping cleanup.");              
        }
    }
    finally 
    {
        isRunning = false;
    }
}
项目:docker4dev-tennistour-app    文件:StarterService.java   
@Schedule(second="*/2", minute="*",hour="*", persistent=false)
public void play() {

    Set<byte[]> matches = jedis.smembers(jedisKey.getBytes());

    try {
        for (Iterator<byte[]> it = matches.iterator(); it.hasNext();) {
            TennisMatch m = (TennisMatch) deserialize(it.next());

            logger.info("Get from cache Key: " + m.getKey());
            MatchEndpoint.send(new MatchMessage(m), m.getKey());
            //if there is a winner, send result and reset the game
            if (m.isFinished()) {
                MatchEndpoint.sendBetMessages(m.playerWithHighestSets(), m.getKey(), true);
            }
        }
    }catch (Exception ex){
        logger.severe("Error with Cache " + ex.getCause());
        ex.printStackTrace();
    }
    Long nbMatches = jedis.scard(jedisKey.getBytes());
    logger.info("Number of matches: " + nbMatches);

}
项目:cats    文件:KeyManagerImpl.java   
/**
 * Let's schedule all remote updates for every 5 minutes.
 * WARNING!!!
 * You must keep persistent=false otherwise the timer
 * will be added to the DB each time the service is redeployed or the server is
 * restarted.  This will cause the method to be invoked N times at the timeout where
 * N is the number of restarts + deployments.
 * WARNING!!!
 * 
*/
@Override
@Schedule(second="0", minute="*/5", hour="*", persistent=false)
public void refresh() {
    KeyManagerProxy kmProxy = keyManagerProxyProvider.get();
    if(kmProxy != null) {
        try {
            List<Remote> remotes=kmProxy.remotes();
            remoteLookup.processRemotes(remotes);
            //Now iterate each remote type and get the remote layout  for that type.
            for(Remote remote:remotes){
                String remoteName=remote.getName();
                logger.debug(" Going to retrieve remote layout for: {} ",remoteName);
                List<RemoteLayout> layout=kmProxy.getRemoteLayout(remoteName);
                remoteLayoutLookup.processRemoteLayout(remoteName,layout);
            }
            lastSuccessfulRefresh = new Date();
        } catch(IllegalArgumentException e) {
            logger.error(e.getMessage());
        }
    } 
    else {
        logger.warn("KeyManagerProxy is null couldn't process keys");
    }
}
项目:cats    文件:RebootProcessingEngine.java   
@Schedule( second = "0", minute = "*/1", hour = "*", persistent = false )
public void run()
{
    logger.trace( "run" );
    List< Host > hosts = service.getEnabledHosts();
    for ( Host h : hosts )
    {
        /*
         * Enclose this in a large try/catch to prevent single host
         * exception from preventing reboot detection for remainder of
         * devices.
         */
        try
        {
            SettopSnmpUptimeRequestHandler handler = new SettopSnmpUptimeRequestHandler( h.getMacAddress(),
                    h.getIpAddress(), h.getEcm() );
            Long uptime = handler.retrieveUptime();
            logger.info( "{} = {}", h, uptime );
            service.processUptime( h, uptime, handler.getRebootDetectionStatus() );
        }
        catch ( Exception e )
        {
            logger.warn( "Unknown Exception Caught processing hosts", e );
        }
    }
}
项目:fablab-web    文件:SystemChecker.java   
@Schedule(second = "0", minute = "*", hour = "*")
public void checkSystemStatus() {
    try {
        List<SystemStatusEO> listSystems = systemStatusService.getAllSystemStatus();
        LOG.info("Check status started, " + listSystems.size() + " systems to check");

        for (SystemStatusEO system : listSystems) {
            AbstractSystem content = SystemStatusFactory.getSystemStatusObject(system);
            boolean changed = content.executeCheck();
            LOG.info("Check of system " + system.getName() + ", changed = " + changed);
            if (changed) {
                system.setContent(content.marshal());
                systemStatusService.save(system);
                broadcastSystemStatusChanged(system, content.getReadableStatus(system));
            }
        }

    } catch (FablabException ex) {
        java.util.logging.Logger.getLogger(SystemChecker.class.getName()).log(Level.SEVERE, null, ex);
    }
}
项目:inversionesgit    文件:TimerCheckoutTareasEstado.java   
@PostConstruct
@Schedule(hour = "*/1", minute = "0", second = "0", persistent = false)
public void run() {
    List<Tarea> lista = tareasFacadeLocal.findAll();
    for (Tarea tarea : lista) {
        if (!tarea.getEstado().equals("VENCIDO")) {
            Calendar fechainicio = Calendar.getInstance();
            Calendar fechafinal = Calendar.getInstance();
            Calendar nowDate = Calendar.getInstance();
            fechainicio.setTime(tarea.getFechaInicio());
            fechafinal.setTime(tarea.getFechaFinalizacion());
            tarea.setEstado("POR INICIAR");
            if (fechainicio.before(nowDate)) {
                tarea.setEstado("ACTIVO");
            }
            if (fechafinal.before(nowDate)) {
                tarea.setEstado("VENCIDO");
            }
        }
    }
}
项目:Faktotum    文件:AuthenticationBean.java   
/**
 * Removes outdated sessions from the system
 */
@Schedule(second = "0", minute = "0", hour = "0", persistent = false)
public void removeOldSessions() {
    long startTime = System.currentTimeMillis();
    long numberOfSessions = 0;
    List<SessionEntity> sessions = this.sessionDao.getAll(SessionEntity.class);
    if (sessions != null) {
        for (SessionEntity session : sessions) {
            if (session != null) {
                Integer maxAgeInSeconds = this.settingBean.getIntegerSettingValue(SettingBean.SETTING_LONG_AUTH_SESSION_MAXAGE);
                long ageInSeconds = (System.currentTimeMillis() - session.getCreationTimestamp().getTime()) / 1000;
                if (ageInSeconds >= maxAgeInSeconds) {
                    numberOfSessions++;
                    this.getLogger().warning(
                            "Session " + session.getKey() + " for " + session.getBundesbruder().getUserName()
                                    + " is too old and cannot be used anymore - it will be removed");
                    this.sessionDao.remove(session);
                }
            }
        }
    }
    this.getLogger().info("Removed " + numberOfSessions + " old session(s) in " + (System.currentTimeMillis() - startTime) + " ms");
}
项目:javaee7-websocket    文件:StarterService.java   
@Schedule(second="*/3", minute="*",hour="*", persistent=false)
public void play() {
    for (Map.Entry<String,TennisMatch> match : matches.entrySet()){
        TennisMatch m = match.getValue();
        if (m.isFinished()){
            //add a timer to restart a match after 20 secondes
            m.reset();
        }
        //Handle point
        if (random.nextInt(2) == 1){
            m.playerOneScores();
        } else {
            m.playerTwoScores();
        }
        MatchEndpoint.send(new MatchMessage(m), match.getKey());
        //if there is a winner, send result and reset the game
        if (m.isFinished()){
            MatchEndpoint.sendBetMessages(m.playerWithHighestSets(), match.getKey(), true);
        }
    }
}
项目:EnavShore    文件:LegacyMsiService.java   
/**
 * Called every 5 minutes to update the legacy MSI warnings
 */
@Schedule(persistent=false, second="13", minute="*/5", hour="*", dayOfWeek="*", year="*")
public void updateLegacyWarnings() {

    List<MsiDto> warnings = getActiveWarnings();
    log.info("Fetched " + warnings.size() + " legacy MSI warnings");

    for (MsiDto msi : warnings) {
        // Either create a new MSI or update an existing
        Message msg = messageService.findByMessageSeriesId(
                msi.getMessageId(), 
                msi.getCreated().toGregorianCalendar().get(Calendar.YEAR), 
                msi.getOrganisation());

        if (msg == null) {
            // Create a new message
            createNewNavwarnMessage(msi);
        } else {
            // TODO
        }   
    }
}
项目:oscm    文件:ConfigurationServiceBean.java   
@Schedule(minute = "*/10")
@Lock(LockType.WRITE)
public void refreshCache() {
    cache = new HashMap<>();
    for (ConfigurationSetting configurationSetting : getAllConfigurationSettings()) {
        addToCache(configurationSetting);
    }
}
项目:oscm    文件:ConfigurationServiceBeanIT.java   
private List<Annotation> givenRefreshCacheAnnotations() {
    List<Annotation> result = new ArrayList<>();
    Annotation schedule = mock(Annotation.class);
    doReturn(Schedule.class).when(schedule).annotationType();
    doReturn("minute = \"*/10\"").when(schedule).toString();
    result.add(schedule);

    result.add(createLockAnnotation("LockType.WRITE"));
    return result;
}
项目:tap17-muggl-javaee    文件:ConfigBean.java   
/**
 * Creates a new tutoring session every day at midnight.
 */
@Schedule(dayOfWeek = "*")
public void createTutoringSession() {
    logger.info("Creating today's session in ConfigBean");
    // Create a new tutoring session
    requestBean.getTodaysSession();
}
项目:mid-tier    文件:SNBScheduler.java   
@Schedule(hour = "*", minute = "*/1", second = "0")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void doTimeout() {
    LOG.info("Running account poll");
    createRequest();
    LOG.info("...finished run");
}
项目:soapbox-race-core    文件:OnlineUsersBO.java   
@Schedule(minute = "*", hour = "*", persistent = false)
public void insertNumberOfUsesOnlineNow() {
    Long timeLong = new Date().getTime() / 1000L;
    OnlineUsersEntity onlineUsersEntity = new OnlineUsersEntity();
    onlineUsersEntity.setNumberOfUsers(openFireRestApiCli.getTotalOnlineUsers());
    onlineUsersEntity.setTimeRecord(timeLong.intValue());
    onlineUsersDAO.insert(onlineUsersEntity);
}
项目:USM    文件:PasswordNotifierScheduler.java   
/**
   * Triggers the sending of notifications (or reminders) to users 
   * whose password is about to  expire.
   * 
   * Scheduled job running every 6 hours on the hour.
   */
  @Schedule(dayOfWeek="*", hour="*/6", minute="0")  
//  @Schedule(dayOfWeek="*", hour = "*", minute="*/5")  
  public void triggerNotifications() 
  {
    LOGGER.info("triggerNotifications() - (ENTER)");

    List<String> userNames = expiryReminder.findUsersToNotify();

    for (String userName : userNames) {
      expiryReminder.notifyUser(userName);
    }

    LOGGER.info("triggerNotifications() - (LEAVE)");
  }
项目:iws    文件:NotificationManagerScheduler.java   
@Schedule(second = "*/30",minute = "*", hour = "*", info="Every 30 seconds", persistent = false)
public void processJobsScheduled() {
    LOG.trace("processJobsScheduled started at {}", new DateTime());
    try {
        notifications.processJobs();
    } catch (RuntimeException e) {
        LOG.error("Exception caught in notification processing", e);
    }
}
项目:ee-scheduler    文件:AutomaticPersistentScheduler.java   
@Schedule(second = "*/5",
        minute = "*",
        hour = "*",
        info = "AutomaticPersistentScheduler",
        persistent = true)
public void process() {
    log.info(myService.sayCiao("AutomaticPersistentScheduler"));
}
项目:ee-scheduler    文件:AutomaticNonPersistentScheduler.java   
@Schedule(second = "*/7",
        minute = "*",
        hour = "*",
        info = "AutomaticNonPersistentScheduler",
        persistent = false)
public void process() {
    log.info(myService.sayCiao("AutomaticNonPersistentScheduler"));
}
项目:otus-domain-api    文件:AuditorServiceBean.java   
@Schedule(hour = "*/1", info = "Persist Auditor Log")
public void persist() {
    Auditor auditor = auditorContext.getAuditor();
    if (!auditor.isEmpty()) {
        auditorDao.merge(auditor);
        auditorContext.init();
    }
}
项目:jdg7-example    文件:WordCountAp.java   
@Schedule(second = "*/5", minute = "*", hour = "*", persistent = false)
public void timer() {
    if (jdg.getManager().isCoordinator()) {
        List<Entry<String, Long>> count = wordCount(10);
        log.infof("TIMER %s", count);
    }
}
项目:Service    文件:InsertBancoDeDados.java   
@Schedule(hour = "*", minute = "*", second = "*/20", persistent = false)
public void tarefa() {

    System.out.println(Thread.currentThread().getId() + ": [InsertBancoDeDados:tarefa] Verificando a existência de objetos para persistir ... ");

    while (!STACK_INSERT.empty()) {
        persistencia.insert(STACK_INSERT.pop());
    }
}
项目:Purifinity    文件:PurifinityServerStatusSocket.java   
@Schedule(hour = "*", minute = "*", second = "*/10")
   public void periodicUpdate() {
if (session != null) {
    logger.trace("Periodic status update...");
    PurifinityServerStatus status = purifinityServer.getStatus();
    for (Session client : session.getOpenSessions()) {
    try {
        client.getBasicRemote().sendObject(status);
    } catch (IOException | EncodeException | NullPointerException e) {
        logger.error("Could not send status message.", e);
    }
    }
}
   }
项目:Purifinity    文件:PurifinityJobsSocket.java   
@Schedule(hour = "*", minute = "*", second = "*/5")
public void sendUpdate() {
    if (session != null) {
        logger.trace("Send job updates...");
        PurifinityJobStates states = getJobStates();
        for (Session client : session.getOpenSessions()) {
            try {
                client.getBasicRemote().sendObject(states);
            } catch (IOException | EncodeException | NullPointerException e) {
                logger.error("Could not send status message.", e);
            }
        }
    }
}
项目:development    文件:ConfigurationServiceBean.java   
@Schedule(minute = "*/10")
@Lock(LockType.WRITE)
public void refreshCache() {
    cache = new HashMap<>();
    for (ConfigurationSetting configurationSetting : getAllConfigurationSettings()) {
        addToCache(configurationSetting);
    }
}
项目:development    文件:ConfigurationServiceBeanIT.java   
private List<Annotation> givenRefreshCacheAnnotations() {
    List<Annotation> result = new ArrayList<>();
    Annotation schedule = mock(Annotation.class);
    doReturn(Schedule.class).when(schedule).annotationType();
    doReturn("minute = \"*/10\"").when(schedule).toString();
    result.add(schedule);

    result.add(createLockAnnotation("LockType.WRITE"));
    return result;
}
项目:vocloud    文件:SchedulerBean.java   
/**
     * periodically query uws for job's progress
     *
     */
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    @Schedule(second = "*/10", minute = "*", hour = "*", persistent = false)
    public void updateExecutingJobs() {
        int prevsize = watchedJobs.size();
        for (Job job : watchedJobs) {
            UWSJob uwsJob = jf.refreshJob(job);
            if (job.getPhase() == Phase.COMPLETED || job.getPhase() == Phase.ERROR || job.getPhase() == Phase.ABORTED) {
//                jf.exportUWSJob(job);
                watchedJobs.remove(job);
                if (uwsJob != null){
                    jf.downloadResults(job, uwsJob);
                }
                jf.destroyRemoteJob(job);
                if (job.getResultsEmail()){
                    jf.sendResults(job);
                }
                if (job.getTargetDir() != null){
                    jf.copyResultsToFilesystem(job);
                }
            }
        }
        lastUpdate = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat();
        if (prevsize != watchedJobs.size()) {
            logger.log(Level.INFO, "update happened at {0}", sdf.format(lastUpdate));
            logger.log(Level.INFO, "watched jobs: {0}", watchedJobs.size());
        }
    }
项目:darceo    文件:RegistrySynchronisatorBean.java   
/**
 * Synchronizes registry with remote registries marked for harvesting.
 * 
 * @param timer
 *            EJB timer injected by cron job.
 */
@Schedule(hour = "1", minute = "0", second = "0", dayOfWeek = "*", persistent = true, info = "Every 1am")
public void run(Timer timer) {
    List<RemoteRegistry> retrieveRemoteRegistries = remoteRegistryManager.retrieveRemoteRegistries(null, null,
        Boolean.TRUE);
    for (RemoteRegistry remoteRegistry : retrieveRemoteRegistries) {
        try {
            registryHarvester.harvestRegistry(remoteRegistry);
        } catch (HarvestingException exception) {
            handleException(remoteRegistry, exception);
            continue;
        }
    }
}
项目:darceo    文件:CacheCleanerBean.java   
/**
 * Runs the scheduled cache cleaning every 12 hours starting from 1AM.
 * 
 * @param timer
 *            schedule's timer.
 */
@Schedule(hour = "*", minute = "0", second = "0", dayOfWeek = "*", persistent = true, info = "Every full hour")
public void run(Timer timer) {
    Integer invalidationPeriod = zmdConfiguration.getCacheStaleAfter();
    String cacheHome = zmdConfiguration.getCacheHome();
    File home = new File(cacheHome);
    File[] cachedSessions = home.listFiles();
    Long invalidatedFrom = (new GregorianCalendar().getTimeInMillis()) - invalidationPeriod * TIME_UNIT_MULTIPLIER;
    for (File file : cachedSessions) {
        if (file.lastModified() <= invalidatedFrom) {
            FileUtils.deleteQuietly(file);
        }
    }
}
项目:darceo    文件:AsyncRequestCleanerBean.java   
/**
 * Cleans responses for asynchronous request. Both in the database and on the disk.
 * 
 * @param timer
 *            timer
 */
@Schedule(hour = "0", minute = "0", second = "0", dayOfWeek = "*", persistent = true,
        info = "Every day at midnight")
public void run(Timer timer) {
    int days = config.getAsyncCleaningPeriod();
    Calendar now = Calendar.getInstance();
    now.set(Calendar.HOUR_OF_DAY, 0);
    now.set(Calendar.MINUTE, 0);
    now.set(Calendar.SECOND, 0);
    now.set(Calendar.MILLISECOND, 0);
    Date date = now.getTime();
    date.setTime(date.getTime() - (days + 1) * 86400000L);
    logger.debug("cleaning all results before " + date + " (cleaning period: " + days + " days");
    AsyncRequestResultFilterFactory queryFilterFactory = asyncRequestResultDaoBean.createQueryModifier()
            .getQueryFilterFactory();
    List<AsyncRequestResult> results = asyncRequestResultDaoBean.findBy(
        queryFilterFactory.byCompletedBefore(date, false), false);
    logger.debug("results to remove: " + results.size());
    String root = config.getAsyncCacheHome();
    for (AsyncRequestResult result : results) {
        logger.debug("result: " + result);
        boolean success = true;
        if (result.hasContent()) {
            File file = new File(root + "/" + result.getId());
            if (file.exists()) {
                success = file.delete();
                if (success) {
                    logger.debug("File " + result.getId() + " successfully deleted");
                } else {
                    logger.debug("Deleting the file " + result.getId() + " failed");
                }
            } else {
                logger.debug("File " + result.getId() + " does not exist!");
            }
        }
        if (success) {
            asyncRequestResultDaoBean.delete(result);
        }
    }
}
项目:predcomposer    文件:AutomaticGameLocker.java   
@Schedule(hour = "*", minute = "10/15", persistent = false)
public void lockRecentGames() {
    final LocalDateTime now = LocalDateTime.now();
    final LocalDateTime fiveMinutesLater = now.plusMinutes(5);
    TypedQuery<Game> recentGamesQuery = entityManager.createNamedQuery("getRecentGames",
            Game.class);
    recentGamesQuery.setParameter("kickoffTime", fiveMinutesLater);
    recentGamesQuery.getResultList().forEach(this::lockGame);
}
项目:packt-java-ee-7-code-samples    文件:WatchMyDB.java   
@Schedule(dayOfWeek = "*", hour = "*", minute = "*", second =
        "*/30", year = "*", persistent = false)
public void backgroundProcessing() {
    ModelControllerClient client = null;
    try {
        client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9990);

        final ModelNode operation = new ModelNode();
        operation.get("operation").set("read-resource");
        operation.get("include-runtime").set(true);
        final ModelNode address = operation.get("address");
        address.add("subsystem", "datasources");
        address.add("data-source", "ExampleDS");
        address.add("statistics", "pool");
        final ModelNode returnVal = client.execute(operation);

        final ModelNode node2 = returnVal.get("result");
        final String stringActiveCount = node2.get("ActiveCount").asString();

        if (stringActiveCount.equals("undefined")) {
            return; // Connection unused
        }
        int activeCount = Integer.parseInt(stringActiveCount);

        if (activeCount > 50) {
            alertAdministrator();
        }
    } catch (Exception exc) {
        logger.log(Level.SEVERE, "Exception !", exc);
    } finally {
        safeClose(client);
    }
}
项目:packt-java-ee-7-code-samples    文件:AutomaticSellerService.java   
@Schedule(hour = "*", minute = "*", second = "*/30", persistent = false)
public void automaticCustomer() {
    final Seat seat = findFreeSeat();

    if (seat == null) {
        cancelTimers();
        logger.info("Scheduler gone!");
        return; // No more seats
    }

    theatreBox.buyTicket(seat.getId());

    logger.info("Somebody just booked seat number " + seat.getId());
}
项目:activemq-consumer-producer-jee    文件:TimerBean.java   
@Schedule(second="*/20", minute="*",hour="*", persistent=false)
public void timeout(Timer timer) {
    System.out.println("Producing 100 messages every 20 seconds.");
    for (int i = 0; i < 100; i++){
        try {
            messageSender.sendMessage("message nr " + counter);
        } catch (JMSException e) {
            System.out.println("Message nr "+counter+" could not be sent.");
        }
        counter++;
    }
}
项目:docker4dev-tennistour-app    文件:StarterServiceJobs.java   
@Schedule(second="*/30", minute="*",hour="*", persistent=false)
public void loadDatas() {
    final Properties props = new Properties();
    props.put("csvDatasFileName",
              "ausopen_ATP_2013.csv");
     long jid = jo.start("loadHistoryJob", props);

     JobExecution je = jo.getJobExecution(jid);
     logger.log(Level.INFO, "Job created on: " + je.getCreateTime() + "<br>");
     logger.log(Level.INFO, "Job started on: " + je.getStartTime() + "<br>");
}
项目:hopsworks    文件:ZookeeprTopicCleanerTimer.java   
/**
 * Get kafka broker endpoints and update them in Settings.
 * These topics are used for passing broker endpoints to HopsUtil and to KafkaFacade.
 */
@Schedule(persistent = false,
    minute = "*/1",
    hour = "*")
public void getBrokers() {
  try {
    settings.setKafkaBrokers(settings.getBrokerEndpoints());
  } catch (AppException ex) {
    LOGGER.log(Level.SEVERE, null, ex);
  }
}