use of org.drools.core.time.impl.TimerJobInstance in project jbpm by kiegroup.
the class TransactionalThreadPoolSchedulerService method internalSchedule.
@Override
public void internalSchedule(TimerJobInstance timerJobInstance) {
TimerJobInstance proxy = (TimerJobInstance) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { Callable.class, Comparable.class, TimerJobInstance.class, Serializable.class }, new TransactionalTimerJobInstance(timerJobInstance));
super.internalSchedule(proxy);
}
use of org.drools.core.time.impl.TimerJobInstance in project jbpm by kiegroup.
the class GlobalJPATimerJobFactoryManager method addTimerJobInstance.
public void addTimerJobInstance(TimerJobInstance instance) {
JobContext ctx = instance.getJobContext();
if (ctx instanceof SelfRemovalJobContext) {
ctx = ((SelfRemovalJobContext) ctx).getJobContext();
}
Map<Long, TimerJobInstance> instances = null;
if (ctx instanceof ProcessJobContext) {
long sessionId = ((ProcessJobContext) ctx).getSessionId();
instances = timerInstances.get(sessionId);
if (instances == null) {
instances = new ConcurrentHashMap<Long, TimerJobInstance>();
timerInstances.put(sessionId, instances);
}
} else {
instances = singleTimerInstances;
}
instances.put(instance.getJobHandle().getId(), instance);
}
use of org.drools.core.time.impl.TimerJobInstance in project jbpm by kiegroup.
the class GlobalJPATimerJobFactoryManager method removeTimerJobInstance.
public void removeTimerJobInstance(TimerJobInstance instance) {
Long sessionId = null;
JobContext ctx = instance.getJobContext();
if (ctx instanceof SelfRemovalJobContext) {
ctx = ((SelfRemovalJobContext) ctx).getJobContext();
}
Map<Long, TimerJobInstance> instances = null;
if (ctx instanceof ProcessJobContext) {
sessionId = ((ProcessJobContext) ctx).getSessionId();
instances = timerInstances.get(sessionId);
if (instances == null) {
instances = new ConcurrentHashMap<Long, TimerJobInstance>();
timerInstances.put(sessionId, instances);
}
} else {
instances = singleTimerInstances;
}
instances.remove(instance.getJobHandle().getId());
if (sessionId != null && instances.isEmpty()) {
timerInstances.remove(sessionId);
}
}
use of org.drools.core.time.impl.TimerJobInstance in project jbpm by kiegroup.
the class EJBTimerScheduler method getTimerByName.
public TimerJobInstance getTimerByName(String jobName) {
if (localCache.containsKey(jobName)) {
logger.debug("Found job {} in cache returning", jobName);
return localCache.get(jobName);
}
TimerJobInstance found = null;
for (Timer timer : timerService.getTimers()) {
try {
Serializable info = timer.getInfo();
if (info instanceof EjbTimerJob) {
EjbTimerJob job = (EjbTimerJob) info;
EjbGlobalJobHandle handle = (EjbGlobalJobHandle) job.getTimerJobInstance().getJobHandle();
localCache.putIfAbsent(jobName, handle.getTimerJobInstance());
if (handle.getUuid().equals(jobName)) {
logger.debug("Job {} does match timer and is going to be returned", jobName);
found = handle.getTimerJobInstance();
}
}
} catch (NoSuchObjectLocalException e) {
logger.debug("Timer info for {} was not found ", timer);
}
}
return found;
}
use of org.drools.core.time.impl.TimerJobInstance in project jbpm by kiegroup.
the class EjbSchedulerService method scheduleJob.
@Override
public JobHandle scheduleJob(Job job, JobContext ctx, Trigger trigger) {
Long id = idCounter.getAndIncrement();
String jobName = getJobName(ctx, id);
EjbGlobalJobHandle jobHandle = new EjbGlobalJobHandle(id, jobName, ((GlobalTimerService) globalTimerService).getTimerServiceId());
TimerJobInstance jobInstance = null;
// if so skip the check by timer name as it has no way to exist
if (!isNewTimer(ctx)) {
jobInstance = scheduler.getTimerByName(jobName);
if (jobInstance != null) {
return jobInstance.getJobHandle();
}
}
jobInstance = globalTimerService.getTimerJobFactoryManager().createTimerJobInstance(job, ctx, trigger, jobHandle, (InternalSchedulerService) globalTimerService);
jobHandle.setTimerJobInstance((TimerJobInstance) jobInstance);
interceptor.internalSchedule(jobInstance);
return jobHandle;
}
Aggregations