[jboss-jira] [JBoss JIRA] Commented: (JBRULES-1165) StatelessSessionResult should have getGlobal

Mark Proctor (JIRA) jira-events at lists.jboss.org
Sun Sep 9 01:08:11 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBRULES-1165?page=comments#action_12376020 ] 
            
Mark Proctor commented on JBRULES-1165:
---------------------------------------

public class ReteStatelessSessionResult implements StatelessSessionResult {
    private transient InternalWorkingMemory workingMemory;
    private ObjectHashMap assertMap;
    private GlobalResolver globalResolver;
    
    public ReteStatelessSessionResult(InternalWorkingMemory workingMemory, GlobalResolver globalResolver) {
        this.workingMemory = workingMemory;
        this.assertMap = workingMemory.getAssertMap();
        this.globalResolver = globalResolver;
    }

    public QueryResults getQueryResults(String query) {
        return this.workingMemory.getQueryResults( query );
    }
    
    public QueryResults getQueryResults(final String query, final Object[] arguments) {
        return this.workingMemory.getQueryResults( query, 
                                                   arguments );
    }

    public Iterator iterateObjects() {
        HashTableIterator iterator = new HashTableIterator( this.assertMap );
        iterator.reset();
        return new JavaIteratorAdapter( iterator,
                                        JavaIteratorAdapter.OBJECT );
    }

    public Iterator iterateObjects(ObjectFilter filter) {
        HashTableIterator iterator = new HashTableIterator( this.assertMap );
        iterator.reset();
        return new JavaIteratorAdapter( iterator,
                                        JavaIteratorAdapter.OBJECT,
                                        filter );
    }
    
    public Object getGlobal(String identifier) {
        return this.globalResolver.resolveGlobal( identifier );
    }
}    
    
public interface GlobalExporter {
    public GlobalResolver export(WorkingMemory workingMemory);
}

public class CopyIdentifiersGlobalExporter implements GlobalExporter {
    private String[] identifiers;
    
    /**
     * All identifiers will be copied
     *
     */
    public CopyIdentifiersGlobalExporter() {
        this.identifiers = null;
    }
    
    /**
     * Specified identifiers will be copied
     * @param identifiers
     */
    public CopyIdentifiersGlobalExporter(String[] identifiers) {
        this.identifiers = identifiers;
    }
    
    public GlobalResolver export(WorkingMemory workingMemory) {
        if ( this.identifiers == null ) {
            // no identifiers, to get all the identifiers from that defined in
            // the rulebase
            Map map = ((InternalRuleBase)workingMemory.getRuleBase()).getGlobals();
            this.identifiers = new String[ map.size() ];
            this.identifiers = (String[]) map.keySet().toArray( this.identifiers );
        }
        
        Map map = new HashMap(identifiers.length);
        for ( int i = 0, length = identifiers.length; i < length; i++ ) {
            map.put( identifiers[i], workingMemory.getGlobal( identifiers[i] ) );
        }
        return new MapGlobalResolver(map);
    }
}


public class ReferenceOriginalGlobalExporter implements GlobalExporter {       
    public GlobalResolver export(WorkingMemory workingMemory) {
        return workingMemory.getGlobalResolver();
    }
}  

> StatelessSessionResult should have getGlobal
> --------------------------------------------
>
>                 Key: JBRULES-1165
>                 URL: http://jira.jboss.com/jira/browse/JBRULES-1165
>             Project: JBoss Rules
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>          Components: Reteoo
>    Affects Versions: 4.0.1
>            Reporter: Michael Neale
>         Assigned To: Mark Proctor
>             Fix For: 4.0.2
>
>
> Most likely an oversight. However, to keep the stateless nature of the API - there isn't another way to do this other then add more methods to the interface, unfortunately. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list