/** * This is a factory method for this belief system configuration. * The factory method is a best practice for the case where the * actual object construction is changed in the future. * * @param beliefSystemType the identifier for the belie system * * @return the actual type safe default clock type configuration. */ public static BeliefSystemTypeOption get( String beliefSystemType ) { return new BeliefSystemTypeOption( beliefSystemType ); }
/** * This is a factory method for this Clock Type configuration. * The factory method is a best practice for the case where the * actual object construction is changed in the future. * * @param clockType the identifier for the clock type * * @return the actual type safe default clock type configuration. */ public static ClockTypeOption get( String clockType ) { return new ClockTypeOption( clockType ); }
/** * This is a factory method for this WorkItemHandler configuration. * The factory method is a best practice for the case where the * actual object construction is changed in the future. * * @param name the name of the work item handler to be configured * * @return the actual type safe work item handler configuration. */ public static WorkItemHandlerOption get( final String name, final WorkItemHandler handler ) { return new WorkItemHandlerOption( name, handler ); }
protected KieFileSystem createKieFileSystemWithKProject(KieServices ks) { KieModuleModel kproj = ks.newKieModuleModel(); KieBaseModel kieBaseModel1 = kproj.newKieBaseModel("KBase-test") .setDefault(true).addPackage("*") .setEqualsBehavior(EqualityBehaviorOption.EQUALITY) .setEventProcessingMode(EventProcessingOption.STREAM); kieBaseModel1.newKieSessionModel("ksession-test").setDefault(true) .setType(KieSessionModel.KieSessionType.STATEFUL) .setClockType(ClockTypeOption.get("realtime")); KieFileSystem kfs = ks.newKieFileSystem(); kfs.writeKModuleXML(kproj.toXML()); return kfs; } }
private KieSession marsallStatefulKnowledgeSession(KieSession ksession) throws IOException, ClassNotFoundException { Globals globals = ksession.getGlobals(); KieBase kbase = ksession.getKieBase(); ByteArrayOutputStream out = new ByteArrayOutputStream(); MarshallerFactory.newMarshaller( kbase ).marshall( out, ksession ); KieSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); ksconf.setOption( TimerJobFactoryOption.get("trackable") ); ksconf.setOption( ClockTypeOption.get( "pseudo" ) ); Environment env = EnvironmentFactory.newEnvironment(); env.set( EnvironmentName.GLOBALS, globals ); ksession = MarshallerFactory.newMarshaller( kbase ).unmarshall( new ByteArrayInputStream( out.toByteArray() ), ksconf, env ); return ksession; }
config.setOption( TimerJobFactoryOption.get(TimerJobFactoryType.JPA.getId()) );
@Test public void testBeliefSystemType() { config.setOption( BeliefSystemTypeOption.get( BeliefSystemType.JTMS.toString() ) ); assertEquals( BeliefSystemTypeOption.get( BeliefSystemType.JTMS.toString() ), config.getOption( BeliefSystemTypeOption.class ) ); // checking the string based getProperty() method assertEquals( BeliefSystemType.JTMS.getId(), config.getProperty( BeliefSystemTypeOption.PROPERTY_NAME ) ); // setting the options using the string based setProperty() method config.setProperty( BeliefSystemTypeOption.PROPERTY_NAME, BeliefSystemType.DEFEASIBLE.getId() ); // checking the type safe getOption() method assertEquals( BeliefSystemTypeOption.get( BeliefSystemType.DEFEASIBLE.getId() ), config.getOption( BeliefSystemTypeOption.class ) ); // checking the string based getProperty() method assertEquals( BeliefSystemType.DEFEASIBLE.getId(), config.getProperty( BeliefSystemTypeOption.PROPERTY_NAME ) ); }
/** * This is a factory method for this timer job factory manager configuration. * The factory method is a best practice for the case where the * actual object construction is changed in the future. * * @param timerJobType the identifier for the belie system * * @return the actual type safe timer job factory manager configuration. */ public static TimerJobFactoryOption get( String timerJobType ) { return new TimerJobFactoryOption( timerJobType ); }
public static QueryListenerOption determineQueryListenerClassOption(String option) { if ( STANDARD.getAsString().equalsIgnoreCase( option ) ) { return STANDARD; } else if ( LIGHTWEIGHT.getAsString().equalsIgnoreCase( option ) ) { return LIGHTWEIGHT; } throw new IllegalArgumentException( "Illegal enum value '" + option + "' for QueryListenerOption" ); }
protected KieFileSystem createKieFileSystemWithKProject(KieServices ks) { KieModuleModel kproj = ks.newKieModuleModel(); KieBaseModel kieBaseModel1 = kproj.newKieBaseModel("defaultKieBase").setDefault(true).addPackage("*") .setEqualsBehavior( EqualityBehaviorOption.EQUALITY ) .setEventProcessingMode( EventProcessingOption.STREAM ); kieBaseModel1.newKieSessionModel("defaultKieSession").setDefault(true) .setType(KieSessionModel.KieSessionType.STATEFUL) .setClockType( ClockTypeOption.get("realtime") ) .newWorkItemHandlerModel("Log", "new org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler()"); KieFileSystem kfs = ks.newKieFileSystem(); kfs.writeKModuleXML(kproj.toXML()); return kfs; }
config.setOption( TimerJobFactoryOption.get(TimerJobFactoryType.JPA.getId()) );
protected KieFileSystem createKieFileSystemWithKProject(KieServices ks) { KieModuleModel kproj = ks.newKieModuleModel(); KieBaseModel kieBaseModel1 = kproj.newKieBaseModel("defaultKieBase") .setDefault(true) .addPackage("*") .setEqualsBehavior( EqualityBehaviorOption.EQUALITY ) .setEventProcessingMode( EventProcessingOption.STREAM ); kieBaseModel1.newKieSessionModel("defaultKieSession") .setDefault(true) .setType(KieSessionModel.KieSessionType.STATEFUL) .setClockType( ClockTypeOption.get("realtime") ); KieFileSystem kfs = ks.newKieFileSystem(); kfs.writeKModuleXML(kproj.toXML()); return kfs; } }
conf.setOption( ClockTypeOption.get( ClockType.PSEUDO_CLOCK.getId() ) );
private StatefulKnowledgeSessionImpl createWorkingMemory(InternalKnowledgeBase kBase) { // WorkingMemoryEntryPoint KieSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); ksconf.setOption( ClockTypeOption.get( "pseudo" ) ); SessionConfiguration sessionConf = ((SessionConfiguration) ksconf); StatefulKnowledgeSessionImpl wm = new StatefulKnowledgeSessionImpl(1L, kBase, true, sessionConf, EnvironmentFactory.newEnvironment()); return wm; }
@Test public void testClockTypeConfiguration() { // setting the option using the type safe method config.setOption( ClockTypeOption.get("pseudo") ); // checking the type safe getOption() method assertEquals( ClockTypeOption.get("pseudo"), config.getOption( ClockTypeOption.class ) ); // checking the string based getProperty() method assertEquals( "pseudo", config.getProperty( ClockTypeOption.PROPERTY_NAME ) ); // setting the options using the string based setProperty() method config.setProperty( ClockTypeOption.PROPERTY_NAME, "realtime" ); // checking the type safe getOption() method assertEquals( ClockTypeOption.get("realtime"), config.getOption( ClockTypeOption.class ) ); // checking the string based getProperty() method assertEquals( "realtime", config.getProperty( ClockTypeOption.PROPERTY_NAME ) ); }
private KieModuleModel createKieProjectWithPackages(KieServices ks, ReleaseId releaseId) { KieModuleModel kproj = ks.newKieModuleModel(); KieBaseModel kieBaseModel1 = kproj.newKieBaseModel("KBase1") .setEqualsBehavior( EqualityBehaviorOption.EQUALITY ) .setEventProcessingMode( EventProcessingOption.STREAM ) .addPackage("org.pkg1"); KieSessionModel ksession1 = kieBaseModel1.newKieSessionModel("KSession1") .setType( KieSessionType.STATEFUL ) .setClockType( ClockTypeOption.get("realtime") ); return kproj; }
private KieModuleModel createKieProjectWithPackages(KieServices ks, String pkg) { KieModuleModel kproj = ks.newKieModuleModel(); KieBaseModel kieBaseModel1 = kproj.newKieBaseModel() .setEqualsBehavior( EqualityBehaviorOption.EQUALITY ) .setEventProcessingMode( EventProcessingOption.STREAM ) .addPackage(pkg); KieSessionModel ksession1 = kieBaseModel1.newKieSessionModel("KSession1") .setType( KieSessionType.STATEFUL ) .setClockType(ClockTypeOption.get("realtime")) .setDefault( true ); return kproj; }
@Before public void setUp() throws Exception { baseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); // use stream mode to enable proper event processing (see Drools Fusion 5.5.0 Doc "Event Processing Modes") baseConfig.setOption( EventProcessingOption.STREAM ); kbase = KnowledgeBaseFactory.newKnowledgeBase(baseConfig); // config sessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); // use a pseudo clock, which starts at 0 and can be advanced manually sessionConfig.setOption( ClockTypeOption.get("pseudo") ); // create and return session session = kbase.newKieSession(sessionConfig, null); clock = session.getSessionClock(); }