Search in sources :

Example 1 with JarScannerCallback

use of org.apache.tomcat.JarScannerCallback in project sonarqube by SonarSource.

the class NullJarScannerTest method does_nothing.

@Test
public void does_nothing() {
    ServletContext context = mock(ServletContext.class);
    JarScannerCallback callback = mock(JarScannerCallback.class);
    NullJarScanner scanner = new NullJarScanner();
    scanner.scan(JarScanType.PLUGGABILITY, context, callback);
    verifyZeroInteractions(context, callback);
    scanner.setJarScanFilter(mock(JarScanFilter.class));
    assertThat(scanner.getJarScanFilter()).isNull();
}
Also used : JarScannerCallback(org.apache.tomcat.JarScannerCallback) ServletContext(javax.servlet.ServletContext) JarScanFilter(org.apache.tomcat.JarScanFilter) Test(org.junit.Test)

Example 2 with JarScannerCallback

use of org.apache.tomcat.JarScannerCallback in project tomee by apache.

the class TomEEJarScanner method doScan.

private void doScan(final JarScanType scanType, final JarScannerCallback callback, final Deque<URL> urls) {
    Method process = null;
    final boolean scanAllDirectories = isScanAllDirectories();
    for (final URL url : urls) {
        final File cpe = URLs.toFile(url);
        if ((cpe.getName().endsWith(".jar") || scanType == JarScanType.PLUGGABILITY || scanAllDirectories) && getJarScanFilter().check(scanType, cpe.getName())) {
            try {
                if (process == null) {
                    process = StandardJarScanner.class.getDeclaredMethod("process", JarScanType.class, JarScannerCallback.class, URL.class, String.class, boolean.class, Deque.class);
                    if (!process.isAccessible()) {
                        process.setAccessible(true);
                    }
                }
                process.invoke(this, scanType, callback, url, null, true, urls);
            } catch (final Exception ioe) {
            // no-op
            }
        }
    }
}
Also used : JarScannerCallback(org.apache.tomcat.JarScannerCallback) StandardJarScanner(org.apache.tomcat.util.scan.StandardJarScanner) Method(java.lang.reflect.Method) File(java.io.File) JarScanType(org.apache.tomcat.JarScanType) Deque(java.util.Deque) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

JarScannerCallback (org.apache.tomcat.JarScannerCallback)2 File (java.io.File)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Deque (java.util.Deque)1 ServletContext (javax.servlet.ServletContext)1 JarScanFilter (org.apache.tomcat.JarScanFilter)1 JarScanType (org.apache.tomcat.JarScanType)1 StandardJarScanner (org.apache.tomcat.util.scan.StandardJarScanner)1 Test (org.junit.Test)1