当前位置: 首页>>代码示例>>Java>>正文


Java Schedule类代码示例

本文整理汇总了Java中javax.ejb.Schedule的典型用法代码示例。如果您正苦于以下问题:Java Schedule类的具体用法?Java Schedule怎么用?Java Schedule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Schedule类属于javax.ejb包,在下文中一共展示了Schedule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runTasks

import javax.ejb.Schedule; //导入依赖的package包/类
@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();
        }
    }

}
 
开发者ID:jmd-stuff,项目名称:task-app,代码行数:22,代码来源:RunTimer.java

示例2: automaticCustomer

import javax.ejb.Schedule; //导入依赖的package包/类
/**
 * @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());
}
 
开发者ID:packt-wildfly,项目名称:packt-java-ee-7-code-samples,代码行数:25,代码来源:AutomaticSellerService.java

示例3: automaticCustomer

import javax.ejb.Schedule; //导入依赖的package包/类
@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());
}
 
开发者ID:packt-wildfly,项目名称:packt-java-ee-7-code-samples,代码行数:17,代码来源:AutomaticSellerService.java

示例4: scheduledMoveItemsOfDeadSystems

import javax.ejb.Schedule; //导入依赖的package包/类
@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");
        }
    }
}
 
开发者ID:weweave,项目名称:tubewarder,代码行数:18,代码来源:AliveStatusUpdater.java

示例5: cleanup

import javax.ejb.Schedule; //导入依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:voodoodyne,项目名称:subetha,代码行数:27,代码来源:CleanupBean.java

示例6: play

import javax.ejb.Schedule; //导入依赖的package包/类
@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);

}
 
开发者ID:mgreau,项目名称:docker4dev-tennistour-app,代码行数:25,代码来源:StarterService.java

示例7: refresh

import javax.ejb.Schedule; //导入依赖的package包/类
/**
 * 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");
	}
}
 
开发者ID:Comcast,项目名称:cats,代码行数:35,代码来源:KeyManagerImpl.java

示例8: run

import javax.ejb.Schedule; //导入依赖的package包/类
@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 );
        }
    }
}
 
开发者ID:Comcast,项目名称:cats,代码行数:27,代码来源:RebootProcessingEngine.java

示例9: checkSystemStatus

import javax.ejb.Schedule; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:romainGuiet,项目名称:fablab-web,代码行数:22,代码来源:SystemChecker.java

示例10: run

import javax.ejb.Schedule; //导入依赖的package包/类
@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");
            }
        }
    }
}
 
开发者ID:ivanbanos,项目名称:inversionesgit,代码行数:22,代码来源:TimerCheckoutTareasEstado.java

示例11: removeOldSessions

import javax.ejb.Schedule; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:RomanKreisel,项目名称:Faktotum,代码行数:26,代码来源:AuthenticationBean.java

示例12: play

import javax.ejb.Schedule; //导入依赖的package包/类
@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);
    	}
	}
}
 
开发者ID:mgreau,项目名称:javaee7-websocket,代码行数:22,代码来源:StarterService.java

示例13: updateLegacyWarnings

import javax.ejb.Schedule; //导入依赖的package包/类
/**
 * 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
        }   
    }
}
 
开发者ID:dma-enav,项目名称:EnavShore,代码行数:25,代码来源:LegacyMsiService.java

示例14: refreshCache

import javax.ejb.Schedule; //导入依赖的package包/类
@Schedule(minute = "*/10")
@Lock(LockType.WRITE)
public void refreshCache() {
    cache = new HashMap<>();
    for (ConfigurationSetting configurationSetting : getAllConfigurationSettings()) {
        addToCache(configurationSetting);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:9,代码来源:ConfigurationServiceBean.java

示例15: givenRefreshCacheAnnotations

import javax.ejb.Schedule; //导入依赖的package包/类
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;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:11,代码来源:ConfigurationServiceBeanIT.java


注:本文中的javax.ejb.Schedule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。