001/*******************************************************************************
002 * Copyright (c) 2017 Red Hat Inc
003 * All rights reserved. This program and the accompanying materials
004 * are made available under the terms of the Eclipse Public License v1.0
005 * which accompanies this distribution, and is available at
006 * http://www.eclipse.org/legal/epl-v10.html
007 *
008 * Contributors:
009 *     Jens Reimann - initial API and implementation
010 *******************************************************************************/
011package de.dentrassi.varlink;
012
013import java.nio.file.Path;
014import java.util.concurrent.CompletableFuture;
015
016import de.dentrassi.varlink.internal.VarlinkImpl;
017
018public interface Varlink extends AutoCloseable {
019
020    public static Varlink varlink() {
021        return new VarlinkImpl();
022    }
023
024    public <T> T newService(Class<T> clazz, String address);
025
026    public <T> T newService(Class<T> clazz, Path address);
027
028    public Resolver resolver();
029
030    public default <T> T resolveSync(final Class<T> clazz) {
031        return resolver().sync().resolve(clazz);
032    }
033
034    public default <T> CompletableFuture<T> resolveAsync(final Class<T> clazz) {
035        return resolver().async().resolve(clazz);
036    }
037
038}