forked from apache/incubator-kie-drools
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JBRULES-3146 rules with timers do not persist
(cherry picked from commit e8061e1)
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
drools-core/src/main/java/org/drools/time/impl/TrackableTimeJobFactoryManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |