
org.tinygroup.pluginmgt.cmd.PluginQueryCommand Maven / Gradle / Ivy
The newest version!
/**
* Copyright (c) 1997-2013, tinygroup.org ([email protected]).
*
* Licensed under the GPL, Version 3.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.gnu.org/licenses/gpl.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* --------------------------------------------------------------------------
* 版权 (c) 1997-2013, tinygroup.org ([email protected]).
*
* 本开源软件遵循 GPL 3.0 协议;
* 如果您不遵循此协议,则不被允许使用此文件。
* 你可以从下面的地址获取完整的协议文本
*
* http://www.gnu.org/licenses/gpl.html
*/
package org.tinygroup.pluginmgt.cmd;
import java.util.List;
import org.tinygroup.command.CommandSystem;
import org.tinygroup.context.Context;
import org.tinygroup.logger.LogLevel;
import org.tinygroup.logger.Logger;
import org.tinygroup.logger.LoggerFactory;
import org.tinygroup.plugin.PluginManager;
import org.tinygroup.plugin.config.PluginInfo;
import org.tinygroup.springutil.SpringUtil;
/**
* 查询插件状态
* @author luoguo
*
*/
public class PluginQueryCommand extends AbstractPluginCommand {
private Logger logger = LoggerFactory.getLogger(PluginStopCommand.class);
@Override
protected void actionAllPlugin(CommandSystem commandHelper, Context context) {
logger.logMessage(LogLevel.DEBUG, "开始执行指令:查询所有插件信息");
PluginManager pluginManager = SpringUtil.getBean(
"pluginManager");
List list = pluginManager.getAllPluginInfo();
for (PluginInfo plugin : list) {
actionPlugin(commandHelper, context, plugin);
}
logger.logMessage(LogLevel.DEBUG, "指令执行完毕:查询所有插件信息");
}
@Override
protected void actionPlugin(CommandSystem commandHelper, Context context,
PluginInfo plugin) {
logger.logMessage(LogLevel.DEBUG, "开始执行指令:查询插件[id:{0},version:{1}]信息",
plugin.getId(),plugin.getVersion());
PluginManager pluginManager = SpringUtil.getBean(
"pluginManager");
int status = pluginManager.status(plugin);
String statusInfo = pluginManager.getStatusDescription(status);
commandHelper.indentPrint(String.format("插件状态:[id:%s,version:%s,level:%s,status:%s]",
plugin.getId(),plugin.getVersion(),plugin.getLevel(),statusInfo), 0);
commandHelper.println();
logger.logMessage(LogLevel.DEBUG, "指令执行完毕:查询插件[id:{0},version:{1}]信息",
plugin.getId(),plugin.getVersion());
}
@Override
protected void actionPluginByLevel(CommandSystem commandHelper,
Context context, int level) {
logger.logMessage(LogLevel.ERROR, "错误的参数,不支持按等级查询插件信息",
level);
commandHelper.indentPrint("错误的参数,不支持按等级查询插件信息", 0);
commandHelper.println();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy