Skip to content

Commit

Permalink
[DROOLS-795] fix timers serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mariofusco committed Jul 8, 2015
1 parent 1a3d2e0 commit e32fb81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
Expand Up @@ -16,13 +16,15 @@
package org.drools.persistence.infinispan;

import org.drools.core.command.CommandService;
import org.drools.core.time.AcceptsTimerJobFactoryManager;
import org.drools.core.time.InternalSchedulerService;
import org.drools.core.time.Job;
import org.drools.core.time.JobContext;
import org.drools.core.time.JobHandle;
import org.drools.core.time.TimerService;
import org.drools.core.time.Trigger;
import org.drools.core.time.impl.CommandServiceTimerJobFactoryManager;
import org.drools.core.time.impl.DefaultTimerJobInstance;
import org.drools.core.time.impl.TimerJobFactoryManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -45,7 +47,8 @@ public InfinispanTimerJobInstance(Job job,
public Void call() throws Exception {
try {
JDKCallableJobCommand command = new JDKCallableJobCommand( this );
CommandService commandService = ((AcceptsTimerJobFactoryManager)scheduler).getTimerJobFactoryManager().getCommandService();
TimerJobFactoryManager timerJobFactoryManager = ( (TimerService)scheduler ).getTimerJobFactoryManager();
CommandService commandService = ( (CommandServiceTimerJobFactoryManager) timerJobFactoryManager ).getCommandService();
commandService.execute( command );
return null;
} catch( Exception e ) {
Expand Down
Expand Up @@ -15,10 +15,6 @@
*/
package org.drools.persistence.infinispan;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

import org.drools.core.SessionConfiguration;
import org.drools.core.command.CommandService;
import org.drools.core.command.Interceptor;
Expand All @@ -37,6 +33,10 @@
import org.kie.internal.KnowledgeBaseFactory;
import org.kie.internal.runtime.StatefulKnowledgeSession;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

public class KnowledgeStoreServiceImpl
implements
KieStoreServices {
Expand Down Expand Up @@ -242,17 +242,6 @@ private CommandExecutor buildCommandService(KieBase kbase,

private KieSessionConfiguration mergeConfig(KieSessionConfiguration configuration) {
((SessionConfiguration) configuration).addDefaultProperties(configProps);
try {

java.lang.reflect.Field field = SessionConfiguration.class.getDeclaredField("timerJobFactoryManager");
field.setAccessible(true);
Object obj = field.get(configuration);
if (obj == null) {
field.set(configuration, new InfinispanTimeJobFactoryManager());
}
} catch (Exception e) {
throw new IllegalStateException("Couldn't set TimeJobFactoryManager", e);
}
return configuration;
}

Expand Down

0 comments on commit e32fb81

Please sign in to comment.