Search in sources :

Example 1 with FastClasspathScanner

use of io.github.lukehutch.fastclasspathscanner.FastClasspathScanner in project uavstack by uavorg.

the class WebServiceListener method doInstallDProxy.

public void doInstallDProxy(ClassLoader webapploader, final String appid, String contextPath) {
    // like SMS, which uses the sun jax-ws RI/Metro-jax-ws RI bind webservices when the servlet starts should
    // profile in ComponentProfileHandler
    FastClasspathScanner fcs = new FastClasspathScanner(new ClassLoader[] { webapploader });
    fcs.scan();
    List<String> endPoints = fcs.getNamesOfDirectSubclassesOf("javax.xml.ws.Endpoint");
    if (!endPoints.isEmpty()) {
        dpInstall.setTargetClassLoader(webapploader);
        for (int i = 0; i < endPoints.size(); i++) {
            dpInstall.installProxy(endPoints.get(i), new String[] { "com.creditease.uav.monitorframework.webservice.interceptors" }, new DynamicProxyProcessor() {

                @Override
                public void process(DPMethod m) throws Exception {
                    if ("publish".equals(m.getName()) && m.getParameterTypes().length > 0 && m.getParameterTypes()[0].getSimpleName().equals("String")) {
                        dpInstall.defineLocalVal(m, "mObj", WebServiceListenerIT.class);
                        m.insertBefore("{mObj=new WebServiceListenerIT(\"" + appid + "\");mObj.obtainWsInfo($1,getImplementor());}");
                    }
                }
            }, false);
        }
        // release loader
        dpInstall.releaseTargetClassLoader();
    }
}
Also used : DPMethod(com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod) FastClasspathScanner(io.github.lukehutch.fastclasspathscanner.FastClasspathScanner) DynamicProxyProcessor(com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor) WebServiceListenerIT(com.creditease.uav.monitorframework.webservice.interceptors.WebServiceListenerIT)

Example 2 with FastClasspathScanner

use of io.github.lukehutch.fastclasspathscanner.FastClasspathScanner in project Orchid by JavaEden.

the class Orchid method findOptions.

public static List<OrchidOption> findOptions() {
    if (Orchid.orchidOptions == null) {
        Orchid.orchidOptions = new ArrayList<>();
        FastClasspathScanner scanner = new FastClasspathScanner();
        scanner.matchSubclassesOf(OrchidOption.class, (matchingClass) -> {
            try {
                OrchidOption option = matchingClass.newInstance();
                if (option != null) {
                    Orchid.orchidOptions.add(option);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        scanner.scan();
    }
    return Orchid.orchidOptions;
}
Also used : FastClasspathScanner(io.github.lukehutch.fastclasspathscanner.FastClasspathScanner) OrchidOption(com.eden.orchid.api.options.OrchidOption)

Example 3 with FastClasspathScanner

use of io.github.lukehutch.fastclasspathscanner.FastClasspathScanner in project Orchid by JavaEden.

the class Orchid method findModules.

public static List<AbstractModule> findModules(Map<String, String[]> options) {
    if (Orchid.modules == null) {
        Orchid.modules = new ArrayList<>();
        FastClasspathScanner scanner = new FastClasspathScanner();
        scanner.matchSubclassesOf(OrchidModule.class, (matchingClass) -> {
            try {
                AbstractModule provider = matchingClass.newInstance();
                if (provider != null) {
                    Orchid.modules.add(provider);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        scanner.scan();
    }
    return Orchid.modules;
}
Also used : FastClasspathScanner(io.github.lukehutch.fastclasspathscanner.FastClasspathScanner) AbstractModule(com.google.inject.AbstractModule)

Example 4 with FastClasspathScanner

use of io.github.lukehutch.fastclasspathscanner.FastClasspathScanner in project typescript-generator by vojtechhabarta.

the class InputTest method testScanner.

@Test
public void testScanner() {
    final ScanResult scanResult = new FastClasspathScanner().scan();
    final List<String> allClassNames = scanResult.getNamesOfAllClasses();
    final List<String> testClassNames = Input.filterClassNames(allClassNames, Arrays.asList("cz.habarta.typescript.generator.**Test"));
    Assert.assertTrue("Typescript-generator must have at least 20 tests :-)", testClassNames.size() > 20);
}
Also used : ScanResult(io.github.lukehutch.fastclasspathscanner.scanner.ScanResult) FastClasspathScanner(io.github.lukehutch.fastclasspathscanner.FastClasspathScanner) Test(org.junit.Test)

Example 5 with FastClasspathScanner

use of io.github.lukehutch.fastclasspathscanner.FastClasspathScanner in project geode by apache.

the class DeployedJar method findFunctionsInThisJar.

private List<String> findFunctionsInThisJar() throws IOException {
    URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { this.getFile().getCanonicalFile().toURL() });
    FastClasspathScanner fastClasspathScanner = new FastClasspathScanner().removeTemporaryFilesAfterScan(true).overrideClassLoaders(urlClassLoader);
    ScanResult scanResult = fastClasspathScanner.scan();
    return scanResult.getNamesOfClassesImplementing(Function.class);
}
Also used : FastClasspathScanner(io.github.lukehutch.fastclasspathscanner.FastClasspathScanner) ScanResult(io.github.lukehutch.fastclasspathscanner.scanner.ScanResult) URLClassLoader(java.net.URLClassLoader)

Aggregations

FastClasspathScanner (io.github.lukehutch.fastclasspathscanner.FastClasspathScanner)13 ScanResult (io.github.lukehutch.fastclasspathscanner.scanner.ScanResult)3 UAVServer (com.creditease.monitor.UAVServer)2 InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)2 ProfileElementInstance (com.creditease.uav.profiling.spi.ProfileElementInstance)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ServerVendor (com.creditease.monitor.UAVServer.ServerVendor)1 DynamicProxyProcessor (com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)1 DPMethod (com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod)1 WebServiceListenerIT (com.creditease.uav.monitorframework.webservice.interceptors.WebServiceListenerIT)1 OrchidOption (com.eden.orchid.api.options.OrchidOption)1 AbstractModule (com.google.inject.AbstractModule)1 Provides (com.google.inject.Provides)1 Named (com.google.inject.name.Named)1 ClassAnnotationMatchProcessor (io.github.lukehutch.fastclasspathscanner.matchprocessor.ClassAnnotationMatchProcessor)1 PrintWriter (java.io.PrintWriter)1 Executable (java.lang.reflect.Executable)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1