Example usage for java.util ServiceConfigurationError getMessage

List of usage examples for java.util ServiceConfigurationError getMessage

Introduction

In this page you can find the example usage for java.util ServiceConfigurationError getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.pentaho.pms.mql.dialect.SQLDialectFactory.java

/**
 * Load and register dialects defined as service providers implementing {@link SQLDialectInterface} (via Java's
 * ServiceLoader mechanism)./*from  w  ww.j av  a 2 s . com*/
 */
private void loadDialectPlugins() {
    ServiceLoader<SQLDialectInterface> dialects = ServiceLoader.load(SQLDialectInterface.class);
    Iterator<SQLDialectInterface> dialectIter = dialects.iterator();
    while (dialectIter.hasNext()) {
        SQLDialectInterface dialect = null;
        try {
            dialect = dialectIter.next(); // Try to instantiate the next dialect
        } catch (ServiceConfigurationError err) {
            // Log an error if dialect instantiation/registration fails for any other reason. We don't know the dialect
            // we attempted to load here so log it as a generic error with stack trace.
            logger.warn(Messages.getErrorString("SQLDialectFactory.WARN_0001_DIALECT_COULD_NOT_BE_LOADED", //$NON-NLS-1$
                    err.getMessage()));
            if (logger.isDebugEnabled()) {
                logger.debug(Messages.getErrorString("SQLDialectFactory.WARN_0001_DIALECT_COULD_NOT_BE_LOADED", //$NON-NLS-1$
                        err.getMessage()), err);
            }
        }
        if (dialect != null) {
            addDialect(dialect);
        }
    }
}

From source file:org.sikuli.scriptrunner.ScriptRunner.java

public static void initScriptingSupport() {
    if (isReady) {
        return;// w w  w.j av a  2  s .c om
    }
    log(lvl, "initScriptingSupport: enter");
    if (scriptRunner.isEmpty()) {
        EndingTypes.put("py", CPYTHON);
        EndingTypes.put("rb", CRUBY);
        EndingTypes.put("txt", CPLAIN);
        for (String k : EndingTypes.keySet()) {
            typeEndings.put(EndingTypes.get(k), k);
        }
        ServiceLoader<IScriptRunner> rloader = ServiceLoader.load(IScriptRunner.class);
        Iterator<IScriptRunner> rIterator = rloader.iterator();
        while (rIterator.hasNext()) {
            IScriptRunner current = null;
            try {
                current = rIterator.next();
            } catch (ServiceConfigurationError e) {
                log(lvl, "initScriptingSupport: warning: %s", e.getMessage());
                continue;
            }
            String name = current.getName();
            if (name != null && !name.startsWith("Not")) {
                scriptRunner.put(name, current);
                current.init(null);
                log(lvl, "initScriptingSupport: added: %s", name);
            }
        }
    }
    if (scriptRunner.isEmpty()) {
        Debug.error("Settings: No scripting support available. Rerun Setup!");
        String em = "Terminating: No scripting support available. Rerun Setup!";
        log(-1, em);
        if (Settings.isRunningIDE) {
            Sikulix.popError(em, "IDE has problems ...");
        }
        System.exit(1);
    } else {
        RDEFAULT = (String) scriptRunner.keySet().toArray()[0];
        EDEFAULT = scriptRunner.get(RDEFAULT).getFileEndings()[0];
        for (IScriptRunner r : scriptRunner.values()) {
            for (String e : r.getFileEndings()) {
                if (!supportedRunner.containsKey(EndingTypes.get(e))) {
                    supportedRunner.put(EndingTypes.get(e), r);
                }
            }
        }
    }
    log(lvl, "initScriptingSupport: exit with defaultrunner: %s (%s)", RDEFAULT, EDEFAULT);
    isReady = true;
}