@Test public void abstractServiceClass() { String className = AbstractListWithPublicConstructor.class.getName(); ServiceLoader<?> loader = new ServiceLoader<>(List.class); assertThat(loader.create(className)).isNull(); assertThat(systemStream.consumeErrorOutput()).contains("ERROR").containsOnlyOnce(className); }
public T create(final String name, final Object... arguments) { if (name.indexOf('.') == -1) { String expectingClassName = toSimpleClassName(name); for (String className : classes) { int split = className.lastIndexOf('.'); String simpleClassName = split == -1 ? className : className.substring(split + 1); if (expectingClassName.equals(simpleClassName)) { return createInstance(className, arguments); } } InternalLogger.log(Level.ERROR, "Service implementation '" + name + "' not found"); return null; } else { return createInstance(name, arguments); } }
ServiceLoader { public T create(final String name, final Object... arguments) { if (name.indexOf('.') == -1) { String expectingClassName = toSimpleClassName(name); for (String className : classes) { int split = className.lastIndexOf('.'); String simpleClassName = split == -1 ? className : className.substring(split + 1); if (expectingClassName.equals(simpleClassName)) { return createInstance(className, arguments); } } InternalLogger.log(Level.ERROR, "Service implementation '" + name + "' not found"); return null; } else { return createInstance(name, arguments); } } }
ServiceLoader { public T create(final String name, final Object... arguments) { if (name.indexOf('.') == -1) { String expectingClassName = toSimpleClassName(name); for (String className : classes) { int split = className.lastIndexOf('.'); String simpleClassName = split == -1 ? className : className.substring(split + 1); if (expectingClassName.equals(simpleClassName)) { return createInstance(className, arguments); } } InternalLogger.log(Level.ERROR, "Service implementation '" + name + "' not found"); return null; } else { return createInstance(name, arguments); } } ServiceLoader(final Class<? extends T> service, final Class<?>... argumentTypes); }
ServiceLoader { public T create(final String name, final Object... arguments) { if (name.indexOf('.') == -1) { String expectingClassName = toSimpleClassName(name); for (String className : classes) { int split = className.lastIndexOf('.'); String simpleClassName = split == -1 ? className : className.substring(split + 1); if (expectingClassName.equals(simpleClassName)) { return createInstance(className, arguments); } } InternalLogger.log(Level.ERROR, "Service implementation '" + name + "' not found"); return null; } else { return createInstance(name, arguments); } } ServiceLoader(final Class<? extends T> service, final Class<?>... argumentTypes); T create(final String name, final Object... arguments); List<T> createList(final String list); Collection<T> createAll(final Object... arguments); String toSimpleClassName(final String name); }
ServiceLoader { public T create(final String name, final Object... arguments) { if (name.indexOf('.') == -1) { String expectingClassName = toSimpleClassName(name); for (String className : classes) { int split = className.lastIndexOf('.'); String simpleClassName = split == -1 ? className : className.substring(split + 1); if (expectingClassName.equals(simpleClassName)) { return createInstance(className, arguments); } } InternalLogger.log(Level.ERROR, "Service implementation '" + name + "' not found"); return null; } else { return createInstance(name, arguments); } } ServiceLoader(final Class<? extends T> service, final Class<?>... argumentTypes); T create(final String name, final Object... arguments); List<T> createList(final String list); Collection<T> createAll(final Object... arguments); String toSimpleClassName(final String name);  }