@Test public void testIncrementalUpdate() { assertInitialState(); registry.set(CollectionSettingNames.CS_QUERY_EXRTERNAL_RESOURCE_NAME, Boolean.TRUE); boolean active = generator.isGeneratingExternalResources(); assertTrue("Active state should be true after update", active); ApplicationName appName = ApplicationName.valueOf("test-app"); registry.set(CollectionSettingNames.createApplicationCollectionSettingName(appName), Boolean.FALSE); Collection<ApplicationName> apps = generator.getDisabledApplicationNames(); assertEquals("Total disabled apps", 1, apps.size()); assertTrue(appName + "is known when disabled", generator.isApplicationNameKnown(appName)); ApplicationName disabledAppName = ListUtil.getFirstMember(apps); assertEquals("The only disabled app", appName, disabledAppName); registry.set(CollectionSettingNames.createApplicationCollectionSettingName(appName), Boolean.TRUE); apps = generator.getDisabledApplicationNames(); assertTrue("Total disabled apps is empty", apps.isEmpty()); assertTrue(appName + "is known when enabled", generator.isApplicationNameKnown(appName)); }
public final void incrementalUpdate(CollectionSettingName name, Serializable value) { if ((name == null) || (value == null)) { return; } if (CollectionSettingNames.CS_QUERY_EXRTERNAL_RESOURCE_NAME.equals(name)) { boolean newValue = CollectionSettingsRegistry.getBooleanSettingValue(value); boolean prevValue = active.getAndSet(newValue); if (prevValue != newValue) { _logger.info("incrementalUpdate(" + name + ") " + prevValue + " => " + newValue); } return; } String key = name.getKey(); if (!key.startsWith(CollectionSettingNames.APP_QUERY_EXRTERNAL_RESOURCE_KEY_NAME)) { return; } String appNameStr = key.substring(CollectionSettingNames.APP_QUERY_EXRTERNAL_RESOURCE_KEY_NAME.length()); ApplicationName appName = ApplicationName.valueOf(appNameStr); if (knownApps.add(appName)) { _logger.info("incrementalUpdate(" + appName + ") new application"); } boolean newEnabledValue = CollectionSettingsRegistry.getBooleanSettingValue(value); boolean prevEnabledValue = newEnabledValue ? disabledApps.remove(appName) : disabledApps.add(appName); if (prevEnabledValue != newEnabledValue) { _logger.info("incrementalUpdate(" + appName + ") " + prevEnabledValue + " => " + newEnabledValue); } }
JdbcQueryExternalResourceGenerator extends AbstractLoggingClass implements CollectionSettingsUpdateListener { public final void incrementalUpdate(CollectionSettingName name, Serializable value) { if ((name == null) || (value == null)) { return; } if (CollectionSettingNames.CS_QUERY_EXRTERNAL_RESOURCE_NAME.equals(name)) { boolean newValue = CollectionSettingsRegistry.getBooleanSettingValue(value); boolean prevValue = active.getAndSet(newValue); if (prevValue != newValue) { _logger.info("incrementalUpdate(" + name + ") " + prevValue + " => " + newValue); } return; } String key = name.getKey(); if (!key.startsWith(CollectionSettingNames.APP_QUERY_EXRTERNAL_RESOURCE_KEY_NAME)) { return; } String appNameStr = key.substring(CollectionSettingNames.APP_QUERY_EXRTERNAL_RESOURCE_KEY_NAME.length()); ApplicationName appName = ApplicationName.valueOf(appNameStr); if (knownApps.add(appName)) { _logger.info("incrementalUpdate(" + appName + ") new application"); } boolean newEnabledValue = CollectionSettingsRegistry.getBooleanSettingValue(value); boolean prevEnabledValue = newEnabledValue ? disabledApps.remove(appName) : disabledApps.add(appName); if (prevEnabledValue != newEnabledValue) { _logger.info("incrementalUpdate(" + appName + ") " + prevEnabledValue + " => " + newEnabledValue); } } }
JdbcQueryExternalResourceGenerator extends AbstractLoggingClass implements CollectionSettingsUpdateListener { public final void incrementalUpdate(CollectionSettingName name, Serializable value) { if ((name == null) || (value == null)) { return; } if (CollectionSettingNames.CS_QUERY_EXRTERNAL_RESOURCE_NAME.equals(name)) { boolean newValue = CollectionSettingsRegistry.getBooleanSettingValue(value); boolean prevValue = active.getAndSet(newValue); if (prevValue != newValue) { _logger.info("incrementalUpdate(" + name + ") " + prevValue + " => " + newValue); } return; } String key = name.getKey(); if (!key.startsWith(CollectionSettingNames.APP_QUERY_EXRTERNAL_RESOURCE_KEY_NAME)) { return; } String appNameStr = key.substring(CollectionSettingNames.APP_QUERY_EXRTERNAL_RESOURCE_KEY_NAME.length()); ApplicationName appName = ApplicationName.valueOf(appNameStr); if (knownApps.add(appName)) { _logger.info("incrementalUpdate(" + appName + ") new application"); } boolean newEnabledValue = CollectionSettingsRegistry.getBooleanSettingValue(value); boolean prevEnabledValue = newEnabledValue ? disabledApps.remove(appName) : disabledApps.add(appName); if (prevEnabledValue != newEnabledValue) { _logger.info("incrementalUpdate(" + appName + ") " + prevEnabledValue + " => " + newEnabledValue); } } private  JdbcQueryExternalResourceGenerator();   JdbcQueryExternalResourceGenerator(CollectionSettingsRegistry reg); }
JdbcQueryExternalResourceGenerator extends AbstractLoggingClass implements CollectionSettingsUpdateListener { public final void incrementalUpdate(CollectionSettingName name, Serializable value) { if ((name == null) || (value == null)) { return; } if (CollectionSettingNames.CS_QUERY_EXRTERNAL_RESOURCE_NAME.equals(name)) { boolean newValue = CollectionSettingsRegistry.getBooleanSettingValue(value); boolean prevValue = active.getAndSet(newValue); if (prevValue != newValue) { _logger.info("incrementalUpdate(" + name + ") " + prevValue + " => " + newValue); } return; } String key = name.getKey(); if (!key.startsWith(CollectionSettingNames.APP_QUERY_EXRTERNAL_RESOURCE_KEY_NAME)) { return; } String appNameStr = key.substring(CollectionSettingNames.APP_QUERY_EXRTERNAL_RESOURCE_KEY_NAME.length()); ApplicationName appName = ApplicationName.valueOf(appNameStr); if (knownApps.add(appName)) { _logger.info("incrementalUpdate(" + appName + ") new application"); } boolean newEnabledValue = CollectionSettingsRegistry.getBooleanSettingValue(value); boolean prevEnabledValue = newEnabledValue ? disabledApps.remove(appName) : disabledApps.add(appName); if (prevEnabledValue != newEnabledValue) { _logger.info("incrementalUpdate(" + appName + ") " + prevEnabledValue + " => " + newEnabledValue); } } private  JdbcQueryExternalResourceGenerator();   JdbcQueryExternalResourceGenerator(CollectionSettingsRegistry reg); static final JdbcQueryExternalResourceGenerator getInstance(); Collection<ExternalResourceDescriptor> createAndAddQueryExternalResourceDescriptors(Collection<ExternalResourceDescriptor> dbDescriptors, Trace trace); final void incrementalUpdate(CollectionSettingName name, Serializable value); static String extractSqlFromOperation(Operation op); boolean isGeneratingExternalResources(); boolean isGeneratingExternalResourceForApplication(ApplicationName appName); Collection<ApplicationName> getDisabledApplicationNames(); Collection<ApplicationName> getKnownApplicationNames(); boolean isApplicationNameKnown(ApplicationName appName); }
JdbcQueryExternalResourceGenerator extends AbstractLoggingClass implements CollectionSettingsUpdateListener { public final void incrementalUpdate(CollectionSettingName name, Serializable value) { if ((name == null) || (value == null)) { return; } if (CollectionSettingNames.CS_QUERY_EXRTERNAL_RESOURCE_NAME.equals(name)) { boolean newValue = CollectionSettingsRegistry.getBooleanSettingValue(value); boolean prevValue = active.getAndSet(newValue); if (prevValue != newValue) { _logger.info("incrementalUpdate(" + name + ") " + prevValue + " => " + newValue); } return; } String key = name.getKey(); if (!key.startsWith(CollectionSettingNames.APP_QUERY_EXRTERNAL_RESOURCE_KEY_NAME)) { return; } String appNameStr = key.substring(CollectionSettingNames.APP_QUERY_EXRTERNAL_RESOURCE_KEY_NAME.length()); ApplicationName appName = ApplicationName.valueOf(appNameStr); if (knownApps.add(appName)) { _logger.info("incrementalUpdate(" + appName + ") new application"); } boolean newEnabledValue = CollectionSettingsRegistry.getBooleanSettingValue(value); boolean prevEnabledValue = newEnabledValue ? disabledApps.remove(appName) : disabledApps.add(appName); if (prevEnabledValue != newEnabledValue) { _logger.info("incrementalUpdate(" + appName + ") " + prevEnabledValue + " => " + newEnabledValue); } } private  JdbcQueryExternalResourceGenerator();   JdbcQueryExternalResourceGenerator(CollectionSettingsRegistry reg); static final JdbcQueryExternalResourceGenerator getInstance(); Collection<ExternalResourceDescriptor> createAndAddQueryExternalResourceDescriptors(Collection<ExternalResourceDescriptor> dbDescriptors, Trace trace); final void incrementalUpdate(CollectionSettingName name, Serializable value); static String extractSqlFromOperation(Operation op); boolean isGeneratingExternalResources(); boolean isGeneratingExternalResourceForApplication(ApplicationName appName); Collection<ApplicationName> getDisabledApplicationNames(); Collection<ApplicationName> getKnownApplicationNames(); boolean isApplicationNameKnown(ApplicationName appName);  }