/** * OSX contains file:// resources on the classpath including .mar and .jnilib files. * <p> * Reflections use of Vfs doesn't recognize these URLs and logs warns when it sees them. By registering those file * endings, we supress the warns. */ public static void registerUrlTypes() { final List<Vfs.UrlType> urlTypes = Lists.newArrayList(); // include a list of file extensions / filenames to be recognized urlTypes.add(new EmptyIfFileEndingsUrlType(".mar", ".jnilib")); urlTypes.addAll(Arrays.asList(Vfs.DefaultUrlTypes.values())); Vfs.setDefaultURLTypes(urlTypes); }
public static void registerUrlTypes() { final List<UrlType> urlTypes = new LinkedList<>(); urlTypes.add(new EmptyUrlType(ENDINGS)); urlTypes.addAll(Arrays.asList(Vfs.DefaultUrlTypes.values())); Vfs.setDefaultURLTypes(urlTypes); }
/** * OSX contains file:// resources on the classpath including .mar and .jnilib files. * * Reflections use of Vfs doesn't recognize these URLs and logs warns when it sees them. By registering those file endings, we suppress the warns. */ public static void registerUrlTypes() { final List<Vfs.UrlType> urlTypes = Lists.newArrayList(); // include a list of file extensions / filenames to be recognized urlTypes.add(new EmptyIfFileEndingsUrlType(".mar", ".jnilib", ".so", ".dll")); urlTypes.addAll(Arrays.asList(Vfs.DefaultUrlTypes.values())); Vfs.setDefaultURLTypes(urlTypes); }
@Programmatic @Override public <T> Set<Class<? extends T>> findSubTypesOfClasses(Class<T> type) { Vfs.setDefaultURLTypes(getUrlTypes()); final Reflections reflections = new Reflections( ClasspathHelper.forClassLoader(Thread.currentThread().getContextClassLoader()), ClasspathHelper.forClass(Object.class), new SubTypesScanner(false) ); return reflections.getSubTypesOf(type); }
private synchronized Kernel createKernel(KernelConfiguration kernelConfiguration, DiagnosticManager diagnosticManager) { // Kernel instantiation Kernel kernel = NuunCore.createKernel(kernelConfiguration); FallbackUrlType fallbackUrlType = new FallbackUrlType(); List<Vfs.UrlType> urlTypes = new ArrayList<>(detectedUrlTypes); urlTypes.add(fallbackUrlType); LOGGER.debug("Registered URL types for classpath scan: " + urlTypes); // Kernel initialization (it is assumed that only this class alter Vfs default url types) Vfs.setDefaultURLTypes(urlTypes); kernel.init(); Vfs.setDefaultURLTypes(savedUrlTypes); // Log if any URL were not scanned int failedUrlCount = fallbackUrlType.getFailedUrls().size(); if (failedUrlCount > 0) { for (String failedUrl : fallbackUrlType.getFailedUrls()) { LOGGER.warn("URL not scanned: {}", failedUrl); } } diagnosticManager.registerDiagnosticInfoCollector("kernel", () -> { Map<String, Object> result = new HashMap<>(); result.put("scannedUrls", kernel.scannedURLs()); result.put("failedUrls", fallbackUrlType.getFailedUrls()); return result; }); return kernel; }
Iterables.addAll(moduleAndFrameworkPackages, modulePackages); Vfs.setDefaultURLTypes(ClassDiscoveryServiceUsingReflections.getUrlTypes());
public void appendServices(final SortedMap<String, SortedSet<String>> positionedServices) { initIfRequired(); final List<String> packagePrefixList = asList(packagePrefixes); Set<Class<?>> domainServiceTypes = AppManifest.Registry.instance().getDomainServiceTypes(); if(domainServiceTypes == null) { // if no appManifest Vfs.setDefaultURLTypes(ClassDiscoveryServiceUsingReflections.getUrlTypes()); final Reflections reflections = new Reflections(packagePrefixList); domainServiceTypes = reflections.getTypesAnnotatedWith(DomainService.class); } final List<Class<?>> domainServiceClasses = Lists.newArrayList(Iterables.filter(domainServiceTypes, instantiatable())); for (final Class<?> cls : domainServiceClasses) { final String order = DomainServiceMenuOrder.orderOf(cls); // we want the class name in order to instantiate it // (and *not* the value of the @DomainServiceLayout(named=...) annotation attribute) final String fullyQualifiedClassName = cls.getName(); final String name = nameOf(cls); ServicesInstallerUtils.appendInPosition(positionedServices, order, fullyQualifiedClassName); } }
@Programmatic @Override public <T> Set<Class<? extends T>> findSubTypesOfClasses(Class<T> type, String packagePrefix) { if(type == FixtureScript.class) { Set fixtureScriptTypes = AppManifest.Registry.instance().getFixtureScriptTypes(); if (fixtureScriptTypes != null) { return fixtureScriptTypes; } } // no appManifest or not asking for FixtureScripts Vfs.setDefaultURLTypes(getUrlTypes()); final Reflections reflections = new Reflections( ClasspathHelper.forClassLoader(Thread.currentThread().getContextClassLoader()), ClasspathHelper.forClass(Object.class), ClasspathHelper.forPackage(packagePrefix), new SubTypesScanner(false) ); return reflections.getSubTypesOf(type); }