private ExtensibleURLStreamHandlerFactory() { this.handlerMap = Util.lookupServiceList(org.eclipse.fx.core.URLStreamHandler.class).stream().collect(Collectors.toMap(h -> h.getProtocol(), h -> h)); }
/** * Convert an URL to a path on the local filesystem * * @param url * the url * @return the path * @since 2.2.0 */ public static Optional<URL> getLocalURL(@NonNull URL url) { return lookupServiceList(URLResolver.class) .stream() .filter(r -> r.test(url)).findFirst() .map(r -> r.resolveToLocalURL(url)); }
@SuppressWarnings("null") @Override public DecorationStrategy convert(ParsedValue<ParsedValue<?, DecorationStrategy>, DecorationStrategy> value, Font font) { String definition = value.getValue() + ""; //$NON-NLS-1$ if (FACTORIES == null) { FACTORIES = Util.lookupServiceList(getClass(), DecorationStrategyFactory.class).stream().sorted((f1, f2) -> -1 * Integer.compare(f1.getRanking(), f2.getRanking())).collect(Collectors.toMap(f -> f.getDecorationStrategyName(), f -> f)); } String type; if (definition.contains("(")) { //$NON-NLS-1$ type = definition.substring(0, definition.indexOf('(')); } else { type = definition + ""; //$NON-NLS-1$ } DecorationStrategyFactory strategy = FACTORIES.get(type); if (strategy != null) { return strategy.create(definition.contains("(") ? definition.substring(definition.indexOf('(') + 1, definition.lastIndexOf(')')) : null); //$NON-NLS-1$ } return null; } }
/** * Get a provider for the given font * * @param font * the font * @return the provider */ public static IconFontProvider getProviderForFont(Font font) { // System.err.println("getProviderForFontSPI " + font); IconFontProvider result = null; Iterator<IconFontProvider> it = Util.lookupServiceList(IconFontProvider.class).iterator(); while (it.hasNext()) { IconFontProvider sup = it.next(); if (sup.getName().equals(font.getName())) { result = sup; break; } } // System.err.println("getProviderForFontSPI => " + result); return result; } }
@SuppressWarnings("null") @Override public DecorationStrategy convert(ParsedValue<ParsedValue<?, DecorationStrategy>, DecorationStrategy> value, Font font) { String definition = value.getValue() + ""; //$NON-NLS-1$ if (FACTORIES == null) { FACTORIES = Util.lookupServiceList(getClass(), DecorationStrategyFactory.class).stream().sorted((f1, f2) -> -1 * Integer.compare(f1.getRanking(), f2.getRanking())).collect(Collectors.toMap(f -> f.getDecorationStrategyName(), f -> f)); } String type; if (definition.contains("(")) { //$NON-NLS-1$ type = definition.substring(0, definition.indexOf('(')); } else { type = definition + ""; //$NON-NLS-1$ } DecorationStrategyFactory strategy = FACTORIES.get(type); if (strategy != null) { return strategy.create(definition.contains("(") ? definition.substring(definition.indexOf('(') + 1, definition.lastIndexOf(')')) : null); //$NON-NLS-1$ } return null; } }
/** * Convert an URL to a path on the local filesystem * * @param url * the url * @param copyIfNeeded * <code>true</code> if the url can not be converted to a local * the content is copied to the local filesystem * @return the path * @since 2.2.0 */ public static Optional<Resource<@NonNull Path>> getLocalPath(@NonNull URL url, boolean copyIfNeeded) { return lookupServiceList(URLResolver.class) .stream() .filter(r -> r.test(url)).findFirst() .map(r -> Optional.of(Resource.createResource(r.resolveToLocalPath(url)))) .orElseGet(() -> copyIfNeeded ? ExExecutor.executeSupplier( () -> Util.copyToTempFile(url), "Unable to copy resource") : Optional.empty()); //$NON-NLS-1$ }
} , (v) -> v.toInstant().toString())); if (!Util.isOsgiEnv()) { Map<Class<?>, TwoVal<?>> collect = Util.lookupServiceList(ValueSerializeProvider.class).stream() .collect(Collectors.toMap(p -> p.getType(), p -> new TwoVal<>(p::fromString, p::toString))); this.mappings.putAll(collect);
case AT_LEAST_ONE: case MULTIPLE: { List<?> list = Util.lookupServiceList(serviceInterface); if (cardinality == ReferenceCardinality.AT_LEAST_ONE && list.isEmpty()) { logError("Unsatisfied dependency '"+r.getIface()+"'. There must be at least one component providing this service", null); //$NON-NLS-1$//$NON-NLS-2$