Skip to content

Commit

Permalink
JBRULES-3146 rules with timers do not persist
Browse files Browse the repository at this point in the history
(cherry picked from commit e8061e1)
  • Loading branch information
mdproctor committed Sep 16, 2011
1 parent d2574f5 commit d9ff06c
Showing 1 changed file with 68 additions and 0 deletions.
@@ -0,0 +1,68 @@
package org.drools.time.impl;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;

import org.drools.command.CommandService;
import org.drools.time.InternalSchedulerService;
import org.drools.time.Job;
import org.drools.time.JobContext;
import org.drools.time.JobHandle;
import org.drools.time.SelfRemovalJob;
import org.drools.time.SelfRemovalJobContext;
import org.drools.time.Trigger;
import org.drools.time.impl.TimerJobFactoryManager;
import org.drools.time.impl.TimerJobInstance;

public class TrackableTimeJobFactoryManager
implements
TimerJobFactoryManager {

private Map<Long, TimerJobInstance> timerInstances;

public TrackableTimeJobFactoryManager() {
timerInstances = new ConcurrentHashMap<Long, TimerJobInstance>();
}

public TimerJobInstance createTimerJobInstance(Job job,
JobContext ctx,
Trigger trigger,
JobHandle handle,
InternalSchedulerService scheduler) {
ctx.setJobHandle( handle );
DefaultTimerJobInstance jobInstance = new DefaultTimerJobInstance( new SelfRemovalJob( job ),
new SelfRemovalJobContext( ctx,
timerInstances ),
trigger,
handle,
scheduler );

return jobInstance;
}

public void addTimerJobInstance(TimerJobInstance instance) {

this.timerInstances.put( instance.getJobHandle().getId(),
instance );
}

public void removeTimerJobInstance(TimerJobInstance instance) {

this.timerInstances.remove( instance.getJobHandle().getId() );
}

public Collection<TimerJobInstance> getTimerJobInstances() {
return timerInstances.values();
}

public void setCommandService(CommandService commandService) {

}

public CommandService getCommandService() {
return null;
}

}

0 comments on commit d9ff06c

Please sign in to comment.