本文整理匯總了Java中javax.ejb.Timer.getInfo方法的典型用法代碼示例。如果您正苦於以下問題:Java Timer.getInfo方法的具體用法?Java Timer.getInfo怎麽用?Java Timer.getInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.ejb.Timer
的用法示例。
在下文中一共展示了Timer.getInfo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: programmaticTimeout
import javax.ejb.Timer; //導入方法依賴的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();
}
示例2: isTimerCreated
import javax.ejb.Timer; //導入方法依賴的package包/類
boolean isTimerCreated(TimerType timerType, TimerService timerService) {
for (Timer timer : ParameterizedTypes.iterable(
timerService.getTimers(), Timer.class)) {
TimerType tType = (TimerType) timer.getInfo();
if ((TimerType.BILLING_INVOCATION.equals(tType) && TimerType.BILLING_INVOCATION
.equals(timerType))
|| (TimerType.DISCOUNT_END_CHECK.equals(tType) && TimerType.DISCOUNT_END_CHECK
.equals(timerType))) {
long currentTime = System.currentTimeMillis();
if (timer.getNextTimeout().getTime() - currentTime > 0) {
return true;
} else {
timer.cancel();
}
}
}
return false;
}
示例3: cancelObsoleteTimer
import javax.ejb.Timer; //導入方法依賴的package包/類
/**
* Determines all currently queued timers and cancel timer with target type.
*
* @param timerService
* The timer service.
* @param timerType
* The timer type.
*/
private void cancelObsoleteTimer(TimerService timerService,
TimerType timerType) {
for (Timer timer : ParameterizedTypes.iterable(
timerService.getTimers(), Timer.class)) {
Serializable info = timer.getInfo();
if (info != null && info instanceof TimerType && timerType == info) {
TimerType type = (TimerType) info;
timer.cancel();
logger.logInfo(Log4jLogger.SYSTEM_LOG,
LogMessageIdentifier.INFO_TIMER_REMOVED,
String.valueOf(type));
}
}
}
示例4: getCurrentTimerExpirationDates
import javax.ejb.Timer; //導入方法依賴的package包/類
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public List<VOTimerInfo> getCurrentTimerExpirationDates() {
List<VOTimerInfo> result = new ArrayList<VOTimerInfo>();
for (Timer timer : ParameterizedTypes.iterable(ctx.getTimerService()
.getTimers(), Timer.class)) {
Serializable info = timer.getInfo();
if (info != null && info instanceof TimerType) {
TimerType type = (TimerType) info;
long expirationTime = timer.getTimeRemaining()
+ System.currentTimeMillis();
VOTimerInfo timerInfo = new VOTimerInfo();
timerInfo.setTimerType(type.name());
timerInfo.setExpirationDate(new Date(expirationTime));
result.add(timerInfo);
}
}
return result;
}
示例5: statusCronJob
import javax.ejb.Timer; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public String statusCronJob() {
String stat = null;
for (Timer timer : (Collection<Timer>) timerService.getTimers()) {
if (timer.getInfo() instanceof String) {
if (((String) timer.getInfo())
.equals(ERPQueryInventory.TIME_OUT_INFO)) {
log.info(" " + timer.toString());
stat = "Running. Remaining: " + timer.getTimeRemaining();
return stat;
}
}
}
return "Not running";
}
示例6: createKindleMail
import javax.ejb.Timer; //導入方法依賴的package包/類
@Timeout
public void createKindleMail(Timer timer) {
try {
Payload payload = (Payload)timer.getInfo();
BookEntry book = payload.getBook();
AppUser user = payload.getUser();
byte[] attachment = solrHandler.getMobiFormat(book.getId()).get(0).getMobi();
//1.Step Check if convert
if (attachment == null) {
convertEPubToMobi(book);
attachment = solrHandler.getMobiFormat(book.getId()).get(0).getMobi();
}
//2. Step Send Email
String filename = book.getTitle() + "-" + book.getAuthor();
sendKindleMail(user, attachment, filename);
} catch (SolrServerException | MessagingException | IOException | InterruptedException ex) {
logger.error("failed to create Kindle mail.",ex);
}
}
示例7: ejbTimeout
import javax.ejb.Timer; //導入方法依賴的package包/類
public void ejbTimeout(Timer theTimer) {
// Any code typically placed in an EJB method can be placed here.
String whyWasICalled = (String) theTimer.getInfo();
this.whyWasICalled = whyWasICalled;
logger.info("I was called because of" + whyWasICalled);
}
示例8: cancelAllObsoleteTimer
import javax.ejb.Timer; //導入方法依賴的package包/類
/**
* Determines all currently queued timers and cancels them.
*/
private void cancelAllObsoleteTimer() {
for (Timer timer : ParameterizedTypes.iterable(ctx.getTimerService()
.getTimers(), Timer.class)) {
Serializable info = timer.getInfo();
if (info != null && info instanceof TimerType) {
TimerType type = (TimerType) info;
timer.cancel();
logger.logInfo(Log4jLogger.SYSTEM_LOG,
LogMessageIdentifier.INFO_TIMER_REMOVED,
String.valueOf(type));
}
}
}
示例9: cancelCronJob
import javax.ejb.Timer; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void cancelCronJob() {
for (Timer timer : (Collection<Timer>) timerService.getTimers()) {
if (timer.getInfo() instanceof String) {
if (((String) timer.getInfo())
.equals(TIME_OUT_INFO)) {
timer.cancel();
log.info("Cancel timer: " + timer.toString());
return;
}
}
}
}
示例10: cancelCronJob
import javax.ejb.Timer; //導入方法依賴的package包/類
public void cancelCronJob() {
TimerService timerService = ctx.getTimerService();
for (Timer timer : (Collection<Timer>) timerService.getTimers()) {
if (timer.getInfo() instanceof String) {
if (((String) timer.getInfo())
.equals(LocationSanityBusiness.TIME_OUT_INFO)) {
timer.cancel();
log.info("Cancel timer: " + timer.toString());
return;
}
}
}
}
示例11: getTimer
import javax.ejb.Timer; //導入方法依賴的package包/類
public Timer getTimer() {
TimerService timerService = ctx.getTimerService();
for (Timer timer : (Collection<Timer>) timerService.getTimers()) {
if (timer.getInfo() instanceof String) {
if (((String) timer.getInfo())
.equals(LocationSanityBusiness.TIME_OUT_INFO)) {
log.info(" " + timer.toString());
return timer;
}
}
}
return null;
}
示例12: handleTimer
import javax.ejb.Timer; //導入方法依賴的package包/類
@Timeout
public void handleTimer(final Timer timer) {
SchedulerTimerConfig config = (SchedulerTimerConfig) timer.getInfo();
log.info("run EE Timer " + config.getSchedulerName());
try {
Context.internalRequestScope().setManaged(false);
Context.start();
if (config.getPersistenceReference() != null) {
setApplicationEntityManager(config.getPersistenceReference());
}
Context.sessionScope().setUser("SchedulerTask-" + config.getSchedulerName());
EntityManager em = Context.internalRequestScope().getOrCreateEntityManager(false);
TypedQuery<Controllable> q = em.createNamedQuery(Controllable.SEL_SCHED_BY_DATE, Controllable.class);
q.setParameter("actuator", config.getSchedulerName());
q.setParameter("currentDate", new Date(), TemporalType.TIMESTAMP);
List<Controllable> list = q.getResultList();
log.info(list.size() + " due scheduled business cases found");
for (Controllable co : list) {
co.decrypt();
process(co);
}
} catch (Exception e) {
log.error("Failed to execute EEScheduledTask Timer " + config.getSchedulerName() + ": " + e.getMessage(), e);
} finally {
Context.end();
}
}
示例13: resetBatchJobs
import javax.ejb.Timer; //導入方法依賴的package包/類
public void resetBatchJobs() {
Collection<Timer> timers = batchJobService.getAllTimer();
logger.debug("found " + timers.size() + " running timers");
for (Timer timer : timers) {
BatchJobConfiguration batchJob = (BatchJobConfiguration)timer.getInfo();
logger.debug("Canceling " + batchJob.getType().getDisplayName() + " ("+batchJob.getId()+")");
batchJobService.cancelJob(batchJob);
}
}
示例14: timeout
import javax.ejb.Timer; //導入方法依賴的package包/類
@Timeout
public void timeout(Timer timer) {
try {
logger.debug("Executing Timer ");
BatchJobConfiguration jobConfig = (BatchJobConfiguration)timer.getInfo();
logger.debug("Executing Batch Job " + jobConfig.getType().getDisplayName());
BatchJobInterface batchJob = (BatchJobInterface)InitialContext.doLookup(jobConfig.getType().getModuleName());
batchJob.executeJob(timer); //Asynchronous method
} catch(NamingException ex) {
logger.error(ex,ex);
}
}
示例15: updateJob
import javax.ejb.Timer; //導入方法依賴的package包/類
public BatchJobConfiguration updateJob(BatchJobConfiguration batchJobConfiguration) {
Timer timer = getTimer(batchJobConfiguration);
if (timer != null) {
BatchJobConfiguration jobConfig = (BatchJobConfiguration)timer.getInfo();
logger.debug("Canceling Timer " + jobConfig.getType().getDisplayName());
timer.cancel();
}
BatchJobConfiguration result = batchJobConfigurationDAO.update(batchJobConfiguration);
result = fireUpTimer(result);
return result;
}