New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #5086 Review and rework o.e.j.util.Scanner #5744
Changes from 9 commits
4883332
4304c78
115a72d
90e48ba
31cc298
e39ec6c
c776eeb
8fe8cb8
97b3f26
fe0e076
9c882ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,20 +41,15 @@ | |
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* | ||
*/ | ||
@ManagedObject("Abstract Provider for loading webapps") | ||
public abstract class ScanningAppProvider extends ContainerLifeCycle implements AppProvider | ||
{ | ||
private static final Logger LOG = LoggerFactory.getLogger(ScanningAppProvider.class); | ||
|
||
private Map<String, App> _appMap = new HashMap<String, App>(); | ||
|
||
private final Map<String, App> _appMap = new HashMap<>(); | ||
private DeploymentManager _deploymentManager; | ||
protected FilenameFilter _filenameFilter; | ||
private FilenameFilter _filenameFilter; | ||
private final List<Resource> _monitored = new CopyOnWriteArrayList<>(); | ||
private boolean _recursive = false; | ||
private int _scanInterval = 10; | ||
private Scanner _scanner; | ||
|
||
|
@@ -140,7 +135,6 @@ protected void doStart() throws Exception | |
_scanner = new Scanner(); | ||
_scanner.setScanDirs(files); | ||
_scanner.setScanInterval(_scanInterval); | ||
_scanner.setRecursive(_recursive); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
_scanner.setFilenameFilter(_filenameFilter); | ||
_scanner.setReportDirs(true); | ||
_scanner.setScanDepth(1); //consider direct dir children of monitored dir | ||
|
@@ -237,12 +231,6 @@ public int getScanInterval() | |
return _scanInterval; | ||
} | ||
|
||
@ManagedAttribute("recursive scanning supported") | ||
public boolean isRecursive() | ||
{ | ||
return _recursive; | ||
} | ||
|
||
@Override | ||
public void setDeploymentManager(DeploymentManager deploymentManager) | ||
{ | ||
|
@@ -295,11 +283,6 @@ public void setMonitoredDirectories(Collection<String> directories) | |
} | ||
} | ||
|
||
protected void setRecursive(boolean recursive) | ||
{ | ||
_recursive = recursive; | ||
} | ||
|
||
public void setScanInterval(int scanInterval) | ||
{ | ||
_scanInterval = scanInterval; | ||
|
@@ -312,7 +295,7 @@ public void scan() | |
getMonitoredResources().stream().map((r) -> r.getURI().toASCIIString()) | ||
.collect(Collectors.joining(", ", "[", "]")) | ||
); | ||
_scanner.scan(); | ||
_scanner.nudge(); | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't like this. File names are unique by definition, so there is no risk of duplicates. I would not add additional randomness caused by
Set
. If I really don't care, I'd useCollection
-- theSet
is supposed to be immutable anyway, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand your point. If it's a List then by definition I can have duplicates in a List, but I can't in a Set. Plus, you can't rely on ordering as it depends on the filesystem in what order scanned directories are visited, so List is a furphy.