public KnowledgeSessionConfiguration newKnowledgeSessionConfiguration(Properties properties) { return new SessionConfiguration(properties); }
@SuppressWarnings("unchecked") public <T extends MultiValueKnowledgeSessionOption> T getOption(Class<T> option, String key) { if ( WorkItemHandlerOption.class.equals( option ) ) { return (T) WorkItemHandlerOption.get( key, getWorkItemHandlers().get( key ) ); } return null; }
public void setClockType(ClockType clockType) { checkCanChange(); // throws an exception if a change isn't possible; this.clockType = clockType; }
public static TimerService getTimerService( SessionConfiguration config ) { switch( config.getClockType() ) { case REALTIME_CLOCK: return config.newTimerService(); case PSEUDO_CLOCK: return new PseudoClockScheduler(); } return null; } }
public StatefulSession newStatefulSession(boolean keepReference) { SessionConfiguration config = new SessionConfiguration(); config.setKeepReference( keepReference ); return newStatefulSession( config, EnvironmentFactory.newEnvironment() ); }
public void setProperty(String name, String value) { name = name.trim(); if ( StringUtils.isEmpty( name ) ) { return; } if ( name.equals( KeepReferenceOption.PROPERTY_NAME ) ) { setKeepReference( StringUtils.isEmpty(value) || Boolean.parseBoolean(value) ); } else if ( name.equals( ClockTypeOption.PROPERTY_NAME ) ) { setClockType( ClockType.resolveClockType( StringUtils.isEmpty( value ) ? "realtime" : value ) ); } else if ( name.equals( TimerJobFactoryOption.PROPERTY_NAME ) ) { setTimerJobFactoryType(TimerJobFactoryType.resolveTimerJobFactoryType(StringUtils.isEmpty(value) ? "default" : value)); } else if ( name.equals( QueryListenerOption.PROPERTY_NAME ) ) { setQueryListenerClass( StringUtils.isEmpty( value ) ? QueryListenerOption.STANDARD.getAsString() : value ); } }
public <T extends KnowledgeSessionOption> void setOption(T option) { if ( option instanceof ClockTypeOption ) { setClockType( ClockType.resolveClockType( ((ClockTypeOption) option).getClockType() ) ); } else if ( option instanceof TimerJobFactoryOption ) { setTimerJobFactoryType(TimerJobFactoryType.resolveTimerJobFactoryType(((TimerJobFactoryOption) option).getTimerJobType())); } else if ( option instanceof KeepReferenceOption ) { setKeepReference(((KeepReferenceOption) option).isKeepReference()); } else if ( option instanceof WorkItemHandlerOption ) { getWorkItemHandlers().put( ((WorkItemHandlerOption) option).getName(), ((WorkItemHandlerOption) option).getHandler() ); } else if ( option instanceof QueryListenerOption ) { this.queryListener = (QueryListenerOption) option; } }
/** * Return a wm ready to go based on the rules in a drl at the specified uri (in the classpath). */ public StatefulSession getWorkingMemory(String uri) throws DroolsParserException, IOException, Exception { PackageBuilder builder = new PackageBuilder(); builder.addPackageFromDrl(new InputStreamReader(this.getClass() .getResourceAsStream(uri))); assertFalse(builder.getErrors().toString(), builder.hasErrors()); RuleBase rb = RuleBaseFactory.newRuleBase(); rb.addPackage(builder.getPackage()); SessionConfiguration conf = new SessionConfiguration(); conf.setClockType( ClockType.PSEUDO_CLOCK ); StatefulSession wm = rb.newStatefulSession( conf, null ); return wm; } }
public WorkItemManager getWorkItemManager() { if ( workItemManager == null ) { workItemManager = config.getWorkItemManagerFactory().createWorkItemManager( this.getKnowledgeRuntime() ); Map<String, Object> params = new HashMap<String, Object>(); params.put("ksession", this.getKnowledgeRuntime()); Map<String, WorkItemHandler> workItemHandlers = config.getWorkItemHandlers(params); if ( workItemHandlers != null ) { for ( Map.Entry<String, WorkItemHandler> entry : workItemHandlers.entrySet() ) { workItemManager.registerWorkItemHandler( entry.getKey(), entry.getValue() ); } } } return workItemManager; }
public ReteooStatelessSession(final InternalRuleBase ruleBase) { this.ruleBase = ruleBase; this.sessionConf = SessionConfiguration.getDefaultInstance(); // create one of these and re-use }
@SuppressWarnings("unchecked") public <T extends SingleValueKnowledgeSessionOption> T getOption(Class<T> option) { if ( ClockTypeOption.class.equals( option ) ) { return (T) ClockTypeOption.get( getClockType().toExternalForm() ); } else if ( KeepReferenceOption.class.equals( option ) ) { return (T) (this.keepReference ? KeepReferenceOption.YES : KeepReferenceOption.NO); } else if ( TimerJobFactoryOption.class.equals( option ) ) { return (T) TimerJobFactoryOption.get( getTimerJobFactoryType().toExternalForm() ); } else if ( QueryListenerOption.class.equals( option ) ) { return (T) this.queryListener; } return null; }
@Override public String getProperty(String name) { if (name.equals(KnowledgeSessionConfigurationRemoteClient.PROPERTY_MESSAGE_TIMEOUT)){ return this.messageTimeout; }else if (name.equals(KnowledgeSessionConfigurationRemoteClient.PROPERTY_MESSAGE_MINIMUM_WAIT_TIME)){ return this.messageMinWaitTime; } return super.getProperty(name); }
private InternalViewChangedEventListener getQueryListenerInstance() { switch ( this.config.getQueryListenerOption() ) { case STANDARD : return new StandardQueryViewChangedEventListener(); case LIGHTWEIGHT : return new NonCloningQueryViewListener(); } return null; }
public TruthMaintenanceSystem(final AbstractWorkingMemory wm) { this.wm = wm; this.justifiedMap = new ObjectHashMap(); this.assertMap = new ObjectHashMap(); this.assertMap.setComparator( EqualityKeyComparator.getInstance() ); beliefSystem = wm.getSessionConfiguration().getBeliefSystemType().createInstance( wm, this ); }
private void init(Properties properties, ClassLoader... classLoader) { this.classLoader = ClassLoaderUtil.getClassLoader( classLoader, getClass(), false ); this.immutable = false; this.chainedProperties = new ChainedProperties( "session.conf", this.classLoader ); if ( properties != null ) { this.chainedProperties.addProperties( properties ); } setKeepReference( Boolean.valueOf( this.chainedProperties.getProperty( KeepReferenceOption.PROPERTY_NAME, "true" ) ).booleanValue() ); setBeliefSystemType( BeliefSystemType.resolveBeliefSystemType( this.chainedProperties.getProperty( BeliefSystemTypeOption.PROPERTY_NAME, BeliefSystemType.SIMPLE.getId())) ); setClockType( ClockType.resolveClockType( this.chainedProperties.getProperty( ClockTypeOption.PROPERTY_NAME, ClockType.REALTIME_CLOCK.getId() ) ) ); setQueryListenerClass( this.chainedProperties.getProperty( QueryListenerOption.PROPERTY_NAME, QueryListenerOption.STANDARD.getAsString() ) ); setTimerJobFactoryType( TimerJobFactoryType.resolveTimerJobFactoryType( this.chainedProperties.getProperty( TimerJobFactoryOption.PROPERTY_NAME, TimerJobFactoryType.DEFUALT.getId() ) ) ); }
SessionConfiguration conf = new SessionConfiguration(); conf.setKeepReference( true ); initSession( conf );
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { ruleBase = (InternalRuleBase) in.readObject(); agendaFilter = (AgendaFilter) in.readObject(); globalResolver = (GlobalResolver) in.readObject(); globalExporter = (GlobalExporter) in.readObject(); this.sessionConf = SessionConfiguration.getDefaultInstance(); // create one of these and re-use }
public String execute(Context context) { SessionConfiguration kconf = (SessionConfiguration) context.getContextManager().getContext("__TEMP__").get(identifier); return kconf.getProperty(propertyName); } }
public KnowledgeSessionConfiguration newKnowledgeSessionConfiguration() { return new SessionConfiguration(); }
@Override protected void internalAfterPropertiesSet() { if ( getConf() != null && getWorkItems() != null && !getWorkItems().isEmpty() ) { Map<String, WorkItemHandler> map = ((SessionConfiguration) getConf()).getWorkItemHandlers(); map.putAll( getWorkItems() );