use of org.apache.commons.chain.Catalog in project sonarqube by SonarSource.
the class ExecuteCommand method getCommand.
/**
* <p> Retrieve the specified Command from the specified Catalog. </p>
*
* @param commandName The Command to retrieve.
* @param catalogName The Catalog to search.
* @return Instantiated Command, or null
*/
protected Command getCommand(String commandName, String catalogName) {
if (commandName == null) {
return null;
}
Catalog catalog;
if (catalogName != null) {
catalog = CatalogFactory.getInstance().getCatalog(catalogName);
if (catalog == null) {
LOG.warn("When looking up " + commandName + "," + " no catalog found under " + catalogName);
return null;
}
} else {
catalogName = "the default catalog";
catalog = CatalogFactory.getInstance().getCatalog();
if (catalog == null) {
LOG.warn("When looking up " + commandName + "," + " no default catalog found.");
return null;
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("looking up command " + commandName + " in " + catalogName);
}
return catalog.getCommand(commandName);
}
use of org.apache.commons.chain.Catalog in project bamboobsc by billchen198318.
the class SimpleChain method getCatalog.
public Catalog getCatalog(String resourceConfig, String catalogName) throws Exception {
ConfigParser parser = new ConfigParser();
parser.parse(this.getClass().getResource(resourceConfig));
Catalog catalog = CatalogFactoryBase.getInstance().getCatalog(catalogName);
return catalog;
}
use of org.apache.commons.chain.Catalog in project bamboobsc by billchen198318.
the class SimpleChain method getResultFromResource.
public ChainResultObj getResultFromResource(String commandName, Context context) throws Exception {
Catalog catalog = this.getCatalog(ChainConstants.CHAIN_RESOURCE_CONFIG, ChainConstants.CHAIN_CATALOG);
this.addCommand(catalog.getCommand(commandName));
this.execute(context);
return this.getResult(context);
}
use of org.apache.commons.chain.Catalog in project sonar-java by SonarSource.
the class WrappingLookupCommand method getCommand.
/**
* <p>Return the Command to process for this Context.</p>
*
* @param context The Context we are processing
* @return The Command to process for this Context
*/
protected Command getCommand(Context context) {
CatalogFactory catalogFactory = CatalogFactory.getInstance();
String catalogName = getCatalogName();
Catalog catalog;
if (catalogName == null) {
catalog = catalogFactory.getCatalog();
// for debugging purposes
catalogName = "{default}";
} else {
catalog = catalogFactory.getCatalog(catalogName);
}
if (catalog == null) {
throw new IllegalArgumentException("Cannot find catalog '" + catalogName + "'");
}
Command command;
String name = getName();
if (name == null) {
name = (String) context.get(getNameKey());
}
if (name != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Lookup command " + name + " in catalog " + catalogName);
}
command = catalog.getCommand(name);
if (LOG.isDebugEnabled()) {
LOG.debug("Found command " + command + ";" + " optional: " + isOptional());
}
if ((command == null) && !isOptional()) {
throw new IllegalArgumentException("Cannot find command " + "'" + name + "' in catalog '" + catalogName + "'");
} else {
return command;
}
} else {
throw new IllegalArgumentException("No command name");
}
}
use of org.apache.commons.chain.Catalog in project sonar-java by SonarSource.
the class ExecuteCommand method getCommand.
/**
* <p> Retrieve the specified Command from the specified Catalog. </p>
*
* @param commandName The Command to retrieve.
* @param catalogName The Catalog to search.
* @return Instantiated Command, or null
*/
protected Command getCommand(String commandName, String catalogName) {
if (commandName == null) {
return null;
}
Catalog catalog;
if (catalogName != null) {
catalog = CatalogFactory.getInstance().getCatalog(catalogName);
if (catalog == null) {
LOG.warn("When looking up " + commandName + "," + " no catalog found under " + catalogName);
return null;
}
} else {
catalogName = "the default catalog";
catalog = CatalogFactory.getInstance().getCatalog();
if (catalog == null) {
LOG.warn("When looking up " + commandName + "," + " no default catalog found.");
return null;
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("looking up command " + commandName + " in " + catalogName);
}
return catalog.getCommand(commandName);
}
Aggregations