@Test public void test() throws RuntimeConfigException, IOException { Map<String, Object> params = new HashMap<String, Object>(); params.put(GeoToolsLayerBeanFactory.BEAN_NAME, "testLayer"); params.put(GeoToolsLayerBeanFactory.CLASS_NAME, GeoToolsLayer.class); params.put(GeoToolsLayerBeanFactory.LAYER_INFO, countriesInfo); params.put(GeoToolsLayerBeanFactory.STYLE_INFO, countriesInfo.getNamedStyleInfos()); List<BeanDefinitionHolder> beans = beanFactory.createBeans(params); System.out.println(new BeanDefinitionWriterServiceImpl().toString(beans)); Assert.assertEquals(2, beans.size()); }
@Override public List<BeanDefinitionHolder> createBeans(Map<String, Object> parameters) throws RuntimeConfigException { Resource resource = null; if (checkString(LOCATION, parameters) != Priority.NONE) { try { resource = resourceService.find((String) parameters.get(LOCATION)); parameters.put(URL, resource.getURL().toExternalForm()); } catch (Exception e) { throw new RuntimeConfigException(RuntimeConfigException.BAD_PARAMETER, LOCATION, e.getMessage()); } } if (checkClass(LAYER_INFO, VectorLayerInfo.class, parameters) == Priority.NONE) { try { VectorLayerInfo info = generateDefaultInfo(resource.getURL()); parameters.put(LAYER_INFO, info); } catch (Exception e) { throw new RuntimeConfigException(RuntimeConfigException.BAD_PARAMETER, LOCATION, e.getMessage()); } } if (checkCollection(STYLE_INFO, NamedStyleInfo.class, parameters) == Priority.NONE) { VectorLayerInfo info = getObject(LAYER_INFO, parameters); parameters.put(STYLE_INFO, info.getNamedStyleInfos()); } else { VectorLayerInfo info = getObject(LAYER_INFO, parameters); Collection<NamedStyleInfo> styles = getCollection(STYLE_INFO, parameters); info.setNamedStyleInfos(new ArrayList<NamedStyleInfo>(styles)); } return super.createBeans(parameters); }
GeoToolsLayerBeanFactory extends BaseVectorLayerBeanFactory { @Override public List<BeanDefinitionHolder> createBeans(Map<String, Object> parameters) throws RuntimeConfigException { Resource resource = null; if (checkString(LOCATION, parameters) != Priority.NONE) { try { resource = resourceService.find((String) parameters.get(LOCATION)); parameters.put(URL, resource.getURL().toExternalForm()); } catch (Exception e) { throw new RuntimeConfigException(RuntimeConfigException.BAD_PARAMETER, LOCATION, e.getMessage()); } } if (checkClass(LAYER_INFO, VectorLayerInfo.class, parameters) == Priority.NONE) { try { VectorLayerInfo info = generateDefaultInfo(resource.getURL()); parameters.put(LAYER_INFO, info); } catch (Exception e) { throw new RuntimeConfigException(RuntimeConfigException.BAD_PARAMETER, LOCATION, e.getMessage()); } } if (checkCollection(STYLE_INFO, NamedStyleInfo.class, parameters) == Priority.NONE) { VectorLayerInfo info = getObject(LAYER_INFO, parameters); parameters.put(STYLE_INFO, info.getNamedStyleInfos()); } else { VectorLayerInfo info = getObject(LAYER_INFO, parameters); Collection<NamedStyleInfo> styles = getCollection(STYLE_INFO, parameters); info.setNamedStyleInfos(new ArrayList<NamedStyleInfo>(styles)); } return super.createBeans(parameters); } }
GeoToolsLayerBeanFactory extends BaseVectorLayerBeanFactory { @Override public List<BeanDefinitionHolder> createBeans(Map<String, Object> parameters) throws RuntimeConfigException { Resource resource = null; if (checkString(LOCATION, parameters) != Priority.NONE) { try { resource = resourceService.find((String) parameters.get(LOCATION)); parameters.put(URL, resource.getURL().toExternalForm()); } catch (Exception e) { throw new RuntimeConfigException(RuntimeConfigException.BAD_PARAMETER, LOCATION, e.getMessage()); } } if (checkClass(LAYER_INFO, VectorLayerInfo.class, parameters) == Priority.NONE) { try { VectorLayerInfo info = generateDefaultInfo(resource.getURL()); parameters.put(LAYER_INFO, info); } catch (Exception e) { throw new RuntimeConfigException(RuntimeConfigException.BAD_PARAMETER, LOCATION, e.getMessage()); } } if (checkCollection(STYLE_INFO, NamedStyleInfo.class, parameters) == Priority.NONE) { VectorLayerInfo info = getObject(LAYER_INFO, parameters); parameters.put(STYLE_INFO, info.getNamedStyleInfos()); } else { VectorLayerInfo info = getObject(LAYER_INFO, parameters); Collection<NamedStyleInfo> styles = getCollection(STYLE_INFO, parameters); info.setNamedStyleInfos(new ArrayList<NamedStyleInfo>(styles)); } return super.createBeans(parameters); } protected  GeoToolsLayerBeanFactory(); }
GeoToolsLayerBeanFactory extends BaseVectorLayerBeanFactory { @Override public List<BeanDefinitionHolder> createBeans(Map<String, Object> parameters) throws RuntimeConfigException { Resource resource = null; if (checkString(LOCATION, parameters) != Priority.NONE) { try { resource = resourceService.find((String) parameters.get(LOCATION)); parameters.put(URL, resource.getURL().toExternalForm()); } catch (Exception e) { throw new RuntimeConfigException(RuntimeConfigException.BAD_PARAMETER, LOCATION, e.getMessage()); } } if (checkClass(LAYER_INFO, VectorLayerInfo.class, parameters) == Priority.NONE) { try { VectorLayerInfo info = generateDefaultInfo(resource.getURL()); parameters.put(LAYER_INFO, info); } catch (Exception e) { throw new RuntimeConfigException(RuntimeConfigException.BAD_PARAMETER, LOCATION, e.getMessage()); } } if (checkCollection(STYLE_INFO, NamedStyleInfo.class, parameters) == Priority.NONE) { VectorLayerInfo info = getObject(LAYER_INFO, parameters); parameters.put(STYLE_INFO, info.getNamedStyleInfos()); } else { VectorLayerInfo info = getObject(LAYER_INFO, parameters); Collection<NamedStyleInfo> styles = getCollection(STYLE_INFO, parameters); info.setNamedStyleInfos(new ArrayList<NamedStyleInfo>(styles)); } return super.createBeans(parameters); } protected  GeoToolsLayerBeanFactory(); @Override Priority getPriority(Map<String, Object> parameters); @Override List<BeanDefinitionHolder> createBeans(Map<String, Object> parameters); }
GeoToolsLayerBeanFactory extends BaseVectorLayerBeanFactory { @Override public List<BeanDefinitionHolder> createBeans(Map<String, Object> parameters) throws RuntimeConfigException { Resource resource = null; if (checkString(LOCATION, parameters) != Priority.NONE) { try { resource = resourceService.find((String) parameters.get(LOCATION)); parameters.put(URL, resource.getURL().toExternalForm()); } catch (Exception e) { throw new RuntimeConfigException(RuntimeConfigException.BAD_PARAMETER, LOCATION, e.getMessage()); } } if (checkClass(LAYER_INFO, VectorLayerInfo.class, parameters) == Priority.NONE) { try { VectorLayerInfo info = generateDefaultInfo(resource.getURL()); parameters.put(LAYER_INFO, info); } catch (Exception e) { throw new RuntimeConfigException(RuntimeConfigException.BAD_PARAMETER, LOCATION, e.getMessage()); } } if (checkCollection(STYLE_INFO, NamedStyleInfo.class, parameters) == Priority.NONE) { VectorLayerInfo info = getObject(LAYER_INFO, parameters); parameters.put(STYLE_INFO, info.getNamedStyleInfos()); } else { VectorLayerInfo info = getObject(LAYER_INFO, parameters); Collection<NamedStyleInfo> styles = getCollection(STYLE_INFO, parameters); info.setNamedStyleInfos(new ArrayList<NamedStyleInfo>(styles)); } return super.createBeans(parameters); } protected  GeoToolsLayerBeanFactory(); @Override Priority getPriority(Map<String, Object> parameters); @Override List<BeanDefinitionHolder> createBeans(Map<String, Object> parameters); static final String LOCATION; static final String PARAMETERS; static final String URL; }