Example usage for org.apache.shiro.io ResourceUtils resourceExists

List of usage examples for org.apache.shiro.io ResourceUtils resourceExists

Introduction

In this page you can find the example usage for org.apache.shiro.io ResourceUtils resourceExists.

Prototype

public static boolean resourceExists(String resourcePath) 

Source Link

Document

Returns true if the resource at the specified path exists, false otherwise.

Usage

From source file:org.apache.activemq.shiro.env.IniEnvironment.java

License:Apache License

@Override
public void init() throws ShiroException {
    //this.environment and this.securityManager are null.  Try Ini config:
    Ini ini = this.ini;
    if (ini != null) {
        apply(ini);//from ww  w  .java 2  s. c o  m
    }

    if (this.objects.isEmpty() && this.iniConfig != null) {
        ini = new Ini();
        ini.load(this.iniConfig);
        apply(ini);
    }

    if (this.objects.isEmpty() && this.iniResourePath != null) {
        ini = new Ini();
        ini.loadFromPath(this.iniResourePath);
        apply(ini);
    }

    if (this.objects.isEmpty()) {
        if (ResourceUtils.resourceExists("classpath:shiro.ini")) {
            ini = new Ini();
            ini.loadFromPath("classpath:shiro.ini");
            apply(ini);
        }
    }

    if (this.objects.isEmpty()) {
        String msg = "Configuration error.  All heuristics for acquiring Shiro INI config "
                + "have been exhausted.  Ensure you configure one of the following properties: "
                + "1) ini 2) iniConfig 3) iniResourcePath and the Ini sections are not empty.";
        throw new ConfigurationException(msg);
    }

    LifecycleUtils.init(this.objects.values());
}