test_class.declarator: configSource
test_class.modifier: private
test_class.original_string: private DatasourceConfigSource configSource;
test_class.type: DatasourceConfigSource
test_class.var_name: configSource
test_class.file: configsource-db/src/test/java/org/microprofileext/config/source/db/DatasourceConfigSourceTest.java
test_class.identifier: DatasourceConfigSourceTest
test_case.body: @Test
      public void testGetValue_cache() {
          when(configSource.repository.getConfigValue(anyString())).thenReturn("123");
          configSource.getValue("test");
          configSource.getValue("test");
          verify(configSource.repository, times(1)).getConfigValue(anyString());
      }
test_case.class_method_signature: DatasourceConfigSourceTest.testGetValue_cache()
test_case.full_signature: @Test public void testGetValue_cache()
test_case.identifier: testGetValue_cache
test_case.invocations: thenReturn when getConfigValue anyString getValue getValue getConfigValue verify times anyString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetValue_cache()
focal_class.declarator: NAME = "DatasourceConfigSource"
focal_class.modifier: private static final
focal_class.original_string: private static final String NAME = "DatasourceConfigSource";
focal_class.type: String
focal_class.var_name: NAME
focal_class.declarator: cache = new ConcurrentHashMap<>()
focal_class.modifier: private final
focal_class.original_string: private final Map<String, TimedEntry> cache = new ConcurrentHashMap<>();
focal_class.type: Map<String, TimedEntry>
focal_class.var_name: cache
focal_class.declarator: repository = null
focal_class.original_string: Repository repository = null;
focal_class.type: Repository
focal_class.var_name: repository
focal_class.declarator: validity = null
focal_class.modifier: private
focal_class.original_string: private Long validity = null;
focal_class.type: Long
focal_class.var_name: validity
focal_class.declarator: notifyOnChanges
focal_class.modifier: private
focal_class.original_string: private boolean notifyOnChanges;
focal_class.type: boolean
focal_class.var_name: notifyOnChanges
focal_class.declarator: NOTIFY_ON_CHANGES = "notifyOnChanges"
focal_class.modifier: private static final
focal_class.original_string: private static final String NOTIFY_ON_CHANGES = "notifyOnChanges";
focal_class.type: String
focal_class.var_name: NOTIFY_ON_CHANGES
focal_class.declarator: DEFAULT_NOTIFY_ON_CHANGES = true
focal_class.modifier: private static final
focal_class.original_string: private static final boolean DEFAULT_NOTIFY_ON_CHANGES = true;
focal_class.type: boolean
focal_class.var_name: DEFAULT_NOTIFY_ON_CHANGES
focal_class.file: configsource-db/src/main/java/org/microprofileext/config/source/db/DatasourceConfigSource.java
focal_class.identifier: DatasourceConfigSource
focal_class.class_method_signature: DatasourceConfigSource.DatasourceConfigSource()
focal_class.full_signature: public  DatasourceConfigSource()
focal_class.identifier: DatasourceConfigSource
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  DatasourceConfigSource()
focal_class.class_method_signature: DatasourceConfigSource.getPropertiesIfEnabled()
focal_class.full_signature: @Override public Map<String, String> getPropertiesIfEnabled()
focal_class.identifier: getPropertiesIfEnabled
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> getPropertiesIfEnabled()
focal_class.class_method_signature: DatasourceConfigSource.getValue(String propertyName)
focal_class.full_signature: @Override public String getValue(String propertyName)
focal_class.identifier: getValue
focal_class.modifiers: @Override public
focal_class.parameters: (String propertyName)
focal_class.return: String
focal_class.signature: String getValue(String propertyName)
focal_class.class_method_signature: DatasourceConfigSource.getName()
focal_class.full_signature: @Override public String getName()
focal_class.identifier: getName
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getName()
focal_class.class_method_signature: DatasourceConfigSource.readFromDB(String propertyName)
focal_class.full_signature: private String readFromDB(String propertyName)
focal_class.identifier: readFromDB
focal_class.modifiers: private
focal_class.parameters: (String propertyName)
focal_class.return: String
focal_class.signature: String readFromDB(String propertyName)
focal_class.class_method_signature: DatasourceConfigSource.initRepository()
focal_class.full_signature: private void initRepository()
focal_class.identifier: initRepository
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void initRepository()
focal_class.class_method_signature: DatasourceConfigSource.initValidity()
focal_class.full_signature: private void initValidity()
focal_class.identifier: initValidity
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void initValidity()
focal_class.class_method_signature: DatasourceConfigSource.getConfigKey(String subKey)
focal_class.full_signature: private String getConfigKey(String subKey)
focal_class.identifier: getConfigKey
focal_class.modifiers: private
focal_class.parameters: (String subKey)
focal_class.return: String
focal_class.signature: String getConfigKey(String subKey)
focal_class.class_method_signature: DatasourceConfigSource.loadNotifyOnChanges()
focal_class.full_signature: private boolean loadNotifyOnChanges()
focal_class.identifier: loadNotifyOnChanges
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean loadNotifyOnChanges()
focal_class.superclass: extends EnabledConfigSource
focal_method.body: @Override
      public String getValue(String propertyName) {
          if (CONFIG_ORDINAL.equals(propertyName)) {
              return null;
          }
          
          initRepository();
          initValidity();
          
          // TODO: Cache null values ? So if the config is not in the DB, cache the empty value
          // TODO: If not first time load, fire NEW Event ?
          TimedEntry entry = cache.get(propertyName);
          
          if (entry == null){
              // First time read (Or no config)
              return readFromDB(propertyName);
          }else if(entry.isExpired()) {
              // Time to refresh
              ChangeEventNotifier changeEventNotifier = ChangeEventNotifier.getInstance();
              String oldValue = entry.getValue();
              String newValue = readFromDB(propertyName);
              if(notifyOnChanges){
                  // Remove Event
                  if(newValue==null){
                      changeEventNotifier.fire(new ChangeEvent(Type.REMOVE,propertyName,changeEventNotifier.getOptionalOldValue(oldValue),null,NAME));
                  // Change Event
                  }else if(!oldValue.equals(newValue)){
                      changeEventNotifier.fire(new ChangeEvent(Type.UPDATE,propertyName,changeEventNotifier.getOptionalOldValue(oldValue),newValue,NAME));
                  }
              }
              
              return newValue;
          }else{
              // Read from cache
              return entry.getValue();
          }
          
      }
focal_method.class_method_signature: DatasourceConfigSource.getValue(String propertyName)
focal_method.full_signature: @Override public String getValue(String propertyName)
focal_method.identifier: getValue
focal_method.invocations: equals initRepository initValidity get readFromDB isExpired getInstance getValue readFromDB fire getOptionalOldValue equals fire getOptionalOldValue getValue
focal_method.modifiers: @Override public
focal_method.parameters: (String propertyName)
focal_method.return: String
focal_method.signature: String getValue(String propertyName)