All Downloads are FREE. Search and download functionalities are using the official Maven repository.

acscommons.io.jsonwebtoken.impl.lang.LegacyServices Maven / Gradle / Ivy

There is a newer version: 6.6.0
Show newest version
package acscommons.io.jsonwebtoken.impl.lang;

import acscommons.io.jsonwebtoken.lang.Classes;
import acscommons.io.jsonwebtoken.lang.UnknownClassException;

/**
 * A backward compatibility {@link Services} utility to help migrate away from {@link Classes#newInstance(String)}.
 * TODO: remove before v1.0
 * @deprecated use {@link Services} directly
 */
@Deprecated
public final class LegacyServices {

    /**
     * Wraps {@code Services.loadFirst} and throws a {@link UnknownClassException} instead of a
     * {@link UnavailableImplementationException} to retain the previous behavior. This method should be used when
     * to retain the previous behavior of methods that throw an unchecked UnknownClassException.
     */
    public static  T loadFirst(Class spi) {
        try {
            return Services.loadFirst(spi);
        } catch (UnavailableImplementationException e) {
            throw new UnknownClassException(e.getMessage(), e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy