@ SuppressWarnings ( "unchecked" ) public static < T > Collection < T > exeWithResults ( Execution < ? , ? , ? > execution , Function < ? > function ) throws Exception { ResultCollector < ? , ? > resultCollector ; try { resultCollector = execution . execute ( function ) ; } catch ( FunctionException e ) { if ( e . getCause ( ) instanceof NullPointerException ) throw new RuntimeException ( "Unable to execute function:" + function . getId ( ) + " assert hostnames(s) for locators and cache server can be resovled. " + " If you do not have access to the host file, create host.properties and add to the CLASSPATH. " + " Example: locahost=127.1.0.0 " + " also assert that all cache servers have been initialized. Check if the server's cache.xml has all required <initializer>..</initializer> configurations" , e ) ; else throw e ; } Object resultsObject = resultCollector . getResult ( ) ; //Return a result in collection (for a single response) Collection < Object > collectionResults = ( Collection < Object > ) resultsObject ; //if empty return null if ( collectionResults . isEmpty ( ) ) return null ; Collection < Object > list = new ArrayList < Object > ( collectionResults . size ( ) ) ; flatten ( collectionResults , list ) ; if ( list . isEmpty ( ) ) return null ; return ( Collection < T > ) list ; }
Execute a function with the given execution settings