
org.btrplace.btrpsl.includes.PathBasedIncludes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of btrpsl Show documentation
Show all versions of btrpsl Show documentation
The btrplace specification language (btrpsl) allows to express constraints
related to the placement of virtual machines in a datacenters.
This language is dedicated to datacenters administrators and applications administrators
that use Btrplace(http://btrp.inria.fr) to manage their nodes and virtual machines.
The newest version!
/*
* Copyright 2020 The BtrPlace Authors. All rights reserved.
* Use of this source code is governed by a LGPL-style
* license that can be found in the LICENSE.txt file.
*/
package org.btrplace.btrpsl.includes;
import org.btrplace.btrpsl.Script;
import org.btrplace.btrpsl.ScriptBuilder;
import org.btrplace.btrpsl.ScriptBuilderException;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
/**
* An implementation that loop for the searched script among several folders.
* Similar to a shell path.
*
* @author Fabien Hermenier
*/
public class PathBasedIncludes implements Includes {
/**
* The folders to browse.
*/
private final List paths;
/**
* The builder to create the scripts.
*/
private final ScriptBuilder builder;
/**
* Make a new instance that will browse a first folder.
*
* @param vBuilder the builder to parse the scripts
*/
public PathBasedIncludes(ScriptBuilder vBuilder) {
this.paths = new LinkedList<>();
this.builder = vBuilder;
}
/**
* Get the script associated to a given identifier by browsing the given paths.
* The first script having a matching identifier is selected, whatever the parsing process result will be
*
* @param name the identifier of the script
* @return the script if found
* @throws org.btrplace.btrpsl.ScriptBuilderException if the builder was not able to parse the looked script
*/
@Override
public List