ch.qos.logback.core.util.Loader Java Examples

The following examples show how to use ch.qos.logback.core.util.Loader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KonkerContextInitializer.java    From konker-platform with Apache License 2.0 6 votes vote down vote up
private void multiplicityWarning(String resourceName, ClassLoader classLoader) {
    Set urlSet = null;
    StatusManager sm = this.loggerContext.getStatusManager();

    try {
        urlSet = Loader.getResourceOccurrenceCount(resourceName, classLoader);
    } catch (IOException var7) {
        sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + ']', this.loggerContext, var7));
    }

    if (urlSet != null && urlSet.size() > 1) {
        sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.", this.loggerContext));
        Iterator i$ = urlSet.iterator();

        while (i$.hasNext()) {
            URL url = (URL) i$.next();
            sm.add(new WarnStatus("Resource [" + resourceName + "] occurs at [" + url + ']', this.loggerContext));
        }
    }

}
 
Example #2
Source File: ContextInitializer.java    From stategen with GNU Affero General Public License v3.0 5 votes vote down vote up
public URL findURLOfDefaultConfigurationFile(boolean updateStatus) throws IOException {
    StatusManager sm = loggerContext.getStatusManager();
    ClassLoader myClassLoader = Loader.getClassLoaderOfObject(this);
    URL url = null;
    url = loadURLFormPropertiesFile(myClassLoader, updateStatus);
    if (url != null) {
        sm.add(new InfoStatus("装载文件:"+url, loggerContext) );
        return url;
    }
    sm.add(new ErrorStatus("从"+application_properties+" 装载文件不成功,不存在!", loggerContext) );

    url = findConfigFileURLFromSystemProperties(myClassLoader, updateStatus);
    if (url != null) {
        return url;
    }

    url = getResource(GROOVY_AUTOCONFIG_FILE, myClassLoader, updateStatus);
    if (url != null) {
        return url;
    }

    url = getResource(TEST_AUTOCONFIG_FILE, myClassLoader, updateStatus);
    if (url != null) {
        return url;
    }

    url = getResource(AUTOCONFIG_FILE, myClassLoader, updateStatus);
    sm.add(new InfoStatus(""+url, loggerContext) );
    return url;
}
 
Example #3
Source File: ContextInitializer.java    From stategen with GNU Affero General Public License v3.0 5 votes vote down vote up
private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
    URL url = Loader.getResource(filename, myClassLoader);
    if (updateStatus) {
        statusOnResourceSearch(filename, myClassLoader, url);
    }
    return url;
}
 
Example #4
Source File: ContextInitializer.java    From stategen with GNU Affero General Public License v3.0 5 votes vote down vote up
private void multiplicityWarning(String resourceName, ClassLoader classLoader) {
    Set<URL> urlSet = null;
    StatusManager sm = loggerContext.getStatusManager();
    try {
        urlSet = Loader.getResources(resourceName, classLoader);
    } catch (IOException e) {
        sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]", loggerContext, e));
    }
    if (urlSet != null && urlSet.size() > 1) {
        sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.", loggerContext));
        for (URL url : urlSet) {
            sm.add(new WarnStatus("Resource [" + resourceName + "] occurs at [" + url.toString() + "]", loggerContext));
        }
    }
}
 
Example #5
Source File: KonkerContextInitializer.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
public URL findURLOfDefaultConfigurationFile(boolean updateStatus) {
    ClassLoader myClassLoader = Loader.getClassLoaderOfObject(this);
    URL url = this.findConfigFileURLFromSystemProperties(myClassLoader, updateStatus);
    if (url != null) {
        return url;
    } else {
        url = this.getResource("logback.groovy", myClassLoader, updateStatus);
        if (url != null) {
            return url;
        } else {
            url = this.getResource("logback-test.xml", myClassLoader, updateStatus);
            return url != null ? url : this.getResource("logback.xml", myClassLoader, updateStatus);
        }
    }
}
 
Example #6
Source File: KonkerContextInitializer.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
    URL url = Loader.getResource(filename, myClassLoader);
    if (updateStatus) {
        this.statusOnResourceSearch(filename, myClassLoader, url);
    }

    return url;
}
 
Example #7
Source File: LogbackConfigurator.java    From cuba with Apache License 2.0 5 votes vote down vote up
public URL findURLOfConfigurationFile(boolean updateStatus) {
    ClassLoader myClassLoader = Loader.getClassLoaderOfObject(this);
    URL url = findConfigFileUrlInAppHome(myClassLoader, updateStatus);
    if (url != null) {
        return url;
    }
    return getResource(DEFAULT_CLASSPATH_CONFIG, myClassLoader, updateStatus);
}
 
Example #8
Source File: LogbackConfigurator.java    From cuba with Apache License 2.0 5 votes vote down vote up
private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
    URL url = Loader.getResource(filename, myClassLoader);
    if (updateStatus) {
        statusOnResourceSearch(filename, myClassLoader, url);
    }
    return url;
}
 
Example #9
Source File: LogbackConfigurator.java    From cuba with Apache License 2.0 5 votes vote down vote up
private void multiplicityWarning(String resourceName, ClassLoader classLoader) {
    Set<URL> urlSet = null;
    try {
        urlSet = Loader.getResources(resourceName, classLoader);
    } catch (IOException e) {
        printError("Failed to get url list for resource [" + resourceName + "]");
    }
    if (urlSet != null && urlSet.size() > 1) {
        printError("Resource [" + resourceName + "] occurs multiple times on the classpath.");
        for (URL url : urlSet) {
            printInfo("Resource [" + resourceName + "] occurs at [" + url.toString() + "]");
        }
    }
}
 
Example #10
Source File: ResourceExistsPropertyDefiner.java    From lemon with Apache License 2.0 5 votes vote down vote up
public String getPropertyValue() {
    if (path == null) {
        return "false";
    }

    URL resourceURL = Loader.getResourceBySelfClassLoader(path);

    return (resourceURL != null) ? "true" : "false";
}
 
Example #11
Source File: LogSetting.java    From ns4_frame with Apache License 2.0 4 votes vote down vote up
private URL getResource(String filename, ClassLoader myClassLoader) {
    URL url = Loader.getResource(filename, myClassLoader);
    return url;
}
 
Example #12
Source File: NsLog.java    From ns4_frame with Apache License 2.0 4 votes vote down vote up
private static URL getResource(String filename, ClassLoader myClassLoader) {
    URL url = Loader.getResource(filename, myClassLoader);
    return url;
}
 
Example #13
Source File: KonkerSelectorStaticBinder.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
static KonkerDefaultContextSelector dynamicalContextSelector(KonkerLoggerContext defaultLoggerContext, String contextSelectorStr) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
    Class contextSelectorClass = Loader.loadClass(contextSelectorStr);
    Constructor cons = contextSelectorClass.getConstructor(new Class[]{LoggerContext.class});
    return (KonkerDefaultContextSelector) cons.newInstance(new Object[]{defaultLoggerContext});
}