Skip to content

Commit

Permalink
Make DirConfigSource retrieve the executor from the global ConfigProv…
Browse files Browse the repository at this point in the history
…iderResolverImpl instead of explicit dep inject. payara#5006
  • Loading branch information
poikilotherm committed Dec 7, 2020
1 parent ccde673 commit 763f400
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ public void run() {

private static final Logger logger = Logger.getLogger(DirConfigSource.class.getName());
private Path directory;
private ConcurrentHashMap<String, DirProperty> properties = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, DirProperty> properties = new ConcurrentHashMap<>();

public DirConfigSource(PayaraExecutorService executorService) {
public DirConfigSource() {
try {
// get the directory from the app server config
this.directory = findDir();
// create the watcher for the directory
executorService.submit(new DirPropertyWatcher(this.directory));
configService.getExecutor().submit(new DirPropertyWatcher(this.directory));
// initial loading
initializePropertiesFromPath(this.directory);
} catch (IOException e) {
Expand All @@ -207,7 +207,7 @@ public DirConfigSource(PayaraExecutorService executorService) {
}

// Used for testing only with explicit dependency injection
DirConfigSource(Path directory, PayaraExecutorService executorService) {
DirConfigSource(Path directory) {
super(true);
this.directory = directory;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ public ConfigBuilder getBuilder() {
return new PayaraConfigBuilder(this);
}

public PayaraExecutorService getExecutor() {
return this.executorService;
}

Config getNamedConfig(String applicationName) {
Config result = null;
ApplicationInfo info = applicationRegistry.get(applicationName);
Expand All @@ -322,7 +326,7 @@ private List<ConfigSource> getDefaultSources(String appName, String moduleName)
sources.add(new SystemPropertyConfigSource());
sources.add(new JNDIConfigSource());
sources.add(new PayaraServerProperties());
sources.add(new DirConfigSource(executorService));
sources.add(new DirConfigSource());
sources.add(new PasswordAliasConfigSource());
sources.add(new JDBCConfigSource());
if (appName != null) {
Expand Down

0 comments on commit 763f400

Please sign in to comment.