本文整理汇总了Java中javax.ejb.TimerConfig.setInfo方法的典型用法代码示例。如果您正苦于以下问题:Java TimerConfig.setInfo方法的具体用法?Java TimerConfig.setInfo怎么用?Java TimerConfig.setInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ejb.TimerConfig
的用法示例。
在下文中一共展示了TimerConfig.setInfo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTimerWithPeriod
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
void createTimerWithPeriod(TimerService timerService, TimerType timerType,
long timerOffset, Period period) {
if (isTimerCreated(timerType, timerService)) {
return;
}
TimerConfig config = new TimerConfig();
config.setInfo(timerType);
Date startDate = getDateForNextTimerExpiration(period, timerOffset);
ScheduleExpression schedleExpression = getExpressionForPeriod(period,
startDate);
Timer timer = timerService.createCalendarTimer(schedleExpression,
config);
Date nextStart = timer.getNextTimeout();
SimpleDateFormat sdf = new SimpleDateFormat();
logger.logInfo(Log4jLogger.SYSTEM_LOG,
LogMessageIdentifier.INFO_TIMER_CREATED,
String.valueOf(timerType), sdf.format(nextStart));
}
示例2: initTimers_interval
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
@Test
public void initTimers_interval() throws Exception {
// given
TimerServiceStub timeServiceStub = mock(TimerServiceStub.class);
when(ctx.getTimerService()).thenReturn(timeServiceStub);
TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo(TimerType.BILLING_INVOCATION);
doReturn(new TimerStub(null, timerConfig)).when(timeServiceStub)
.createCalendarTimer(any(ScheduleExpression.class),
any(TimerConfig.class));
// when
tm.initTimers();
// then
verify(timeServiceStub, times(4)).createTimer(any(Date.class),
eq(10000L), any(TimerType.class));
}
示例3: startup
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
/**
* <p>Starts the The Timer Scheduler to handle Mail Synchronization.</p>
*/
@PostConstruct
public void startup() {
LOG.info("Starting IWS Mail Synchronize Bean.");
// Registering the Timer Service. This will ensure that the Scheduler
// is invoked at frequent intervals.
final TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo("IWS Mail Synchronize");
timerConfig.setPersistent(false);
final ScheduleExpression expression = new ScheduleExpression();
final String[] time = settings.getMailSynchronizeTime().split(":", 2);
expression.hour(time[0]).minute(time[1]);
timerService.createCalendarTimer(expression, timerConfig);
LOG.info("First synchronize run scheduled to begin at {}", expression);
}
示例4: startup
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
/**
* To ensure that the system State is always consistent, we have two things
* that must be accomplished. First thing is to load the former state and
* ensure that the system is working using this as base.<br />
* Second part is to have a timer service (cron job), which will once per
* day run and perform certain cleanup actions.<br />
* This method is run once the Bean is initialized and will perform two
* things, first it will initialize the Timer Service, so it can run at
* frequent Intervals, secondly, it will initialize the Sessions.<br />
* Heavier maintenance operations like cleaning up accounts is left for
* the Timed Service to handle, since it may otherwise put the server under
* unnecessary pressure during the initial Startup Phase.
*/
@PostConstruct
public void startup() {
LOG.info("Starting IWS Initialization.");
// First, we need to initialize our dependencies
activeSessions = ActiveSessions.getInstance(settings);
accessDao = new AccessJpaDao(entityManager, settings);
exchangeDao = new ExchangeJpaDao(entityManager, settings);
service = new AccountService(settings, accessDao, notifications);
// Second, we're registering the Timer Service. This will ensure that the
// Bean is invoked daily at 2 in the morning.
final TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo("IWS State Cleaner");
timerConfig.setPersistent(false);
final ScheduleExpression expression = new ScheduleExpression();
final String[] time = settings.getRunCleanTime().split(":", 2);
expression.hour(time[0]).minute(time[1]);
timerService.createCalendarTimer(expression, timerConfig);
LOG.info("First cleanup run scheduled to begin at {}", expression);
if (settings.resetSessionsAtStartup()) {
// Now, remove all deprecated Sessions from the Server. These Sessions
// may or may not work correctly, since IW4 with JSF is combining the
// Sessions with a Windows Id, and upon restart - the Windows Id is
// renewed. Even if it isn't renewed, JSF will not recognize it
final int deprecated = accessDao.deprecateAllActiveSessions();
LOG.info("Deprecated {} Stale Sessions.", deprecated);
} else {
loadActiveTokens();
}
// That's it - we're done :-)
LOG.info("IWS Initialization Completed.");
}
示例5: createTimerConfig
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
private TimerConfig createTimerConfig() {
TimerConfig timerConfig = new TimerConfig();
// The name of the scheduler
timerConfig.setInfo("ProgrammaticPersistentScheduler");
// The scheduler is persistent.
// Set to false if we do want a non persistent scheduler
timerConfig.setPersistent(true);
return timerConfig;
}
示例6: startup
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
@PostConstruct
public void startup() {
log.info("Check if Database is up-to-date.");
if (checkDatabase()) {
log.info("Initialize the Settings.");
initializeSettings();
log.info("Initializing the CWS Sanitizer Service.");
// If requested, then simply start the sanitize as a background job
// now. The job will process small blocks of code and save these.
if (settings.getSanityStartup()) {
runSanitizing();
}
// Registering the Timer Service. This will ensure that the Scheduler
// is invoked at frequent intervals.
final TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo("CWS Sanitizer");
// Once started, the next run should always occur as planned, regardless
// of restarts, as it is not guaranteed that the sanitizing is performed
// at startup.
timerConfig.setPersistent(true);
// Starting the Timer Service every hour.
final ScheduleExpression expression = new ScheduleExpression();
expression.hour("*");
timerService.createCalendarTimer(expression, timerConfig);
}
}
示例7: addSchedulesToMethod
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
private void addSchedulesToMethod(final MethodContext methodContext, final MethodScheduleInfo info) {
if (methodContext == null) {
return;
}
for (final ScheduleInfo scheduleInfo : info.schedules) {
final ScheduleExpression expr = new ScheduleExpression();
expr.second(scheduleInfo.second == null ? "0" : scheduleInfo.second);
expr.minute(scheduleInfo.minute == null ? "0" : scheduleInfo.minute);
expr.hour(scheduleInfo.hour == null ? "0" : scheduleInfo.hour);
expr.dayOfWeek(scheduleInfo.dayOfWeek == null ? "*" : scheduleInfo.dayOfWeek);
expr.dayOfMonth(scheduleInfo.dayOfMonth == null ? "*" : scheduleInfo.dayOfMonth);
expr.month(scheduleInfo.month == null ? "*" : scheduleInfo.month);
expr.year(scheduleInfo.year == null ? "*" : scheduleInfo.year);
expr.timezone(scheduleInfo.timezone);
expr.start(scheduleInfo.start);
expr.end(scheduleInfo.end);
final TimerConfig config = new TimerConfig();
config.setInfo(scheduleInfo.info);
config.setPersistent(scheduleInfo.persistent);
methodContext.getSchedules().add(new ScheduleData(config, expr));
}
}
示例8: scheduleDelivery
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
/**
* Schedules an asynchronous delivery of messages in the given topic.
*
* @param timeout timeout after which the delivery is started
* @param topic the topic for which delivery is scheduled
*/
private void scheduleDelivery(long timeout, String topic) {
this.timerByTopicLock.lock();
try {
if (this.timerByTopic.get(topic) != null) return;
TimerConfig config = new TimerConfig();
config.setPersistent(false);
config.setInfo(topic);
Timer timer = timerService.createSingleActionTimer(timeout, config);
this.timerByTopic.put(topic, timer);
} finally {
timerByTopicLock.unlock();
}
}
示例9: finishSystemCreation
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
public void finishSystemCreation(CreateLPlatform lplatform) {
TimerConfig config = new TimerConfig();
config.setInfo(lplatform.getLplatformId());
timerService.createSingleActionTimer(60000L, config);
}
示例10: scheduleJobOnce
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
/**
* Schedule a job for a single execution, at the given date.
* <p/>
* @param job
* @param when
*/
public void scheduleJobOnce(Jobs job, Date when) {
TimerConfig config = new TimerConfig();
config.setInfo(job.getId());
timerService.createSingleActionTimer(when, config);
}
示例11: scheduleJobOnCalendar
import javax.ejb.TimerConfig; //导入方法依赖的package包/类
/**
* Schedule a job for regular execution.
* <p/>
* @param job
* @param when The ScheduleExpression dictating when the job should be run.
*/
public void scheduleJobOnCalendar(Jobs job, ScheduleExpression when) {
TimerConfig config = new TimerConfig();
config.setInfo(job.getId());
timerService.createCalendarTimer(when, config);
}