I need to solve a java design problem. I am implementing a generic ConfigurationRetriever which would return the Configurations that user needs.
I have multiple *Configuration objects which need to be auto refreshed based on the user provided time interval. Client should be able to provide the list of Configurations it needs. The retriever should provide ways for the user to retrieve the configurations which are auto updated. How should I design this? Which design pattern is more suitable for this problem?
Here are sample classes.
class AConfiguration {}
class BConfiguration {}
class CConfiguration {}
class ConfigurationRetriever {
AConfiguration getAConfiguration() {}
BConfiguration getBConfiguration() {}
CConfiguration getCConfiguration() {}
}
I want to add additional fields in the ConfigurationRetriever class.
long timePeriod; // This indicates hhow frequently configurations should be auto updated.
List<String> configNames; // This indicates which configs should be retrieved. e.g { "AConfiguration", "CConfiguration" }
Based on the timePeriod there will be a ScheduledExecutorService which will keep on updating the configs provided in the configNames list.
How should I go about designing these classes? Which design pattern would be suitable here?
Aucun commentaire:
Enregistrer un commentaire