public static DisconnectedFactHandle newFrom( FactHandle handle ) { if( handle instanceof DisconnectedFactHandle ) { return (DisconnectedFactHandle) handle; } else { InternalFactHandle ifh = (InternalFactHandle) handle; return new DisconnectedFactHandle(ifh.getId(), ifh.getIdentityHashCode(), ifh.getObjectHashCode(), ifh.getRecency(), ifh.getEntryPoint() != null ? ifh.getEntryPoint().getEntryPointId() : null, null, ifh.isValid(), ifh.isTraitOrTraitable() ); } }
public ConcurrentRightTuple(InternalFactHandle handle, RightTupleSink sink) { this.handle = handle; this.sink = sink; this.previous = new AtomicReference<Entry>(); this.next = new AtomicReference<Entry>(); handle.addFirstRightTuple( this ); }
public void reAdd() { handle.addLastLeftTuple( this ); }
public void modifyQuery(final InternalFactHandle factHandle, final PropagationContext context, final InternalWorkingMemory workingMemory) { if ( queryNode == null ) { this.queryNode = objectTypeNodes.get( ClassObjectType.DroolsQuery_ObjectType ); } if ( queryNode != null ) { ModifyPreviousTuples modifyPreviousTuples = new ModifyPreviousTuples(factHandle.getFirstLeftTuple(), factHandle.getFirstRightTuple() ); factHandle.clearLeftTuples(); factHandle.clearRightTuples(); // There may be no queries defined this.queryNode.modifyObject( factHandle, modifyPreviousTuples, context, workingMemory ); modifyPreviousTuples.retractTuples( context, workingMemory ); } }
public FactHandle execute(Context context) { StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession(); InternalFactHandle factHandle = (InternalFactHandle) ksession.getFactHandle( object ); if ( factHandle != null ){ InternalFactHandle handle = factHandle.clone(); if ( disconnected ) { handle.disconnect(); } return handle; } return null; }
if ( ! handle.isValid() ) { if ( handle.isDisconnected() ) { handle = this.objectStore.reconnect( handle ); if ( handle.isTraitable() ) { TraitableBean traitableBean = (TraitableBean) handle.getObject(); if( traitableBean.hasTraits() ){ PriorityQueue<TraitProxy> removedTypes = if ( handle.getEntryPoint() != this ) { throw new IllegalArgumentException( "Invalid Entry Point. You updated the FactHandle on entry point '" + handle.getEntryPoint().getEntryPointId() + "' instead of '" + getEntryPointId() + "'" ); final Object object = handle.getObject(); final EqualityKey key = handle.getEqualityKey(); handle.setEqualityKey( null ); if ( handle.isTraitOrTraitable() && handle.getObject() instanceof TraitProxy ) { ((TraitableBean) ( (TraitProxy) handle.getObject() ).getObject()).removeTrait( ( (TraitProxy) handle.getObject() ).getTypeCode() );
if ( handle.isDisconnected() ) { handle = this.objectStore.reconnect( factHandle ); final Object originalObject = handle.getObject(); if ( handle.getEntryPoint() != this ) { throw new IllegalArgumentException( "Invalid Entry Point. You updated the FactHandle on entry point '" + handle.getEntryPoint().getEntryPointId() + "' instead of '" + getEntryPointId() + "'" ); status = handle.getEqualityKey().getStatus(); if ( ! handle.isValid() || object == null || (handle.isEvent() && ((EventFactHandle) handle).isExpired()) ) { handle.setObject( object ); this.objectStore.addHandle( handle, object ); EqualityKey key = handle.getEqualityKey(); key.removeFactHandle( handle ); handle.setEqualityKey( key );
public void rowAdded(final Rule rule, final LeftTuple tuple, final PropagationContext context, final InternalWorkingMemory workingMemory) { InternalFactHandle[] handles = new InternalFactHandle[tuple.getIndex() + 1]; LeftTuple entry = tuple; // Add all the FactHandles while ( entry != null) { InternalFactHandle handle = entry.getLastHandle(); handles[entry.getIndex()] = new DefaultFactHandle( handle.getId(), ( handle.getEntryPoint() != null ) ? handle.getEntryPoint().getEntryPointId() : null, handle.getIdentityHashCode(), handle.getObjectHashCode(), handle.getRecency(), handle.getObject() ); entry = entry.getParent(); } QueryTerminalNode node = ( QueryTerminalNode ) tuple.getLeftTupleSink(); this.results.add( new QueryRowWithSubruleIndex(handles, node.getSubruleIndex()) ); }
((ShadowProxy) handle.getObject()).updateProxy(); if ( handle.isTraitOrTraitable() && handle.isTraitable() ) { TraitFieldTMS tms = ( (TraitableBean) handle.getObject() )._getFieldTMS(); if ( tms.needsInit() ) { tms.init( workingMemory ); ModifyPreviousTuples modifyPreviousTuples = new ModifyPreviousTuples(handle.getFirstLeftTuple(), handle.getFirstRightTuple() ); handle.clearLeftTuples(); handle.clearRightTuples();
InternalFactHandle handle) throws IOException { stream.writeInt( type ); stream.writeInt( handle.getId() ); stream.writeLong( handle.getRecency() ); Object object = handle.getObject(); if ( handle.getEntryPoint() instanceof InternalWorkingMemoryEntryPoint ) { String entryPoint = ((InternalWorkingMemoryEntryPoint) handle.getEntryPoint()).getEntryPoint().getEntryPointId(); if ( entryPoint != null && !entryPoint.equals( "" ) ) { stream.writeBoolean( true );
public void update( final FactHandle handle, long mask, Class<?> modifiedClass ) { InternalFactHandle h = (InternalFactHandle) handle; ((InternalWorkingMemoryEntryPoint) h.getEntryPoint()).update( h, ((InternalFactHandle)handle).getObject(), mask, modifiedClass, this.activation ); if ( h.isTraitOrTraitable() ) { if ( h.isTraitable() ) { if ( ((TraitableBean) h.getObject()).hasTraits() ) { updateTraits( h.getObject(), mask, null, modifiedClass, null, ((TraitableBean) h.getObject()).getMostSpecificTraits() ); } else if ( h.isTraiting() ) { Thing x = (Thing) h.getObject(); ((InternalWorkingMemoryEntryPoint) coreHandle.getEntryPoint()).update( coreHandle, core,
public void retract(final FactHandle handle) { Object o = ((InternalFactHandle) handle).getObject(); ((InternalWorkingMemoryEntryPoint) ((InternalFactHandle) handle).getEntryPoint()).retract( handle, true, true, this.activation.getRule(), this.activation ); if ( this.identityMap != null ) { this.getIdentityMap().remove( o ); } }
public void execute( final ObjectSinkPropagator sink, final InternalWorkingMemory workingMemory ) { super.execute( sink, workingMemory ); for ( RightTuple rightTuple = this.handle.getFirstRightTuple(); rightTuple != null; rightTuple = rightTuple.getHandleNext() ) { rightTuple.getRightTupleSink().retractRightTuple( rightTuple, context, workingMemory ); } this.handle.clearRightTuples(); for ( LeftTuple leftTuple = this.handle.getLastLeftTuple(); leftTuple != null; leftTuple = leftTuple.getLeftParentNext() ) { leftTuple.getLeftTupleSink().retractLeftTuple( leftTuple, context, workingMemory ); } this.handle.clearLeftTuples(); context.evaluateActionQueue( workingMemory ); } }
InternalFactHandle handle = readFactHandle( context ); context.handles.put( handle.getId(), handle ); handles[i] = handle; if (handle.getObject() != null) { objectStore.addHandle( handle, handle.getObject() ); Object object = factHandle.getObject(); EntryPoint ep = ( (InternalWorkingMemoryEntryPoint) factHandle.getEntryPoint() ).getEntryPoint(); ObjectTypeConf typeConf = ( (InternalWorkingMemoryEntryPoint) factHandle.getEntryPoint() ).getObjectTypeConfigurationRegistry().getObjectTypeConf( ep, object ); ObjectTypeNode[] cachedNodes = typeConf.getObjectTypeNodes();
ObjectTypeConf typeConf = context.wm.getObjectTypeConfigurationRegistry().getObjectTypeConf( ((NamedEntryPoint)handle.getEntryPoint()).getEntryPoint(), handle.getObject() ); if (!typeConf.isTMSEnabled() && (!wasOTCSerialized || tmsEnabled.contains(typeConf.getTypeName()) ) ) { typeConf.enableTMS(); handle.setEqualityKey( key ); for( Integer factHandleId : _key.getOtherHandleList() ) { handle = (InternalFactHandle) context.handles.get( factHandleId.intValue() ); key.addFactHandle( handle ); handle.setEqualityKey( key ); PersisterHelper.createActivationKey( _activation.getPackageName(), _activation.getRuleName(), _activation.getTuple() ) ).getObject(); PropagationContext pc = activation.getPropagationContext(); ObjectTypeConf typeConf = context.wm.getObjectTypeConfigurationRegistry().getObjectTypeConf( ((NamedEntryPoint)handle.getEntryPoint()).getEntryPoint(), handle.getObject() ); tms.readLogicalDependency( handle, null,
InternalFactHandle handle = context.handles.get( stream.readInt() ); activation.setFactHandle( handle ); handle.setObject( activation ); int factHandleId = stream.readInt(); InternalFactHandle handle = (InternalFactHandle) context.handles.get( factHandleId ); ObjectTypeConf typeConf = context.wm.getObjectTypeConfigurationRegistry().getObjectTypeConf( ((NamedEntryPoint)handle.getEntryPoint()).getEntryPoint(), handle.getObject() ); tms.addLogicalDependency( handle, null,
public void update(final FactHandle handle, final Object newObject){ InternalFactHandle h = (InternalFactHandle) handle; ((InternalWorkingMemoryEntryPoint) h.getEntryPoint()).update( h, newObject, Long.MIN_VALUE, newObject.getClass(), this.activation ); if ( getIdentityMap() != null ) { this.getIdentityMap().put( newObject, handle ); } }
public FactHandle execute(Context context) { StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context) .getStatefulKnowledgesession(); Collection<FactHandle> factHandles = ksession.getFactHandles(); int fhId = Integer.parseInt(factHandleExternalForm.split(":")[1]); for (FactHandle factHandle : factHandles) { if (factHandle instanceof InternalFactHandle && ((InternalFactHandle) factHandle).getId() == fhId) { InternalFactHandle fhClone = ((InternalFactHandle) factHandle).clone(); if (disconnected) { fhClone.disconnect(); } return fhClone; } } return null; }
public BaseLeftTuple(final InternalFactHandle factHandle, final LeftTupleSink sink, final boolean leftTupleMemoryEnabled) { this.handle = factHandle; this.sink = sink; if ( leftTupleMemoryEnabled ) { this.handle.addLeftTupleInPosition( this ); } }
public RightTuple(InternalFactHandle handle, RightTupleSink sink) { this.handle = handle; this.sink = sink; // add to end of RightTuples on handle handle.addRightTupleInPosition( this ); }