Command
2012-04-13 17:24
60 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/standyxu/article/details/84185830
public abstract class Command { protected SecurityContext securityContext = null; protected Map<String, Object> arguments = null; protected Command.status status = null; protected Command.exitCode exitCode = null; private final static String ERROR_MESSAGE = "errorMessage"; private final static String EXIT_CODE = "exitCode"; private Map<String, Object> exitStatus; public enum status { WAITING, RUNNING, FINISHED } public enum exitCode { UNKNOWN, SUCCESS, FAILURE } public Command() { this.arguments = new ConcurrentHashMap<String, Object>(10, 0.9f, 8); this.exitStatus = new ConcurrentHashMap<String, Object>(10, 0.9f, 8); // Set default exitStatus.put(EXIT_CODE, exitCode.UNKNOWN); } /** * Executes this command. Override this method to implement your service- * specific behaviour. * * @param parameters the parameters * @return the result */ public abstract Object execute(Object... parameters) throws FrameworkException; /** * Returns the service class this command belongs to. Implement this method * in an abstrac base class and derive all you service commands from this * class. * * @return the service this command belongs to */ public abstract Class getServiceClass(); /** * Sets an argument for this command. Call this method from within * {@see org.structr.core.Service#injectArguments}. * * @param key the key * @param value the value */ public final void setArgument(String key, Object value) { if (key != null && value != null) { this.arguments.put(key, value); } } /** * Returns a previously set argument for this command. * * @param key the key * @return the argument or null if no such argument exists. */ public final Object getArgument(String key) { return (this.arguments.get(key)); } public Command.status getStatus() { return status; } public void setStatus(final Command.status status) { this.status = status; } public Command.exitCode getExitCode() { return (Command.exitCode) exitStatus.get(EXIT_CODE); } public void setExitCode(final Command.exitCode exitCode) { if (exitCode != null) { this.exitStatus.put(EXIT_CODE, exitCode); } } public String getErrorMessage() { return (String) exitStatus.get("errorMessage"); } public void setErrorMessage(final String errorMessage) { if (errorMessage != null) { this.exitStatus.put(ERROR_MESSAGE, errorMessage); } } public void setSecurityContext(SecurityContext securityContext) { this.securityContext = securityContext; } }
相关文章推荐
- Cocoa with gcc command build without window
- 利用Command创建执行SQL语句的模块
- Xcode代码提示联想功能失效,按command键点不进去类库,提示“?”,代码全是白色
- MCI Command String全览——完全参数篇(1)
- 设计模式之命令模式(Command)
- Build step 'Execute Windows batch command' marked build as failure
- command模式
- linker command failed with exit code 1 (use -v to see invocation)
- 解决MySQL5.6出现"Using a password on the command line interface..."
- Winform实践SqlCommandBuilder
- linux svn command
- 【解决方案】Command failed due to signal: Segmentation fault: 11
- command命令模式
- RMAN:Use CROSSCHECK command to fix status
- 2: Python Versions(Command line Python scripting)
- asp中command的在单条记录时,有些字段显示为空的问题
- linker command failed with exit code 1 (use -v to see invocation)的错误调试
- pip 安装 psycopg2 遇到的Command "python setup.py egg_info" failed
- onclick与onCommand的区别
- build event command line