Skip to content

Commit

Permalink
Merge pull request #5744 from eclipse/jetty-10.0.x-5086-review-scanner
Browse files Browse the repository at this point in the history
Issue #5086 Review and rework o.e.j.util.Scanner
  • Loading branch information
sbordet authored Dec 2, 2020
2 parents 3788223 + 9c882ee commit 0eccdde
Show file tree
Hide file tree
Showing 9 changed files with 409 additions and 445 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.eclipse.jetty.ant.types.Connector;
import org.eclipse.jetty.ant.types.ContextHandlers;
Expand Down Expand Up @@ -135,7 +136,7 @@ public WebAppScannerListener(AntWebAppContext awc)
}

@Override
public void filesChanged(List<String> changedFileNames)
public void filesChanged(Set<String> changedFileNames)
{
boolean isScanned = false;
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -140,7 +135,6 @@ protected void doStart() throws Exception
_scanner = new Scanner();
_scanner.setScanDirs(files);
_scanner.setScanInterval(_scanInterval);
_scanner.setRecursive(_recursive);
_scanner.setFilenameFilter(_filenameFilter);
_scanner.setReportDirs(true);
_scanner.setScanDepth(1); //consider direct dir children of monitored dir
Expand Down Expand Up @@ -237,12 +231,6 @@ public int getScanInterval()
return _scanInterval;
}

@ManagedAttribute("recursive scanning supported")
public boolean isRecursive()
{
return _recursive;
}

@Override
public void setDeploymentManager(DeploymentManager deploymentManager)
{
Expand Down Expand Up @@ -295,11 +283,6 @@ public void setMonitoredDirectories(Collection<String> directories)
}
}

protected void setRecursive(boolean recursive)
{
_recursive = recursive;
}

public void setScanInterval(int scanInterval)
{
_scanInterval = scanInterval;
Expand All @@ -312,7 +295,7 @@ public void scan()
getMonitoredResources().stream().map((r) -> r.getURI().toASCIIString())
.collect(Collectors.joining(", ", "[", "]"))
);
_scanner.scan();
_scanner.nudge();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public void setupEnvironment() throws Exception
if (provider instanceof ScanningAppProvider)
{
_providers++;
((ScanningAppProvider)provider).addScannerListener(new Scanner.ScanListener()
((ScanningAppProvider)provider).addScannerListener(new Scanner.ScanCycleListener()
{
@Override
public void scan()
public void scanEnded(int cycle)
{
_scans.incrementAndGet();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -191,7 +191,7 @@ protected void configureScanner()
}
scanner.addListener(new Scanner.BulkListener()
{
public void filesChanged(List<String> changes)
public void filesChanged(Set<String> changes)
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Execute;
Expand Down Expand Up @@ -197,7 +197,7 @@ public void configureScanner() throws MojoExecutionException
configureScanTargetPatterns(scanner);
scanner.addListener(new Scanner.BulkListener()
{
public void filesChanged(List<String> changes)
public void filesChanged(Set<String> changes)
{
try
{
Expand Down
Loading

0 comments on commit 0eccdde

Please sign in to comment.