private static void writeObjectTypeConfiguration( MarshallerWriteContext context, ObjectTypeConfigurationRegistry otcr, org.drools.marshalling.impl.ProtobufMessages.EntryPoint.Builder _epb ) { Collection<ObjectTypeConf> values = otcr.values(); ObjectTypeConf[] otcs = values.toArray( new ObjectTypeConf[ values.size() ] ); Arrays.sort( otcs, new Comparator<ObjectTypeConf>() { public int compare(ObjectTypeConf o1, ObjectTypeConf o2) { return o1.getTypeName().compareTo(o2.getTypeName()); } }); for( ObjectTypeConf otc : otcs ) { final ObjectTypeNodeMemory memory = (ObjectTypeNodeMemory) context.wm.getNodeMemory(otc.getConcreteObjectTypeNode()); if (memory != null && !memory.memory.isEmpty()) { ObjectTypeConfiguration _otc = ObjectTypeConfiguration.newBuilder() .setType(otc.getTypeName()) .setTmsEnabled(otc.isTMSEnabled()) .build(); _epb.addOtc(_otc); } } }
public void dispose() { if( dynamicFacts != null ) { // first we check for facts that were inserted into the working memory // using the old API and setting a per instance dynamic flag and remove the // session from the listeners list in the bean for( InternalFactHandle handle : dynamicFacts ) { removePropertyChangeListener( handle, false ); } dynamicFacts = null; } for( ObjectTypeConf conf : this.typeConfReg.values() ) { // then, we check if any of the object types were configured using the // @propertyChangeSupport annotation, and clean them up if( conf.isDynamic() && conf.isSupportsPropertyChangeListeners() ) { // it is enough to iterate the facts on the concrete object type nodes // only, as the facts will always be in their concrete object type nodes // even if they were also asserted into higher level OTNs as well ObjectTypeNode otn = conf.getConcreteObjectTypeNode(); final ObjectHashSet memory = ((ObjectTypeNodeMemory) this.getInternalWorkingMemory().getNodeMemory( otn )).memory; Iterator it = memory.iterator(); for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) { InternalFactHandle handle = (InternalFactHandle) entry.getValue(); removePropertyChangeListener( handle, false ); } } } } }
public void updateSink(final ObjectSink sink, final PropagationContext context, final InternalWorkingMemory workingMemory) { // @todo // JBRULES-612: the cache MUST be invalidated when a new node type is added to the network, so iterate and reset all caches. final ObjectTypeNode node = (ObjectTypeNode) sink; final ObjectType newObjectType = node.getObjectType(); InternalWorkingMemoryEntryPoint wmEntryPoint = (InternalWorkingMemoryEntryPoint) workingMemory.getWorkingMemoryEntryPoint( this.entryPoint.getEntryPointId() ); for ( ObjectTypeConf objectTypeConf : wmEntryPoint.getObjectTypeConfigurationRegistry().values() ) { if ( newObjectType.isAssignableFrom( objectTypeConf.getConcreteObjectTypeNode().getObjectType() ) ) { objectTypeConf.resetCache(); ObjectTypeNode sourceNode = objectTypeConf.getConcreteObjectTypeNode(); Iterator it = ((ObjectTypeNodeMemory) workingMemory.getNodeMemory( sourceNode )).memory.iterator(); for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) { sink.assertObject( (InternalFactHandle) entry.getValue(), context, workingMemory ); } } } }