本文整理汇总了Java中org.apache.commons.chain.Command类的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于org.apache.commons.chain包,在下文中一共展示了Command类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: executeCommandLine
import org.apache.commons.chain.Command; //导入依赖的package包/类
public void executeCommandLine(CommandLine commandLine)
throws DataScraper3Exception {
if (!commandLine.hasOption(CommandLineOptions.COMMAND)) {
throw new DataScraper3Exception("No command supplied.");
}
CommandContext context = new CommandContext();
context.put(CommandContext.EODDATAPROVIDER_KEY, _eodDataProvider);
context.put(CommandContext.EODDATASINK_KEY, _eodDataSink);
context.put(CommandContext.EMAILSERVICE_KEY, _emailService);
// place optional argument values into the context
if (commandLine.hasOption(CommandLineOptions.EXCHANGE)) {
context.put(CommandContext.EXCHANGE_KEY,
commandLine.getOptionValue(CommandLineOptions.EXCHANGE));
}
if (commandLine.hasOption(CommandLineOptions.SYMBOL)) {
context.put(CommandContext.SYMBOL_KEY,
commandLine.getOptionValue(CommandLineOptions.SYMBOL));
}
try {
Command command = (Command)_appContext.getBean(commandLine
.getOptionValue(CommandLineOptions.COMMAND));
command.execute(context);
} catch (Exception e) {
throw new DataScraper3Exception(e);
}
}
开发者ID:jsr38,项目名称:ds3,代码行数:35,代码来源:DataScraper3Controller.java
示例2: execute
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* <p>Invoke the Command for a Context, returning TRUE if processing
* should halt.</p>
*
* @param context Our ActionContext
* @return TRUE if processing should halt
* @throws Exception On any error
*/
public boolean execute(Context context)
throws Exception {
if (LOG.isTraceEnabled()) {
LOG.trace("execute [" + this + "]");
}
Command command = getCommand(context);
if (command != null) {
return command.execute(getContext(context));
} else {
return false;
}
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:23,代码来源:WrappingLookupCommand.java
示例3: getCommand
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* <p>Return the command specified by the <code>command</code> and
* <code>catalog</code> properties of the <code>forwardConfig</code>
* property of the given <code>ActionContext</code>. If
* <code>forwardConfig</code> is null, return null.</p>
*
* @param context Our ActionContext
* @return Command to execute or null
*/
protected Command getCommand(ActionContext context) {
ForwardConfig forwardConfig = context.getForwardConfig();
if (forwardConfig == null) {
return null;
}
return getCommand(forwardConfig.getCommand(), forwardConfig.getCatalog());
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:19,代码来源:ExecuteForwardCommand.java
示例4: execute
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* <p>If the <code>context</code> is "valid", lookup a command and execute
* it.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return the result of the lookup command's <code>execute</code> method,
* if executed, or <code>false</code> if it was not executed.
* @throws Exception on any error
*/
public boolean execute(ActionContext actionCtx)
throws Exception {
if (shouldProcess(actionCtx)) {
Command command = getCommand(actionCtx);
if (command != null) {
return (command.execute(actionCtx));
}
}
return (false);
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:22,代码来源:ExecuteCommand.java
示例5: getCommand
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* <p>Find the <code>ActionConfig</code> in the current context and, if it
* is properly configured, lookup the appropriate <code>commons-chain</code>
* command.</p>
*
* @param context A valid ActionContext
* @return a <code>Command</code> to execute, or null if none is specified
* or if the specified command cannot be found.
*/
protected Command getCommand(ActionContext context) {
ActionConfig actionConfig = context.getActionConfig();
String commandName = actionConfig.getCommand();
if (commandName == null) {
return null;
}
String catalogName = actionConfig.getCatalog();
return getCommand(commandName, catalogName);
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:23,代码来源:ExecuteCommand.java
示例6: postprocess
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* <p>If an exception was thrown by a subsequent <code>Command</code>,
* pass it on to the specified exception handling chain. Otherwise, do
* nothing.</p>
*
* @param context The {@link Context} to be processed by this {@link
* Filter}
* @param exception The <code>Exception</code> (if any) that was thrown by
* the last {@link Command} that was executed; otherwise
* <code>null</code>
* @return TRUE if post processing an exception occurred and the exception
* processing chain invoked
* @throws IllegalStateException If exception throws exception
*/
public boolean postprocess(Context context, Exception exception) {
// Do nothing if there was no exception thrown
if (exception == null) {
return (false);
}
// Stash the exception in the specified context attribute
if (LOG.isDebugEnabled()) {
LOG.debug("Attempting to handle a thrown exception");
}
ActionContext actionCtx = (ActionContext) context;
actionCtx.setException(exception);
// Execute the specified command
try {
Command command = lookupExceptionCommand();
if (command == null) {
LOG.error("Cannot find exceptionCommand '" + exceptionCommand
+ "'");
throw new IllegalStateException(
"Cannot find exceptionCommand '" + exceptionCommand + "'");
}
if (LOG.isTraceEnabled()) {
LOG.trace("Calling exceptionCommand '" + exceptionCommand + "'");
}
command.execute(context);
} catch (Exception e) {
LOG.warn("Exception from exceptionCommand '" + exceptionCommand
+ "'", e);
throw new IllegalStateException("Exception chain threw exception");
}
return (true);
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:54,代码来源:ExceptionCatcher.java
示例7: getResultFromClass
import org.apache.commons.chain.Command; //导入依赖的package包/类
public ChainResultObj getResultFromClass(Class<Command>[] clazz, Context context) throws Exception {
for (int i=0; i<clazz.length; i++) {
this.addCommand(clazz[i].newInstance());
}
this.execute(context);
return this.getResult(context);
}
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:8,代码来源:SimpleChain.java
示例8: setCommand
import org.apache.commons.chain.Command; //导入依赖的package包/类
public void setCommand(Command command) {
this.command = command;
}
开发者ID:jsr38,项目名称:ds3,代码行数:4,代码来源:QuartzJobBeanCommandProxy.java
示例9: getCommand
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* <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();
catalogName = "{default}"; // for debugging purposes
} 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");
}
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:54,代码来源:WrappingLookupCommand.java
示例10: lookupExceptionCommand
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* <p> Return the command to be executed if an exception occurs. </p>
*
* @return The command to be executed if an exception occurs
* @throws IllegalArgumentException If catalog cannot be found
* @throws IllegalStateException If command property is not specified
*/
protected Command lookupExceptionCommand() {
String catalogName = getCatalogName();
Catalog catalog;
if (catalogName == null) {
catalog = CatalogFactory.getInstance().getCatalog();
if (catalog == null) {
LOG.error("Cannot find default catalog");
throw new IllegalArgumentException(
"Cannot find default catalog");
}
} else {
catalog = CatalogFactory.getInstance().getCatalog(catalogName);
if (catalog == null) {
LOG.error("Cannot find catalog '" + catalogName + "'");
throw new IllegalArgumentException("Cannot find catalog '"
+ catalogName + "'");
}
}
String exceptionCommand = getExceptionCommand();
if (exceptionCommand == null) {
LOG.error("No exceptionCommand property specified");
throw new IllegalStateException(
"No exceptionCommand property specfied");
}
return catalog.getCommand(exceptionCommand);
}
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:40,代码来源:ExceptionCatcher.java
示例11: getCommand
import org.apache.commons.chain.Command; //导入依赖的package包/类
public static Command getCommand(String commandID) throws IllegalArgumentException
{
// XXX: This function taken from CVS version of CatalogFactory
String DELIMITER = ":";
String commandName = commandID;
String catalogName = null;
Catalog catalog = null;
if (commandID != null)
{
int splitPos = commandID.indexOf(DELIMITER);
if (splitPos != -1)
{
catalogName = commandID.substring(0, splitPos);
commandName = commandID.substring(splitPos + DELIMITER.length());
if (commandName.indexOf(DELIMITER) != -1)
{
throw new IllegalArgumentException("commandID [" + commandID + "] has too many delimiters (reserved for future use)");
}
}
}
if (catalogName != null)
{
catalog = factory.getCatalog(catalogName);
if (catalog == null)
{
RadiusLog.warn("No catalog found for name: " + catalogName + ".");
return null;
}
}
else
{
catalog = factory.getCatalog();
if (catalog == null)
{
RadiusLog.warn("No default catalog found.");
return null;
}
}
return catalog.getCommand(commandName);
}
开发者ID:coova,项目名称:jradius,代码行数:44,代码来源:Configuration.java
示例12: testListExchangesCommand
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* Test that when supplied with a known set of exchanges,
* an identical set of exchanges is written to the HDF5
* file.
*/
@Test
public void testListExchangesCommand() {
try {
UnitTestData testData = new UnitTestData();
EodDataProvider eodDataProvider = new EodDataProviderMock(testData);
EodDataSink eodDataSink = new EodDataSinkEmptyMock(testData);
CommandContext context = new CommandContext();
context.put(CommandContext.EODDATAPROVIDER_KEY, eodDataProvider);
context.put(CommandContext.EODDATASINK_KEY, eodDataSink);
context.put(CommandContext.EXCHANGE_KEY, testData.getTestExchange());
context.put(CommandContext.SYMBOL_KEY, testData.getTestSymbol());
Command command = new ListExchangesCommand();
command.execute(context);
} catch (Exception e) {
fail(e.getMessage());
}
}
开发者ID:jsr38,项目名称:ds3,代码行数:34,代码来源:ListExchangesCommandTest.java
示例13: testUpdateExchangeQuotesCommand_EmptySink
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* Test
*/
@Test
public void testUpdateExchangeQuotesCommand_EmptySink() {
try {
UnitTestData testData = new UnitTestData();
EodDataProvider eodDataProvider = new EodDataProviderMock(testData);
EodDataSink eodDataSink = new EodDataSinkEmptyMock(testData);
EmailService emailService = new EmailServiceMock();
CommandContext context = new CommandContext();
// context.put(CommandContext.EODDATAPROVIDER_KEY, eodDataProvider);
// context.put(CommandContext.EODDATASINK_KEY, eodDataSink);
context.put(CommandContext.EXCHANGE_KEY, testData.getTestExchange());
context.put(CommandContext.SYMBOL_KEY, testData.getTestSymbol());
Command command = new UpdateExchangeQuotesCommand(
Executors.newSingleThreadExecutor(), eodDataProvider,
eodDataSink, emailService);
command.execute(context);
} catch (Throwable t) {
t.printStackTrace();
fail(t.getCause().toString());
}
}
开发者ID:jsr38,项目名称:ds3,代码行数:37,代码来源:UpdateExchangeQuotesCommandTest.java
示例14: testUpdateExchangeQuotesCommand_OneDayOrLessAvailable
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* Test
*/
@Test
public void testUpdateExchangeQuotesCommand_OneDayOrLessAvailable() {
try {
UnitTestData testData = new UnitTestData();
EodDataProvider eodDataProvider = new EodDataProviderOneDayAvailableMock(
testData);
EodDataSink eodDataSink = new EodDataSinkFirstElementLessThanOneDayAfterFirstAvailable(
testData);
EmailService emailService = new EmailServiceMock();
CommandContext context = new CommandContext();
// context.put(CommandContext.EODDATAPROVIDER_KEY, eodDataProvider);
// context.put(CommandContext.EODDATASINK_KEY, eodDataSink);
context.put(CommandContext.EXCHANGE_KEY, testData.getTestExchange());
context.put(CommandContext.SYMBOL_KEY, testData.getTestSymbol());
Command command = new UpdateExchangeQuotesCommand(
Executors.newSingleThreadExecutor(), eodDataProvider,
eodDataSink, emailService);
command.execute(context);
} catch (Throwable t) {
t.printStackTrace();
fail(t.getCause().getMessage());
}
}
开发者ID:jsr38,项目名称:ds3,代码行数:39,代码来源:UpdateExchangeQuotesCommandTest.java
示例15: testUpdateExchangeSymbolQuotesCommand_EmptySink
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* Test
*/
@Test
public void testUpdateExchangeSymbolQuotesCommand_EmptySink() {
try {
UnitTestData testData = new UnitTestData();
EodDataProvider eodDataProvider = new EodDataProviderMock(testData);
EodDataSink eodDataSink = new EodDataSinkEmptyMock(testData);
CommandContext context = new CommandContext();
context.put(CommandContext.EODDATAPROVIDER_KEY, eodDataProvider);
context.put(CommandContext.EODDATASINK_KEY, eodDataSink);
context.put(CommandContext.EXCHANGE_KEY, testData.getTestExchange());
context.put(CommandContext.SYMBOL_KEY, testData.getTestSymbol());
Command command = new UpdateExchangeSymbolQuotesCommand();
command.execute(context);
} catch (Throwable t) {
fail(t.toString());
}
}
开发者ID:jsr38,项目名称:ds3,代码行数:33,代码来源:UpdateExchangeSymbolQuotesCommandTest.java
示例16: testUpdateExchangeSymbolQuotesCommand_ContainedByAvailableRangeSink
import org.apache.commons.chain.Command; //导入依赖的package包/类
/**
* Test
*/
@Test
public void testUpdateExchangeSymbolQuotesCommand_ContainedByAvailableRangeSink() {
try {
UnitTestData testData = new UnitTestData();
EodDataProvider eodDataProvider = new EodDataProviderMock(testData);
EodDataSink eodDataSink = new EodDataSinkContainedByAvailableRangeMock(
testData);
CommandContext context = new CommandContext();
context.put(CommandContext.EODDATAPROVIDER_KEY, eodDataProvider);
context.put(CommandContext.EODDATASINK_KEY, eodDataSink);
context.put(CommandContext.EXCHANGE_KEY, testData.getTestExchange());
context.put(CommandContext.SYMBOL_KEY, testData.getTestSymbol());
Command command = new UpdateExchangeSymbolQuotesCommand();
command.execute(context);
} catch (Throwable t) {
fail(t.toString());
}
}
开发者ID:jsr38,项目名称:ds3,代码行数:34,代码来源:UpdateExchangeSymbolQuotesCommandTest.java
示例17: create
import org.apache.commons.chain.Command; //导入依赖的package包/类
public static Command create(String type, ExecutorService executorService) throws CommandException {
if (type.compareTo(LISTEXCHANGES_KEY) == 0) {
return new ListExchangesCommand();
}
else if (type.compareTo(LISTEXCHANGEMONTHS_KEY) == 0) {
return new ListExchangeMonthsCommand();
}
else if (type.compareTo(UPDATEEXCHANGES_KEY) == 0) {
return new UpdateExchangesCommand();
}
else if (type.compareTo(UPDATEEXCHANGESYMBOLS_KEY) == 0) {
return new UpdateExchangeSymbolsCommand();
}
else if (type.compareTo(UPDATEALLSYMBOLS_KEY) == 0) {
return new UpdateAllSymbolsCommand();
}
else if (type.compareTo(UPDATEEXCHANGEQUOTES_KEY) == 0) {
return new UpdateExchangeQuotesCommand(executorService, null, null, null);
}
else if (type.compareTo(UPDATEEXCHANGESYMBOLQUOTES_KEY) == 0) {
return new UpdateExchangeSymbolQuotesCommand();
}
else if (type.compareTo(GETEXCHANGESYMBOLQUOTES_KEY) == 0) {
return new GetExchangeSymbolQuotesCommand();
}
else {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("Unknown command [ ");
stringBuffer.append(type);
stringBuffer.append(" ] ");
throw new CommandException(stringBuffer.toString());
}
}
开发者ID:jsr38,项目名称:ds3,代码行数:54,代码来源:CommandFactory.java
注:本文中的org.apache.commons.chain.Command类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论