private HashMap<Name, FunctionFactory> lookupFunctions() { // get all filter functions via function factory HashMap<Name, FunctionFactory> result = new HashMap<Name, FunctionFactory>(); Set<FunctionFactory> functionFactories = CommonFactoryFinder.getFunctionFactories(null); for (FunctionFactory ff : functionFactories) { for (FunctionName functionName : ff.getFunctionNames()) { result.put(functionName.getFunctionName(), ff); } } return result; } }
/** * Return a List of FunctionName's describing the functions currently available. * * @return List describing available functions */ public List<FunctionName> getAllFunctionDescriptions() { Set<FunctionFactory> functionFactories = CommonFactoryFinder.getFunctionFactories(null); List<FunctionName> allFunctionDescriptions = new ArrayList<FunctionName>(); for (FunctionFactory factory : functionFactories) { List<FunctionName> functionNames = factory.getFunctionNames(); allFunctionDescriptions.addAll(functionNames); } Collections.sort( allFunctionDescriptions, new Comparator<FunctionName>() { public int compare(FunctionName o1, FunctionName o2) { if (o1 == null && o2 == null) return 0; if (o1 == null && o2 != null) return 1; if (o1 != null && o2 == null) return -1; return o1.getName().compareTo(o2.getName()); } }); return Collections.unmodifiableList(allFunctionDescriptions); } /**
Function findFunctionInternal(Name name, List parameters, Literal fallback) { if (functionFactoryCache == null) { synchronized (this) { if (functionFactoryCache == null) { functionFactoryCache = lookupFunctions(); } } } if (functionFactoryCache.containsKey(name)) { FunctionFactory functionFactory = functionFactoryCache.get(name); return functionFactory.function(name, parameters, fallback); } // do a lookup from all factories, this is because of the name tricks the default // factory does Function f = null; for (FunctionFactory ff : CommonFactoryFinder.getFunctionFactories(null)) { f = ff.function(name, parameters, fallback); if (f != null) return f; } return null; }
/** * Lookup the FunctionName description. * * @param name Function name; this will need to be an exact match * @return FunctioName description, or null if function is not available */ public FunctionName findFunctionDescription(Name name) { Set<FunctionFactory> functionFactories = CommonFactoryFinder.getFunctionFactories(null); for (FunctionFactory factory : functionFactories) { List<FunctionName> functionNames = factory.getFunctionNames(); for (FunctionName description : functionNames) { if (description.getFunctionName().equals(name)) { return description; } } } return null; // not found }
@Test public void testLookup() { Set<FunctionFactory> factories = CommonFactoryFinder.getFunctionFactories(null); FunctionFactory factory = null; for (FunctionFactory ff : factories) { for (FunctionName fn : ff.getFunctionNames()) { if ("foo".equals(fn.getName())) { factory = ff; break; } } } assertNotNull(factory); Function f = factory.function("foo", null, null); assertNotNull(f); }
protected Set<FunctionName> getAvailableFunctionNames() { // Sort them up for easier visual inspection SortedSet sortedFunctions = new TreeSet( new Comparator() { public int compare(Object o1, Object o2) { String n1 = ((FunctionName) o1).getName(); String n2 = ((FunctionName) o2).getName(); return n1.toLowerCase().compareTo(n2.toLowerCase()); } }); Set<FunctionFactory> factories = CommonFactoryFinder.getFunctionFactories(null); for (FunctionFactory factory : factories) { sortedFunctions.addAll(factory.getFunctionNames()); } return sortedFunctions; }
private HashMap<Name,FunctionFactory> lookupFunctions() { // get all filter functions via function factory HashMap<Name,FunctionFactory> result = new HashMap<Name,FunctionFactory>(); Set<FunctionFactory> functionFactories = CommonFactoryFinder.getFunctionFactories(null); for (FunctionFactory ff : functionFactories) { for (FunctionName functionName : ff.getFunctionNames()) { result.put(functionName.getFunctionName(), ff); } } return result; }
/** * Return a List of FunctionName's describing the functions currently available. * @return List describing available functions */ public List<FunctionName> getAllFunctionDescriptions(){ Set<FunctionFactory> functionFactories = CommonFactoryFinder.getFunctionFactories(null); List<FunctionName> allFunctionDescriptions = new ArrayList<FunctionName>(); for (FunctionFactory factory : functionFactories) { List<FunctionName> functionNames = factory.getFunctionNames(); allFunctionDescriptions.addAll( functionNames ); } Collections.sort( allFunctionDescriptions, new Comparator<FunctionName>() { public int compare(FunctionName o1, FunctionName o2) { if( o1 == null && o2 == null ) return 0; if( o1 == null && o2 != null ) return 1; if( o1 != null && o2 == null ) return -1; return o1.getName().compareTo( o2.getName() ); } } ); return Collections.unmodifiableList(allFunctionDescriptions); } /**
/** * Lookup the FunctionName description. * @param name Function name; this will need to be an exact match * @return FunctioName description, or null if function is not available */ public FunctionName findFunctionDescription(Name name ){ Set<FunctionFactory> functionFactories = CommonFactoryFinder.getFunctionFactories(null); for (FunctionFactory factory : functionFactories) { List<FunctionName> functionNames = factory.getFunctionNames(); for( FunctionName description : functionNames ){ if( description.getFunctionName().equals( name )){ return description; } } } return null; // not found }
Function findFunctionInternal(Name name, List parameters, Literal fallback) { if (functionFactoryCache == null) { synchronized (this) { if (functionFactoryCache == null) { functionFactoryCache = lookupFunctions(); } } } if (functionFactoryCache.containsKey(name)) { FunctionFactory functionFactory = functionFactoryCache.get(name); return functionFactory.function(name, parameters, fallback); } //do a lookup from all factories, this is because of the name tricks the default // factory does Function f = null; for (FunctionFactory ff : CommonFactoryFinder.getFunctionFactories(null)) { f = ff.function(name, parameters, fallback); if (f != null) return f; } return null; }
public SpringBeanProcessFactory(String title, String namespace, Class markerInterface) { super(new SimpleInternationalString(title), namespace); this.markerInterface = markerInterface; // create an iterator that will register this factory into SPI iterator = new FactoryIteratorProvider() { public <T> Iterator<T> iterator(Class<T> category) { if (ProcessFactory.class.isAssignableFrom(category)) { return (Iterator<T>) Collections.singletonList(SpringBeanProcessFactory.this) .iterator(); } else { return null; } } }; // register the new process and make the process function factory lookup again the processes Processors.addProcessFactory(this); for(FunctionFactory ff : CommonFactoryFinder.getFunctionFactories(null)) { if(ff instanceof ProcessFunctionFactory) { ProcessFunctionFactory pff = (ProcessFunctionFactory) ff; pff.clear(); } } }
public SpringBeanProcessFactory(String title, String namespace, Class markerInterface) { super(new SimpleInternationalString(title), namespace); this.markerInterface = markerInterface; // create an iterator that will register this factory into SPI iterator = new FactoryIteratorProvider() { public <T> Iterator<T> iterator(Class<T> category) { if (ProcessFactory.class.isAssignableFrom(category)) { return (Iterator<T>) Collections.singletonList(SpringBeanProcessFactory.this) .iterator(); } else { return null; } } }; // register the new process and make the process function factory lookup again the processes Processors.addProcessFactory(this); for (FunctionFactory ff : CommonFactoryFinder.getFunctionFactories(null)) { if (ff instanceof ProcessFunctionFactory) { ProcessFunctionFactory pff = (ProcessFunctionFactory) ff; pff.clear(); } } }
private void configure() { Integer maxFeatures = parseInteger(GeoServerExtensions .getProperty("QUERY_LAYER_MAX_FEATURES")); Long maxCoordinates = parseLong(GeoServerExtensions .getProperty("GEOMETRY_COLLECT_MAX_COORDINATES")); Set<FunctionFactory> factories = CommonFactoryFinder.getFunctionFactories(null); for (FunctionFactory ff : factories) { if (ff instanceof QueryLayerFunctionFactory) { QueryLayerFunctionFactory factory = (QueryLayerFunctionFactory) ff; if (maxFeatures != null) { factory.setMaxFeatures(maxFeatures); } if (maxCoordinates != null) { factory.setMaxCoordinates(maxCoordinates); } factory.setCatalog(geoServer.getCatalog()); } } }