Java 8 ServiceLoader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ServiceLoader class.

This code example shows how to use the following methods:iterator
 */ 
public class ServiceFactoryBean extends AbstractServiceLoaderBasedFactoryBean implements BeanClassLoaderAware {
 
	@Override 
	protected Object getObjectToExpose(ServiceLoader<?> serviceLoader) {
		Iterator<?> it = serviceLoader.iterator();
		if (!it.hasNext()) {
			throw new IllegalStateException(
					"ServiceLoader could not find service for type [" + getServiceType() + "]"); 
		} 
		return it.next();
	} 
 
	@Override 
	public Class<?> getObjectType() {
		return getServiceType(); 
	} 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:iterator, reload
		LOGGER.debug("got serviceLoader: " + this.serviceLoader);
	} 
 
	@Override 
	public Iterator<JDIPlugin> getPlugins() {
		this.serviceLoader.reload();
		return this.serviceLoader.iterator();
	} 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:iterator
public class ServerSerializerFactory { 
 
    private static ServiceLoader<ServerSerializer> loader = ServiceLoader.load(ServerSerializer.class);
 
    public static Iterator<ServerSerializer> getSerializers() {
        return loader.iterator();
    } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:iterator
     * Returns an Iterator for all instances of the CachedWebDataSource interface. 
     * 
     * @return an iterator of CachedWebDataSource. 
     */ 
    public Iterator<CachedWebDataSource> getDataSources() {
        return loader.iterator();
    } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:iterator
     * Returns an Iterator for all instances of the Analyzer interface. 
     * 
     * @return an iterator of Analyzers. 
     */ 
    public Iterator<Analyzer> getAnalyzers() {
        return loader.iterator();
    } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:iterator
        this.serviceLoader = serviceLoader;
    } 
 
    @Override 
    public Iterator iterator() {
        return new ProviderIterator(serviceLoader.iterator());
    } 
 
    private static class ProviderIterator<T> implements Iterator<T> {
 
        private final Iterator<T> itr;
 
        private T next;
 
        private ProviderIterator(Iterator<T> itr) {
            this.itr = itr;
            setNext(); 
        } 
 
        @Override 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:iterator
        if (defaultFactory != null) {
            return (HashCharShortMapFactory/*<>*/) defaultFactory;
        } else { 
            // synchronization? 
            return (HashCharShortMapFactory/*<>*/) 
                    (defaultFactory = LOADER.iterator().next());
        } 
    } 
 
    /* define ek */ 
    /* if obj key //? extends K// elif !(obj key) //Character// endif */ 
    /* enddefine */ 
 
    /* define ev */ 
    /* if obj value //? extends V// elif !(obj value) //Short// endif */ 
    /* enddefine */ 
 
    /* define ep //<// ek //, // ev //>// enddefine */ 
 
    /* define typeParams // 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:iterator
Service service = null;
 
        try 
        { 
            Iterator<Service> services = loader.iterator();
            while (service == null && services.hasNext())
            { 
                Service serve = services.next();
                if (accepts(serve, serviceType))
                { 
                    LOG.info("found service: " + serve);
                    service = serve;
                } 
            } 
        } 
        catch (ServiceConfigurationError e)
        { 
            LOG.error("Configuration Error will searching for service:" + e.getMessage(), e);
            throw new FailJobException("exception occured while trying to find a service for " 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:iterator
 */ 
public class ServiceFactoryBean extends AbstractServiceLoaderBasedFactoryBean implements BeanClassLoaderAware { 
 
	@Override 
	protected Object getObjectToExpose(ServiceLoader serviceLoader) {
		Iterator it = serviceLoader.iterator();
		if (!it.hasNext()) {
			throw new IllegalStateException(
					"ServiceLoader could not find service for type [" + getServiceType() + "]"); 
		} 
		return it.next();
	} 
 
	@Override 
	public Class getObjectType() {
		return getServiceType(); 
	} 
 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:toString
        } 
 
        serviceLoader = ServiceLoader.loadInstalled(null);
        assertNotNull(serviceLoader);
        try { 
            serviceLoader.toString();
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected 
        } 
    } 
 
    /** 
     * @see junit.framework.TestCase#setUp() 
     */ 
    @SuppressWarnings("nls") 
    @Override 
    protected void setUp() throws Exception { 
        super.setUp(); 
        jarFile = prepairJar("hyts_services.jar");
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 ServiceLoader Methods: