public static ClockType resolveClockType( String id ) { if( PSEUDO_CLOCK.getId().equalsIgnoreCase( id ) ) { return PSEUDO_CLOCK; } else if( REALTIME_CLOCK.getId().equalsIgnoreCase( id ) ) { return REALTIME_CLOCK; } throw new IllegalArgumentException( "Illegal enum value '" + id + "' for ClockType" ); }
public String getProperty(String name) { name = name.trim(); if ( StringUtils.isEmpty( name ) ) { return null; } if ( name.equals( KeepReferenceOption.PROPERTY_NAME ) ) { return Boolean.toString( this.keepReference ); } else if ( name.equals( ClockTypeOption.PROPERTY_NAME ) ) { return this.clockType.toExternalForm(); } else if ( name.equals( TimerJobFactoryOption.PROPERTY_NAME ) ) { return this.timerJobFactoryType.toExternalForm(); } else if ( name.equals( QueryListenerOption.PROPERTY_NAME ) ) { return this.queryListener.getAsString(); } return null; }
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() ) ) ); }
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 ); } }
if (e != null && StringUtils.hasText(e.getAttribute("type"))) { rbaseConfBuilder.addPropertyValue("clockType", ClockType.resolveClockType(e.getAttribute("type")));
if (e != null && StringUtils.hasText(e.getAttribute("type"))) { rbaseConfBuilder.addPropertyValue("clockType", ClockType.resolveClockType(e.getAttribute("type")));
/** * Creates a new KnowledgeSessionConfiguration given the specified component implementation config. * @param cic the component implementation config * @return the config */ public static KnowledgeSessionConfiguration getSessionConfiguration(ComponentImplementationConfig cic) { KnowledgeSessionConfiguration ksessionConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(getProperties(cic)); ClockType clock = cic.getModel().getClock(); if (clock != null) { switch (clock) { case REALTIME: ksessionConfig.setOption(ClockTypeOption.get(org.drools.ClockType.REALTIME_CLOCK.getId())); break; case PSEUDO: ksessionConfig.setOption(ClockTypeOption.get(org.drools.ClockType.PSEUDO_CLOCK.getId())); break; } } return ksessionConfig; }
@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; }
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; } }