/** * Merges two models into a new model. * Note: The act of merging results in fromModel and toModel to have their configurations normalized and children ordered! * @param <M> the type of Model being merged * @param fromModel merge from this model, optionally overriding anything in toModel * @param toModel merge into a copy of this model * @param fromOverridesTo whether fromModel attributes/values should override those in toModel * @return the newly merged model */ public static <M extends Model> M merge(M fromModel, M toModel, boolean fromOverridesTo) { return merge(fromModel, toModel, fromOverridesTo, false); }
/** * Merges two models into a new model. * Note: The act of merging results in fromModel and toModel to have their configurations normalized and children ordered! * @param <M> the type of Model being merged * @param fromModel merge from this model, overriding anything in toModel * @param toModel merge into a copy of this model * @return the newly merged model */ public static <M extends Model> M merge(M fromModel, M toModel) { return merge(fromModel, toModel, true); }
/** * Merges two models into a new model. * Note: The act of merging results in fromModel and toModel to have their configurations normalized and children ordered! * @param <M> the type of Model being merged * @param fromModel merge from this model, overriding anything in toModel * @param toModel merge into a copy of this model * @return the newly merged model */ public static <M extends Model> M merge(M fromModel, M toModel) { return merge(fromModel, toModel, true); }
/** * Merges two models into a new model. * Note: The act of merging results in fromModel and toModel to have their configurations normalized and children ordered! * @param <M> the type of Model being merged * @param fromModel merge from this model, optionally overriding anything in toModel * @param toModel merge into a copy of this model * @param fromOverridesTo whether fromModel attributes/values should override those in toModel * @return the newly merged model */ public static <M extends Model> M merge(M fromModel, M toModel, boolean fromOverridesTo) { return merge(fromModel, toModel, fromOverridesTo, false); }
/** * Retrieves a merge of the user config and the generated configuration in * <code>target/classes/META-INF/switchyard.xml</code>. * @return merged switchyard configuration */ public SwitchYardModel getMergedSwitchYardConfig() { SwitchYardModel mergedConfig = null; FileResource<?> generatedFile = getGeneratedConfigFile(); if (generatedFile != null && generatedFile.exists()) { try { SwitchYardModel generatedConfig = readSwitchYardConfig(generatedFile); mergedConfig = Models.merge(generatedConfig, getSwitchYardConfig()); } catch (java.io.IOException ioEx) { _shell.println("Error while reading SwitchYard configuration: " + ioEx.getMessage()); } } // If we don't have a merged config at this point, then we should just // return the user configuration if (mergedConfig == null) { mergedConfig = getSwitchYardConfig(); } return mergedConfig; }
private SwitchYardModel createSwitchYardModel(InputStream configModel, List<Scanner<V1SwitchYardModel>> scanners, boolean validate) { Assert.assertNotNull("Test 'configModel' is null.", configModel); final SwitchYardModel returnModel; try { SwitchYardModel model = loadSwitchYardModel(configModel, false); ClassLoader classLoader = _testInstance.getClass().getClassLoader(); if (scanners != null && !scanners.isEmpty() && classLoader instanceof URLClassLoader) { String uri = model.getModelRootNamespace(); SwitchYardNamespace ns = SwitchYardNamespace.fromUri(uri); MergeScanner<V1SwitchYardModel> merge_scanner = new MergeScanner<V1SwitchYardModel>(true, scanners); List<URL> scanURLs = getScanURLs((URLClassLoader)classLoader); ScannerInput<V1SwitchYardModel> scanner_input = new ScannerInput<V1SwitchYardModel>() .setSwitchyardNamespace(ns).setCompositeName(model.getName()).setURLs(scanURLs); V1SwitchYardModel scannedModel = merge_scanner.scan(scanner_input).getModel(); returnModel = Models.merge(scannedModel, model, false); } else { returnModel = model; } if (validate) { returnModel.assertModelValid(); } return returnModel; } catch (java.io.IOException ioEx) { throw new SwitchYardException("Failed to read switchyard config.", ioEx); } }
private SwitchYardModel createSwitchYardModel(InputStream configModel, List<Scanner<V1SwitchYardModel>> scanners, boolean validate) { Assert.assertNotNull("Test 'configModel' is null.", configModel); final SwitchYardModel returnModel; try { SwitchYardModel model = loadSwitchYardModel(configModel, false); ClassLoader classLoader = _testInstance.getClass().getClassLoader(); if (scanners != null && !scanners.isEmpty() && classLoader instanceof URLClassLoader) { String uri = model.getModelRootNamespace(); SwitchYardNamespace ns = SwitchYardNamespace.fromUri(uri); MergeScanner<V1SwitchYardModel> merge_scanner = new MergeScanner<V1SwitchYardModel>(true, scanners); List<URL> scanURLs = getScanURLs((URLClassLoader)classLoader); ScannerInput<V1SwitchYardModel> scanner_input = new ScannerInput<V1SwitchYardModel>() .setSwitchyardNamespace(ns).setCompositeName(model.getName()).setURLs(scanURLs); V1SwitchYardModel scannedModel = merge_scanner.scan(scanner_input).getModel(); returnModel = Models.merge(scannedModel, model, false); } else { returnModel = model; } if (validate) { returnModel.assertModelValid(); } return returnModel; } catch (java.io.IOException ioEx) { throw new SwitchYardException("Failed to read switchyard config.", ioEx); } }
merged = scanned; } else { merged = Models.merge(scanned, merged, _fromOverridesTo);
merged = scanned; } else { merged = Models.merge(scanned, merged, _fromOverridesTo);