private void processBindingConfigsFromModel(String modelName) { logger.debug("Processing binding configs for items from model '{}'", modelName); if (modelRepository != null) { ItemModel model = (ItemModel) modelRepository.getModel(modelName); if (model == null) { return; } // start binding configuration processing for (BindingConfigReader reader : bindingConfigReaders.values()) { reader.startConfigurationUpdate(modelName); } // create items and read new binding configuration for (ModelItem modelItem : model.getItems()) { Item item = createItemFromModelItem(modelItem); if (item != null) { internalDispatchBindings(modelName, item, modelItem.getBindings()); } } // end binding configuration processing for (BindingConfigReader reader : bindingConfigReaders.values()) { reader.stopConfigurationUpdate(modelName); } } }
public void addBindingConfigReader(BindingConfigReader reader) { if (!bindingConfigReaders.containsKey(reader.getBindingType())) { bindingConfigReaders.put(reader.getBindingType(), reader); dispatchBindingsPerType(reader, new String[] {reader.getBindingType()}); } else { logger.warn( "Attempted to register a second BindingConfigReader of type '{}'." + " The primaraly reader will remain active!", reader.getBindingType()); } }
private void internalDispatchBindings( BindingConfigReader reader, String modelName, Item item, EList<ModelBinding> bindings) { for (ModelBinding binding : bindings) { String bindingType = binding.getType(); String config = binding.getConfiguration(); BindingConfigReader localReader = reader; if (reader == null) { logger.trace( "Given binding config reader is null > query cache to find appropriate reader!"); localReader = bindingConfigReaders.get(bindingType); } else { if (!localReader.getBindingType().equals(binding.getType())) { logger.trace( "The Readers' binding type '{}' and the Bindings' type '{}' doesn't match > continue processing next binding.", localReader.getBindingType(), binding.getType()); continue; } else { logger.debug( "Start processing binding configuration of Item '{}' with '{}' reader.", item, localReader.getClass().getSimpleName()); } } if (localReader != null) { try { localReader.validateItemType(item.getType(), config); localReader.processBindingConfiguration( modelName, item.getType(), item.getName(), config); } catch (BindingConfigParseException e) { logger.error( "Binding configuration of type '" + bindingType + "' of item '" + item.getName() + "' could not be parsed correctly.", e); } catch (Exception e) { // Catch badly behaving binding exceptions and continue processing logger.error( "Binding configuration of type '" + bindingType + "' of item '" + item.getName() + "' could not be parsed correctly.", e); } } else { logger.trace( "Couldn't find config reader for binding type '{}' > " + "parsing binding configuration of Item '{}' aborted!", bindingType, item); } } }
public void removeBindingConfigReader(BindingConfigReader reader) { if (bindingConfigReaders.get(reader.getBindingType()).equals(reader)) { bindingConfigReaders.remove(reader.getBindingType()); } }