
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.
/*
* Copyright (c) 2016 University Nice Sophia Antipolis
*
* This file is part of btrplace.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
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 List paths;
/**
* The builder to create the scripts.
*/
private 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