Example usage for java.io File pathSeparator

List of usage examples for java.io File pathSeparator

Introduction

In this page you can find the example usage for java.io File pathSeparator.

Prototype

String pathSeparator

To view the source code for java.io File pathSeparator.

Click Source Link

Document

The system-dependent path-separator character, represented as a string for convenience.

Usage

From source file:org.apache.hive.hcatalog.templeton.tool.LaunchMapper.java

/**
 * {@link #copyLocal(String, org.apache.hadoop.conf.Configuration)} should be called before this
 * See {@link org.apache.hive.hcatalog.templeton.SqoopDelegator#makeBasicArgs(String, String, String, String, boolean, String)}
 * for more comments//ww w. ja  v  a  2  s.  co  m
 */
private static void handleSqoop(Configuration conf, Map<String, String> env) throws IOException {
    if (TempletonUtils.isset(conf.get(Sqoop.LIB_JARS))) {
        //LIB_JARS should only be set if Sqoop is auto-shipped
        LOG.debug(Sqoop.LIB_JARS + "=" + conf.get(Sqoop.LIB_JARS));
        String[] files = conf.getStrings(Sqoop.LIB_JARS);
        StringBuilder jdbcJars = new StringBuilder();
        for (String f : files) {
            jdbcJars.append(f).append(File.pathSeparator);
        }
        jdbcJars.setLength(jdbcJars.length() - 1);
        //this makes the jars available to Sqoop client
        prependPathToVariable(HADOOP_CLASSPATH, env, jdbcJars.toString());
    }
}

From source file:com.agileapes.couteau.maven.sample.task.CompileCodeTask.java

/**
 * This method will determine the classpath argument passed to the JavaC compiler used by this
 * implementation/*from  w w  w.j  av a 2s  .  c o  m*/
 * @return the classpath
 * @throws org.apache.maven.artifact.DependencyResolutionRequiredException if the resolution of classpath requires a prior
 * resolution of dependencies for the target project
 */
private String getClassPath(SampleExecutor executor) throws DependencyResolutionRequiredException {
    //Adding compile time dependencies for the project
    final List elements = executor.getProject().getCompileClasspathElements();
    final Set<File> classPathElements = new HashSet<File>();
    //noinspection unchecked
    classPathElements.addAll(elements);
    //Adding runtime dependencies available to the target project
    final ClassLoader loader = executor.getProjectClassLoader();
    URL[] urls = new URL[0];
    if (loader instanceof URLClassLoader) {
        urls = ((URLClassLoader) loader).getURLs();
    } else if (loader instanceof ConfigurableClassLoader) {
        urls = ((ConfigurableClassLoader) loader).getUrls();
    }
    for (URL url : urls) {
        try {
            final File file = new File(url.toURI());
            if (file.exists()) {
                classPathElements.add(file);
            }
        } catch (Throwable ignored) {
        }
    }
    //Adding dependency artifacts for the target project
    for (Object dependencyArtifact : executor.getProject().getDependencyArtifacts()) {
        if (!(dependencyArtifact instanceof DefaultArtifact)) {
            continue;
        }
        DefaultArtifact artifact = (DefaultArtifact) dependencyArtifact;
        if (artifact.getFile() != null) {
            classPathElements.add(artifact.getFile());
        }
    }
    return StringUtils.collectionToDelimitedString(classPathElements, File.pathSeparator);
}

From source file:org.jdag.launcher.JDAGLauncher.java

/**
 * CTOR/* w  w w . j a  v  a2 s  .  co  m*/
 */
@SuppressWarnings("static-access")
public JDAGLauncher(String[] args) {
    try {
        Option classPathFileOption = OptionBuilder.withDescription("<the file containing class path>").hasArg()
                .create(OPTION_JDAG_HOME);

        Options options = new Options();
        options.addOption(classPathFileOption);
        CommandLineParser commandLineParser = new GnuParser();
        CommandLine commandLine = commandLineParser.parse(options, args);

        if (!commandLine.hasOption(OPTION_JDAG_HOME)) {
            LOG.severe("The file containing class path is not specified" + " Hence aborting");
        }

        File libDir = new File(commandLine.getOptionValue(OPTION_JDAG_HOME) + File.separator + LIB_DIR);

        if (!libDir.exists()) {
            throw new RuntimeException("Not able to resolve the library directory" + " Please check "
                    + libDir.getAbsolutePath() + " exists");
        }

        File[] dependentLibraries = libDir.listFiles();
        if (dependentLibraries.length == 0) {
            throw new RuntimeException("Not able to locate dependent jars " + " in " + libDir);
        }

        StringBuilder builder = new StringBuilder();
        File confDir = new File(commandLine.getOptionValue(OPTION_JDAG_HOME) + File.separator + CONF_DIR);
        if (!confDir.exists()) {
            throw new RuntimeException(
                    "Unable to locate the conf directory" + "  " + confDir.getAbsolutePath());
        }
        builder.append(confDir.getAbsolutePath());
        for (File f : dependentLibraries) {
            builder.append(File.pathSeparator);
            builder.append(f.getAbsolutePath());
        }
        myClassPath = builder.toString();
        File f = new File(ClassLoader.getSystemClassLoader().getResource(TOPOLOGY_FILE).getFile());

        myTopologyConfiguration = new XMLConfiguration(f);

    } catch (ConfigurationException e) {
        LOG.log(Level.SEVERE, "Exception when loading the topology file", e);
        throw new RuntimeException(e);
    } catch (ParseException e) {
        LOG.log(Level.SEVERE, "Exception while parsing command line arguments", e);
        throw new RuntimeException(e);
    }
}

From source file:eu.udig.omsbox.core.OmsScriptExecutor.java

/**
 * Execute an OMS script./*from   w  w  w  .  j  a va 2s. c  o  m*/
 * 
 * @param script the script file or the script string.
 * @param internalStream
 * @param errorStream
 * @param loggerLevelGui the log level as presented in the GUI, can be OFF|ON. This is not the OMS logger level, which 
 *                              in stead has to be picked from the {@link OmsBoxConstants#LOGLEVELS_MAP}.
 * @param ramLevel the heap size to use in megabytes.
 * @return the process.
 * @throws Exception
 */
public Process exec(String script, final PrintStream internalStream, final PrintStream errorStream,
        String loggerLevelGui, String ramLevel) throws Exception {
    if (loggerLevelGui == null)
        loggerLevelGui = OmsBoxConstants.LOGLEVEL_GUI_OFF;

    File scriptFile = new File(script);
    if (!scriptFile.exists()) {
        // if the file doesn't exist, it is a script, let's put it into a file
        scriptFile = File.createTempFile("omsbox_script_", ".oms");
        BufferedWriter bw = null;
        try {
            bw = new BufferedWriter(new FileWriter(scriptFile));
            bw.write(script);
        } finally {
            bw.close();
        }

    } else {
        // it is a script in a file, read it to log it
        BufferedReader br = null;
        StringBuilder sb = new StringBuilder();
        try {
            br = new BufferedReader(new FileReader(scriptFile));
            String line = null;
            while ((line = br.readLine()) != null) {
                sb.append(line).append("\n");
            }
        } finally {
            br.close();
        }
        script = sb.toString();
    }

    // tmp folder
    String tempdir = System.getProperty("java.io.tmpdir");
    File omsTmp = new File(tempdir + File.separator + "oms");
    if (!omsTmp.exists())
        omsTmp.mkdirs();

    List<String> arguments = new ArrayList<String>();
    arguments.add(javaFile);

    // ram usage
    String ramExpr = "-Xmx" + ramLevel + "m";
    arguments.add(ramExpr);

    // modules jars
    List<String> modulesJars = OmsModulesManager.getInstance().getModulesJars();
    StringBuilder sb = new StringBuilder();
    for (String moduleJar : modulesJars) {
        sb.append(File.pathSeparator).append(moduleJar);
    }
    String modulesJarsString = sb.toString().replaceFirst(File.pathSeparator, "");
    String resourcesFlag = "-Doms.sim.resources=\"" + modulesJarsString + "\"";
    arguments.add(resourcesFlag);

    // grass gisbase
    String grassGisbase = OmsBoxPlugin.getDefault().getGisbasePreference();
    if (grassGisbase != null && grassGisbase.length() > 0) {
        arguments.add("-D" + OmsBoxConstants.GRASS_ENVIRONMENT_GISBASE_KEY + "=" + grassGisbase);
    }
    String grassShell = OmsBoxPlugin.getDefault().getShellPreference();
    if (grassShell != null && grassShell.length() > 0) {
        arguments.add("-D" + OmsBoxConstants.GRASS_ENVIRONMENT_SHELL_KEY + "=" + grassShell);
    }

    // all the arguments
    arguments.add("-cp");
    arguments.add(classPath);
    arguments.add(CLI.class.getCanonicalName());
    arguments.add("-r ");
    arguments.add("\"" + scriptFile.getAbsolutePath() + "\"");

    String homeDir = System.getProperty("java.io.tmpdir");
    File homeFile = new File(homeDir);
    StringBuilder runSb = new StringBuilder();
    for (String arg : arguments) {
        runSb.append(arg).append(" ");
    }

    String[] args;
    if (Platform.getOS().equals(Platform.OS_WIN32)) {
        File tmpRunFile = new File(homeFile, "udig_spatialtoolbox.bat");
        FileUtils.writeStringToFile(tmpRunFile, "@echo off\n" + runSb.toString());
        args = new String[] { "cmd", "/c", tmpRunFile.getAbsolutePath() };
    } else {
        File tmpRunFile = new File(homeFile, "udig_spatialtoolbox.sh");
        FileUtils.writeStringToFile(tmpRunFile, runSb.toString());
        args = new String[] { "sh", tmpRunFile.getAbsolutePath() };
    }

    // {javaFile, ramExpr, resourcesFlag, "-cp", classPath,
    // CLI.class.getCanonicalName(), "-r",
    // scriptFile.getAbsolutePath()};

    ProcessBuilder processBuilder = new ProcessBuilder(args);
    // work in home
    // processBuilder.directory(homeFile);

    // environment
    Map<String, String> environment = processBuilder.environment();
    // environment.put("CLASSPATH", classPath);

    final Process process = processBuilder.start();
    internalStream.println(
            "Process started: " + new DateTime().toString(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS));
    internalStream.println("");

    // command launched
    if (loggerLevelGui.equals(OmsBoxConstants.LOGLEVEL_GUI_ON)) {
        internalStream.println("------------------------------>8----------------------------");
        internalStream.println("Launching command: ");
        internalStream.println("------------------");
        List<String> command = processBuilder.command();
        for (String arg : command) {
            internalStream.print(arg);
            internalStream.print(" ");
        }
        internalStream.println("\n");
        internalStream.println("(you can run the above from command line, customizing the content)");
        internalStream.println("----------------------------------->8---------------------------------");
        internalStream.println("");
        // script run
        internalStream.println("Script run: ");
        internalStream.println("-----------");
        internalStream.println(script);
        internalStream.println("");
        internalStream.println("------------------------------>8----------------------------");
        internalStream.println("");
        // environment used
        internalStream.println("Environment used: ");
        internalStream.println("-----------------");

        Set<Entry<String, String>> entrySet = environment.entrySet();
        for (Entry<String, String> entry : entrySet) {
            internalStream.print(entry.getKey());
            internalStream.print(" =\t");
            internalStream.println(entry.getValue());
        }
        internalStream.println("------------------------------>8----------------------------");
        internalStream.println("");
    }
    internalStream.println("");
    isRunning = true;

    new Thread() {
        public void run() {
            BufferedReader br = null;
            try {
                InputStream is = process.getInputStream();
                InputStreamReader isr = new InputStreamReader(is);
                br = new BufferedReader(isr);
                String line;
                while ((line = br.readLine()) != null) {
                    internalStream.println(line);
                }
            } catch (Exception e) {
                e.printStackTrace();
                errorStream.println(e.getLocalizedMessage());
            } finally {
                if (br != null)
                    try {
                        br.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                isRunning = false;
                updateListeners();
            }
            internalStream.println("");
            internalStream.println("");
            internalStream.println("Process finished: "
                    + new DateTime().toString(OmsBoxConstants.dateTimeFormatterYYYYMMDDHHMMSS));
        };
    }.start();

    new Thread() {
        public void run() {
            BufferedReader br = null;
            try {
                InputStream is = process.getErrorStream();
                InputStreamReader isr = new InputStreamReader(is);
                br = new BufferedReader(isr);
                String line;
                while ((line = br.readLine()) != null) {
                    /*
                     * remove of ugly recurring geotools warnings. Not nice, but 
                     * at least users do not get confused. 
                     */
                    if (ConsoleMessageFilter.doRemove(line)) {
                        continue;
                    }
                    errorStream.println(line);
                }
            } catch (Exception e) {
                e.printStackTrace();
                errorStream.println(e.getLocalizedMessage());
            } finally {
                if (br != null)
                    try {
                        br.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
            }
        };
    }.start();

    return process;
}

From source file:org.apache.cordova.legacywebsql.LegacyWebSql.java

/**
 * Open database.//ww  w.j a  v  a 2  s  . c  om
 *
 * @param db
 *            The name of the database
 * @param version
 *            The version
 * @param display_name
 *            The display name
 * @param size
 *            The size in bytes
 */
public void openDatabase(String db, String version, String display_name, long size) {

    // If database is open, then close it
    if (this.myDb != null) {
        this.myDb.close();
    }

    // If no database path, generate from application package
    if (this.path == null) {
        this.path = this.cordova.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE)
                .getPath();
    }

    this.dbName = this.path + File.separator + db + ".db";

    /*
     * What is all this nonsense? Well the separator was incorrect so the db was showing up in the wrong 
     * directory. This bit of code fixes that issue and moves the db to the correct directory.
     */
    File oldDbFile = new File(this.path + File.pathSeparator + db + ".db");
    if (oldDbFile.exists()) {
        File dbPath = new File(this.path);
        File dbFile = new File(dbName);
        dbPath.mkdirs();
        oldDbFile.renameTo(dbFile);
    }

    this.myDb = SQLiteDatabase.openOrCreateDatabase(this.dbName, null);
}

From source file:net.grinder.engine.agent.LocalScriptTestDriveService.java

/**
 * Validate script./*from  ww w .j  a v a  2s .  c  om*/
 *
 * @param base                 working directory
 * @param script               script file
 * @param eventSynchronisation condition for event synchronization
 * @param securityEnabled      if security is set or not.
 * @param hostString           hostString
 * @param timeout              timeout in sec.
 * @return File which stores validation result.
 */
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
public File doValidate(File base, File script, Condition eventSynchronisation, boolean securityEnabled,
        String hostString, final int timeout) {
    FanOutStreamSender fanOutStreamSender = null;
    ErrorStreamRedirectWorkerLauncher workerLauncher = null;
    boolean stopByTooMuchExecution = false;
    ByteArrayOutputStream byteArrayErrorStream = new ByteArrayOutputStream();
    File file = new File(base, "validation-0.log");
    try {

        fanOutStreamSender = new FanOutStreamSender(1);
        deleteLogs(base);

        AbstractLanguageHandler handler = Lang.getByFileName(script).getHandler();
        AbstractGrinderClassPathProcessor classPathProcessor = handler.getClassPathProcessor();
        GrinderProperties properties = new GrinderProperties();
        PropertyBuilder builder = new PropertyBuilder(properties, new Directory(base), securityEnabled,
                hostString, NetworkUtils.getLocalHostName());
        properties.setInt("grinder.agents", 1);
        properties.setInt("grinder.processes", 1);
        properties.setInt("grinder.threads", 1);
        properties.setBoolean("grinder.script.validation", true);
        String grinderJVMClassPath = classPathProcessor.buildForemostClasspathBasedOnCurrentClassLoader(LOGGER)
                + File.pathSeparator + classPathProcessor.buildPatchClasspathBasedOnCurrentClassLoader(LOGGER)
                + File.pathSeparator + builder.buildCustomClassPath(true);
        properties.setProperty("grinder.jvm.classpath", grinderJVMClassPath);
        LOGGER.info("grinder.jvm.classpath  : {} ", grinderJVMClassPath);
        AgentIdentityImplementation agentIdentity = new AgentIdentityImplementation("validation");
        agentIdentity.setNumber(0);
        String newClassPath = classPathProcessor.buildClasspathBasedOnCurrentClassLoader(LOGGER);
        LOGGER.debug("validation class path " + newClassPath);
        Properties systemProperties = new Properties();
        systemProperties.put("java.class.path", base.getAbsolutePath() + File.pathSeparator + newClassPath);

        Directory workingDirectory = new Directory(base);
        String buildJVMArgumentWithoutMemory = builder.buildJVMArgumentWithoutMemory();
        LOGGER.info("jvm args : {} ", buildJVMArgumentWithoutMemory);
        final WorkerProcessCommandLine workerCommandLine = new WorkerProcessCommandLine(properties,
                systemProperties, buildJVMArgumentWithoutMemory, workingDirectory);

        ScriptLocation scriptLocation = new ScriptLocation(workingDirectory, script);
        ProcessWorkerFactory workerFactory = new ProcessWorkerFactory(workerCommandLine, agentIdentity,
                fanOutStreamSender, false, scriptLocation, properties);

        workerLauncher = new ErrorStreamRedirectWorkerLauncher(1, workerFactory, eventSynchronisation, LOGGER,
                byteArrayErrorStream);

        // Start
        workerLauncher.startAllWorkers();
        // Wait for a termination event.
        synchronized (eventSynchronisation) {
            final long sleep = 1000;
            int waitingCount = 0;
            while (true) {
                if (workerLauncher.allFinished()) {
                    break;
                }
                if (waitingCount++ > timeout) {
                    LOGGER.error("Validation should be performed within {} sec. Stop it by force", timeout);
                    workerLauncher.destroyAllWorkers();
                    stopByTooMuchExecution = true;
                    break;
                }
                eventSynchronisation.waitNoInterrruptException(sleep);
            }
        }
    } catch (Exception e) {
        LOGGER.error("Error while executing {} because {}", script, e.getMessage());
        LOGGER.info("The error detail is ", e);
        appendingMessageOn(file, ExceptionUtils.getFullStackTrace(e));
    } finally {
        if (workerLauncher != null) {
            workerLauncher.shutdown();
        }
        if (fanOutStreamSender != null) {
            fanOutStreamSender.shutdown();
        }
        // To be safe, wait again..
        int waitingCount = 0;
        while (workerLauncher != null) {
            final int maximumWaitingCount = 10;
            if (workerLauncher.allFinished() || waitingCount++ > maximumWaitingCount) {
                break;
            }
            synchronized (eventSynchronisation) {
                eventSynchronisation.waitNoInterrruptException(1000);
            }
        }

    }
    appendingMessageOn(file, byteArrayErrorStream.toString());
    File errorValidation = new File(base, "error_validation-0.log");
    if (errorValidation.exists()) {
        String errorValidationResult = "";
        try {
            errorValidationResult = FileUtils.readFileToString(errorValidation);
        } catch (IOException e) {
            noOp();
        }
        appendingMessageOn(file, errorValidationResult);
    }
    if (stopByTooMuchExecution) {
        appendingMessageOn(file, "Validation should be performed within " + timeout + " sec. Stop it by force");
    }
    return file;
}

From source file:com.ejisto.util.IOUtils.java

private static URL[] getSystemClasspathEntries() throws MalformedURLException {
    String[] paths = System.getProperty("java.class.path").split(File.pathSeparator);
    URL[] urls = new URL[paths.length];
    for (int i = 0; i < paths.length; i++) {
        urls[i] = new File(paths[i]).toURI().toURL();
    }/*from   w ww . j a  va 2s. c o  m*/
    return urls;
}

From source file:org.dkf.jmule.util.SystemUtils.java

/**
 * Use this instead ContextCompat//  w ww  .  j a v  a2  s  .co  m
 *
 */
public static File[] getExternalFilesDirs(Context context) {
    if (hasKitKatOrNewer()) {
        List<File> dirs = new LinkedList<>();

        for (File f : ContextCompat.getExternalFilesDirs(context, null)) {
            if (f != null) {
                dirs.add(f);
            }
        }

        return dirs.toArray(new File[dirs.size()]);
    } else {
        List<File> dirs = new LinkedList<>();

        dirs.add(context.getExternalFilesDir(null));

        try {
            String secondaryStorages = System.getenv("SECONDARY_STORAGE");
            if (secondaryStorages != null) {
                String[] storages = secondaryStorages.split(File.pathSeparator);
                for (String s : storages) {
                    dirs.add(new File(s));
                }
            }
        } catch (Exception e) {
            LOG.error("Unable to get secondary external storages", e);
        }

        return dirs.toArray(new File[dirs.size()]);
    }
}

From source file:dk.netarkivet.common.utils.ApplicationUtils.java

/**
 * Starts up an application. The applications class must:
 * (i) Have a static getInstance() method which returns a
 *     an instance of itself.//from   w  ww .  ja va2 s  .c om
 * (ii) Implement CleanupIF.
 * If the class cannot be started and a shutdown hook added, the JVM
 * exits with a return code depending on the problem:
 * 1 means wrong arguments
 * 2 means no factory method exists for class
 * 3 means couldn't instantiate class
 * 4 means couldn't add shutdown hook
 * 5 means couldn't add liveness logger
 * 6 means couldn't add remote management
 * @param c The class to be started.
 * @param args The arguments to the application (should be empty).
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void startApp(Class c, String[] args) {
    String appName = c.getName();
    Settings.set(CommonSettings.APPLICATION_NAME, appName);
    logAndPrint("Starting " + appName + "\n" + Constants.getVersionString());
    log.info("Using settings files '" + StringUtils.conjoin(File.pathSeparator, Settings.getSettingsFiles())
            + "'");
    checkArgs(args);
    dirMustExist(FileUtils.getTempDir());
    Method factoryMethod = null;
    CleanupIF instance = null;
    // Start the remote management connector
    try {
        MBeanConnectorCreator.exposeJMXMBeanServer();
        log.trace("Added remote management for " + appName);
    } catch (Throwable e) {
        logExceptionAndPrint("Could not add remote management for class " + appName, e);
        System.exit(EXCEPTION_WHEN_ADDING_MANAGEMENT);
    }
    // Get the factory method
    try {
        factoryMethod = c.getMethod("getInstance", (Class[]) null);
        int modifier = factoryMethod.getModifiers();
        if (!Modifier.isStatic(modifier)) {
            throw new Exception("getInstance is not static");
        }
        logAndPrint(appName + " Running");
    } catch (Throwable e) {
        logExceptionAndPrint("Class " + appName + " does not have required" + "factory method", e);
        System.exit(NO_FACTORY_METHOD);
    }
    // Invoke the factory method
    try {
        log.trace("Invoking factory method.");
        instance = (CleanupIF) factoryMethod.invoke(null, (Object[]) null);
        log.trace("Factory method invoked.");
    } catch (Throwable e) {
        logExceptionAndPrint("Could not start class " + appName, e);
        System.exit(EXCEPTION_WHILE_INSTANTIATING);
    }
    // Add the shutdown hook
    try {
        log.trace("Adding shutdown hook for " + appName);
        Runtime.getRuntime().addShutdownHook((new CleanupHook(instance)));
        log.trace("Added shutdown hook for " + appName);
    } catch (Throwable e) {
        logExceptionAndPrint("Could not add shutdown hook for class " + appName, e);
        System.exit(EXCEPTION_WHEN_ADDING_SHUTDOWN_HOOK);
    }
}

From source file:org.eclipse.smila.utils.config.ConfigUtils.java

/**
 * Gets the configuration stream for the denoted config file. The stream is to be closed by the caller.
 * <p>/*from  w  w  w  .j av a  2s. com*/
 * <strong>Note</strong>: While this methods supports the bundle name to be an arbitrary string that is not the name
 * of the bundle for "normal" configs the defaultConfigPath will only work if the given bundle name is actually the
 * name of the bundle.
 * 
 * @param bundleName
 *          the bundle name
 * @param configPath
 *          the path which may be either relative or absolute. <br/>
 *          <em>While absolute paths are supported they are strongly discurraged.</em>
 * @param defaultConfigPath
 *          the default config path to a resource that is contained in the bundle itself if the configPath doesnt
 *          resolve to an existing file.
 * 
 * @throws ConfigurationLoadException
 *           if the denoted config file doesnt exist or cannot be opened.
 */
public static InputStream getConfigStream(final String bundleName, final String configPath,
        final String defaultConfigPath) {

    String effectivePath = "<ConfigRoot>" + File.pathSeparator
            + new File(bundleName, configPath).getAbsolutePath();
    if (getConfigurationFolder() != null) {
        final File bundleConfigRoot = new File(getConfigurationFolder(), bundleName);
        if (bundleConfigRoot.exists()) {
            final File configFile = new File(configPath);
            final File effectiveConfigFile = configFile.isAbsolute() ? configFile
                    : new File(bundleConfigRoot, configPath);
            effectivePath = effectiveConfigFile.getAbsolutePath();
            if (effectiveConfigFile.exists()) {
                try {
                    return new FileInputStream(effectiveConfigFile);
                } catch (final Exception e) {
                    throw new ConfigurationLoadException("Failed to open config file: " + effectivePath);
                }
            }
        }
    }
    if (defaultConfigPath == null) {
        throw new ConfigurationLoadException(
                String.format("Configuration resource %s for the bundle %s not found", configPath, bundleName));
    }
    final Bundle bundle = Platform.getBundle(bundleName);
    if (bundle == null) {
        throw new ConfigurationLoadException("Unable to find bundle: " + bundleName);
    }
    final URL url = bundle.getEntry(defaultConfigPath);
    if (url == null) {
        throw new ConfigurationLoadException(
                String.format("Unable to find config file '%s' nor fallback config '%s' in bundle '%s'",
                        effectivePath, defaultConfigPath, bundleName));
    }
    try {
        return url.openStream();
    } catch (final IOException e) {
        throw new ConfigurationLoadException(e);
    }
}