本文整理汇总了Java中javax.ejb.TimerConfig类的典型用法代码示例。如果您正苦于以下问题:Java TimerConfig类的具体用法?Java TimerConfig怎么用?Java TimerConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimerConfig类属于javax.ejb包,在下文中一共展示了TimerConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: fireUpTimer
import javax.ejb.TimerConfig; //导入依赖的package包/类
public BatchJobConfiguration fireUpTimer(BatchJobConfiguration jobConfig) {
if (jobConfig.isActive()) {
logger.debug("Configured batch job " + jobConfig.getType().getDisplayName());
TimerConfig timerConf = new TimerConfig(jobConfig, false);
String[] splittedCronJob = jobConfig.getCronJobExpression().split(" ");
ScheduleExpression schedExp = new ScheduleExpression();
schedExp.second(splittedCronJob[0]);
schedExp.minute(splittedCronJob[1]);
schedExp.hour(splittedCronJob[2]);
schedExp.dayOfMonth(splittedCronJob[3]);
schedExp.month(splittedCronJob[4]);
schedExp.year(splittedCronJob[5]);
schedExp.dayOfWeek(splittedCronJob[6]);
Timer timer = timerService.createCalendarTimer(schedExp, timerConf);
jobConfig.setNextTimeout(timer.getNextTimeout());
jobConfig = batchJobConfigurationDAO.update(jobConfig);
}
return jobConfig;
}
示例3: programmaticTimeout
import javax.ejb.TimerConfig; //导入依赖的package包/类
public void programmaticTimeout() {
logger.info("TimerEJB: programmatic timeout occurred");
timeoutDone = false;
long duration = 60;
Timer timer = timerService.createSingleActionTimer(duration, new TimerConfig());
timer.getInfo();
try {
timer.getSchedule();
} catch (IllegalStateException e) {
logger.log(SEVERE, "it is not a scheduler", e);
}
TimerHandle timerHandle = timer.getHandle();
timerHandle.getTimer();
timer.isCalendarTimer();
timer.isPersistent();
timer.getTimeRemaining();
}
示例4: 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));
}
示例5: 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);
}
示例6: initialize
import javax.ejb.TimerConfig; //导入依赖的package包/类
@PostConstruct
private void initialize() {
log.info("IoCWithCustomProtostreamGenerator initialize...");
new File(GENERATED_PROTOFILES_DIRECTORY).mkdirs();
if (SINKIT_ALL_IOC_PROTOSTREAM_GENERATOR_D_H_M_S != null) {
timerService.createCalendarTimer(new ScheduleExpression()
.dayOfWeek(SINKIT_ALL_IOC_PROTOSTREAM_GENERATOR_D_H_M_S[0])
.hour(SINKIT_ALL_IOC_PROTOSTREAM_GENERATOR_D_H_M_S[1])
.minute(SINKIT_ALL_IOC_PROTOSTREAM_GENERATOR_D_H_M_S[2])
.second(SINKIT_ALL_IOC_PROTOSTREAM_GENERATOR_D_H_M_S[3])
, new TimerConfig(ALL_IOC_TAG, false));
log.info("IoCWithCustomProtostreamGenerator: All IoC Protostream Generator");
}
if (SINKIT_ALL_CUSTOM_PROTOSTREAM_GENERATOR_D_H_M_S != null) {
timerService.createCalendarTimer(new ScheduleExpression()
.dayOfWeek(SINKIT_ALL_CUSTOM_PROTOSTREAM_GENERATOR_D_H_M_S[0])
.hour(SINKIT_ALL_CUSTOM_PROTOSTREAM_GENERATOR_D_H_M_S[1])
.minute(SINKIT_ALL_CUSTOM_PROTOSTREAM_GENERATOR_D_H_M_S[2])
.second(SINKIT_ALL_CUSTOM_PROTOSTREAM_GENERATOR_D_H_M_S[3])
, new TimerConfig(ALL_CUSTOM_TAG, false));
log.info("IoCWithCustomProtostreamGenerator: All Custom Protostream Generator");
}
}
示例7: initialize
import javax.ejb.TimerConfig; //导入依赖的package包/类
@PostConstruct
private void initialize() {
new File(GENERATED_PROTOFILES_DIRECTORY).mkdirs();
if (SINKIT_CUSTOMLIST_PROTOSTREAM_GENERATOR_D_H_M_S != null) {
timerService.createCalendarTimer(new ScheduleExpression()
.dayOfWeek(SINKIT_CUSTOMLIST_PROTOSTREAM_GENERATOR_D_H_M_S[0])
.hour(SINKIT_CUSTOMLIST_PROTOSTREAM_GENERATOR_D_H_M_S[1])
.minute(SINKIT_CUSTOMLIST_PROTOSTREAM_GENERATOR_D_H_M_S[2])
.second(SINKIT_CUSTOMLIST_PROTOSTREAM_GENERATOR_D_H_M_S[3])
, new TimerConfig("CustomlistProtostreamGenerator", false));
} else {
log.info("CustomlistProtostreamGenerator timer not activated.");
}
}
示例8: createTimer
import javax.ejb.TimerConfig; //导入依赖的package包/类
@Override
public Timer createTimer(final Object primaryKey,
final Method timeoutMethod,
final long duration,
final TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException {
if (duration < 0) {
throw new IllegalArgumentException("duration is negative: " + duration);
}
checkState();
final Date expiration = new Date(System.currentTimeMillis() + duration);
try {
final TimerData timerData = timerStore.createSingleActionTimer(this, (String) deployment.getDeploymentID(), primaryKey, timeoutMethod, expiration, timerConfig);
initializeNewTimer(timerData);
return timerData.getTimer();
} catch (final TimerStoreException e) {
throw new EJBException(e);
}
}
示例9: createCalendarTimer
import javax.ejb.TimerConfig; //导入依赖的package包/类
@Override
public Timer createCalendarTimer(ScheduleExpression arg0, TimerConfig arg1)
throws IllegalArgumentException, IllegalStateException,
EJBException {
TimerStub timer = new TimerStub(arg0, arg1);
timers.add(timer);
return timer;
}
示例10: createIntervalTimer
import javax.ejb.TimerConfig; //导入依赖的package包/类
@Override
public Timer createIntervalTimer(long arg0, long arg1, TimerConfig arg2)
throws IllegalArgumentException, IllegalStateException,
EJBException {
return null;
}
示例11: createSingleActionTimer
import javax.ejb.TimerConfig; //导入依赖的package包/类
@Override
public Timer createSingleActionTimer(long arg0, TimerConfig arg1)
throws IllegalArgumentException, IllegalStateException,
EJBException {
return null;
}
示例12: TimerStub
import javax.ejb.TimerConfig; //导入依赖的package包/类
public TimerStub(ScheduleExpression scheduleExpression, TimerConfig config) {
this.scheduleExpression = scheduleExpression;
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, 1);
this.execDate = cal.getTime();
this.info = config.getInfo();
}
示例13: init
import javax.ejb.TimerConfig; //导入依赖的package包/类
@PostConstruct
public void init() {
/**
* fires 5 secs after creation interval = 5 secs non-persistent
* no-additional (custom) info
*/
timer = ts.createIntervalTimer(5000, 5000, new TimerConfig(null, false)); //trigger every 5 seconds
Logger.getLogger(PingForLeaders.class.getName()).log(Level.INFO, "Timer initiated");
jedis = new Jedis("192.168.99.100", 6379, 10000);
}
示例14: createTimer
import javax.ejb.TimerConfig; //导入依赖的package包/类
private void createTimer(long interval) {
if (tm == null)
tm = context.getTimerService().createIntervalTimer(0, interval, new TimerConfig());
else {
tm.cancel();
tm = context.getTimerService().createIntervalTimer(0, interval, new TimerConfig());
}
logger.debug("Timer started, remaining time: {}", tm.getTimeRemaining());
}
示例15: 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.");
}