public static List<String> getSettableProperties(InternalWorkingMemory workingMemory, ObjectTypeNode objectTypeNode) { return getSettableProperties((InternalRuleBase)workingMemory.getRuleBase(), objectTypeNode); }
public AgendaGroup getAgendaGroup(final String name) { return getAgendaGroup(name, workingMemory == null ? null : ((InternalRuleBase)workingMemory.getRuleBase())); }
private List<String> getSettableProperties(InternalWorkingMemory workingMemory, Class<?> classType, String pkgName) { if ( pkgName.equals( "java.lang" ) || pkgName.equals( "java.util" ) ) { return Collections.EMPTY_LIST; } Package pkg = workingMemory.getRuleBase().getPackage( pkgName ); TypeDeclaration tdecl = pkg != null ? pkg.getTypeDeclaration( classType ) : null; return tdecl != null ? tdecl.getSettableProperties() : Collections.EMPTY_LIST; }
public Object resolve( InternalWorkingMemory workingMemory ) { try { type = ((ReteooRuleBase) workingMemory.getRuleBase()).getRootClassLoader().loadClass( className, true ); } catch (Exception e) { } return type; }
public static ActivationIterator iterator(InternalWorkingMemory wm) { return new ActivationIterator( wm, new KnowledgeBaseImpl( wm.getRuleBase() ) ); }
protected MVELDialectRuntimeData getMVELDialectRuntimeData(InternalWorkingMemory workingMemory) { return ((MVELDialectRuntimeData)workingMemory.getRuleBase().getPackage(packageName).getDialectRuntimeRegistry().getDialectData( "mvel" )); }
private void executeJitting(Object object, InternalWorkingMemory workingMemory, LeftTuple leftTuple) { InternalRuleBase ruleBase = ((InternalRuleBase) workingMemory.getRuleBase()); if ( MemoryUtil.permGenStats.isUsageThresholdExceeded(ruleBase.getConfiguration().getPermGenThreshold()) ) { return; } try { CompositeClassLoader classLoader = ruleBase.getRootClassLoader(); if (analyzedCondition == null) { analyzedCondition = ((MvelConditionEvaluator) conditionEvaluator).getAnalyzedCondition(object, workingMemory, leftTuple); } conditionEvaluator = ASMConditionEvaluatorJitter.jitEvaluator(expression, analyzedCondition, declarations, classLoader, leftTuple); } catch (Throwable t) { if (TEST_JITTING) { if (analyzedCondition == null) { logger.error("Unable to analize condition for expression: " + expression, t); } else { throw new RuntimeException("Exception jitting: " + expression, t); } } else { logger.warn("Exception jitting: " + expression, t.getMessage()); } } }
public void execute(InternalWorkingMemory workingMemory) { final PropagationContext context = new PropagationContextImpl( workingMemory.getNextPropagationIdCounter(), PropagationContext.ASSERTION, this.ruleOrigin, this.leftTuple, this.factHandle ); ReteooRuleBase ruleBase = (ReteooRuleBase) workingMemory.getRuleBase(); ruleBase.assertObject( this.factHandle, this.factHandle.getObject(), context, workingMemory ); context.evaluateActionQueue( workingMemory ); }
private void cacheLiteral( Object value, InternalWorkingMemory workingMemory ) { CodedHierarchy x = ((ReteooRuleBase) workingMemory.getRuleBase()).getConfiguration().getComponentFactory().getTraitRegistry().getHierarchy(); cachedLiteral = getCode( value, x ); }
if ( objectTypeConf == null ) { objectTypeConf = new ClassObjectTypeConf( workingMemory.getEntryPoint(), resultClass, (InternalRuleBase) workingMemory.getRuleBase() );
@SuppressWarnings("unchecked") public Collection<Object> instantiateResultObject(InternalWorkingMemory wm) throws RuntimeDroolsException { try { // Collect can only be used with a Collection implementation, so // FactTemplateObject type is not allowed if ( this.cls == null ) { ClassObjectType objType = ((ClassObjectType) this.resultPattern.getObjectType()); String className = determineResultClassName( objType ); this.cls = (Class<Collection<Object>>) Class.forName( className, true, ((InternalRuleBase) wm.getRuleBase()).getRootClassLoader() ); } return this.cls.newInstance(); } catch ( final ClassCastException cce ) { throw new RuntimeDroolsException( "Collect CE requires a Collection implementation as return type", cce ); } catch ( final InstantiationException e ) { throw new RuntimeDroolsException( "Collect CE requires a non-argument constructor for the return type", e ); } catch ( final IllegalAccessException e ) { throw new RuntimeDroolsException( "Collect CE requires an accessible constructor for the return type", e ); } catch ( final ClassNotFoundException e ) { throw new RuntimeDroolsException( "Collect CE could not resolve return result class '" + ((ClassObjectType) this.resultPattern.getObjectType()).getClassName() + "'", e ); } }
public void read(MarshallerReaderContext inCtx) throws IOException, ClassNotFoundException { InternalFactHandle factHandle = inCtx.handles.get( inCtx.readInt() ); String entryPointId = inCtx.readUTF(); EntryPointNode epn = ((ReteooRuleBase) inCtx.wm.getRuleBase()).getRete().getEntryPointNode( new EntryPoint( entryPointId ) ); String className = inCtx.readUTF(); Class< ? > cls = ((ReteooRuleBase) inCtx.wm.getRuleBase()).getRootClassLoader().loadClass( className ); ObjectTypeNode otn = epn.getObjectTypeNodes().get( new ClassObjectType( cls ) ); long nextTimeStamp = inCtx.readLong(); TimerService clock = inCtx.wm.getTimerService(); JobContext jobctx = new ExpireJobContext( new WorkingMemoryReteExpireAction( factHandle, otn ), inCtx.wm ); JobHandle handle = clock.scheduleJob( job, jobctx, new PointInTimeTrigger( nextTimeStamp, null, null ) ); jobctx.setJobHandle( handle ); }
public void deserialize(MarshallerReaderContext inCtx, Timer _timer) throws ClassNotFoundException { ExpireTimer _expire = _timer.getExpire(); InternalFactHandle factHandle = inCtx.handles.get( _expire.getHandleId() ); EntryPointNode epn = ((ReteooRuleBase)inCtx.wm.getRuleBase()).getRete().getEntryPointNode( new EntryPoint( _expire.getEntryPointId() ) ); Class<?> cls = ((ReteooRuleBase)inCtx.wm.getRuleBase()).getRootClassLoader().loadClass( _expire.getClassName() ); ObjectTypeNode otn = epn.getObjectTypeNodes().get( new ClassObjectType( cls ) ); TimerService clock = inCtx.wm.getTimerService(); JobContext jobctx = new ExpireJobContext( new WorkingMemoryReteExpireAction(factHandle, otn), inCtx.wm ); JobHandle handle = clock.scheduleJob( job, jobctx, new PointInTimeTrigger( _expire.getNextFireTimestamp(), null, null ) ); jobctx.setJobHandle( handle ); } }
public void setWorkingMemory(final InternalWorkingMemory workingMemory) { this.workingMemory = workingMemory; RuleBaseConfiguration rbc = ((InternalRuleBase) this.workingMemory.getRuleBase()).getConfiguration(); if ( rbc.isSequential() ) { this.knowledgeHelper = rbc.getComponentFactory().getKnowledgeHelperFactory().newSequentialKnowledgeHelper( this.workingMemory ); } else { this.knowledgeHelper = rbc.getComponentFactory().getKnowledgeHelperFactory().newStatefulKnowledgeHelper( this.workingMemory ); } }
public KnowledgeSessionMonitoring(InternalWorkingMemory ksession) { this.ksession = ksession; this.kbase = (InternalRuleBase) ksession.getRuleBase(); this.name = DroolsManagementAgent.createObjectName(KSESSION_PREFIX + ":type="+kbase.getId()+",group=Sessions,sessionId=Session-"+ksession.getId()); this.agendaStats = new AgendaStats(); this.processStats = new ProcessStats(); this.ksession.addEventListener( agendaStats ); if (ksession.getProcessRuntime() != null) { this.ksession.getProcessRuntime().addEventListener( processStats ); } }
public boolean evaluate(ExecutableStatement statement, Object object, InternalWorkingMemory workingMemory, LeftTuple leftTuple) { if (compilationUnit == null) { Map<String, Object> vars = valuesAsMap(object, workingMemory, leftTuple, declarations); return evaluate(statement, object, vars); } VariableResolverFactory factory = compilationUnit.createFactory(); compilationUnit.updateFactory( null, null, object, leftTuple, null, workingMemory, workingMemory.getGlobalResolver(), factory ); org.drools.rule.Package pkg = workingMemory.getRuleBase().getPackage( "MAIN" ); if ( pkg != null ) { MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData("mvel"); factory.setNextFactory( data.getFunctionFactory() ); } return (Boolean) MVEL.executeExpression( statement, object, factory ); }
sourceTraits = ((TraitableBean) ((Thing) source).getCore()).getCurrentTypeCode(); if ( sourceTraits == null && source instanceof TraitType ) { CodedHierarchy x = ((ReteooRuleBase) workingMemory.getRuleBase()).getConfiguration().getComponentFactory().getTraitRegistry().getHierarchy(); sourceTraits = x.getCode( ((TraitType)source).getTraitName() ); sourceTraits = ((TraitableBean) source).getCurrentTypeCode(); } else if ( source instanceof String ) { CodedHierarchy x = ((ReteooRuleBase) workingMemory.getRuleBase()).getConfiguration().getComponentFactory().getTraitRegistry().getHierarchy(); sourceTraits = x.getCode( source ); } else { CodedHierarchy x = ((ReteooRuleBase) workingMemory.getRuleBase()).getConfiguration().getComponentFactory().getTraitRegistry().getHierarchy(); targetTraits = x.getCode( ((Class) target).getName() ); } else if ( target instanceof String ) { CodedHierarchy x = ((ReteooRuleBase) workingMemory.getRuleBase()).getConfiguration().getComponentFactory().getTraitRegistry().getHierarchy(); targetTraits = x.getCode( target ); } else if ( target instanceof Thing ) { targetTraits = ((TraitableBean) ((Thing) target).getCore()).getCurrentTypeCode(); if ( targetTraits == null && target instanceof TraitType ) { CodedHierarchy x = ((ReteooRuleBase) workingMemory.getRuleBase()).getConfiguration().getComponentFactory().getTraitRegistry().getHierarchy(); targetTraits = x.getCode( ((TraitType)target).getTraitName() );