本文整理汇总了Java中org.apache.commons.chain.Command.execute方法的典型用法代码示例。如果您正苦于以下问题:Java Command.execute方法的具体用法?Java Command.execute怎么用?Java Command.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.chain.Command
的用法示例。
在下文中一共展示了Command.execute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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;
}
}
示例3: 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);
}
示例4: 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);
}
示例5: 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());
}
}
示例6: 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());
}
}
示例7: 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());
}
}
示例8: 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());
}
}
示例9: 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());
}
}