All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.plugin.integration.operator.verify.PluginLegalVerify Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.plugin.integration.operator.verify;

import org.pf4j.*;
import org.zodiac.sdk.toolkit.util.lang.StrUtil;

import java.nio.file.Path;
import java.util.Objects;

/**
 * 

插件包合法校验。

* */ public class PluginLegalVerify implements PluginVerify { protected final PluginDescriptorFinder pluginDescriptorFinder; public PluginLegalVerify(PluginDescriptorFinder pluginDescriptorFinder) { Objects.requireNonNull(pluginDescriptorFinder); this.pluginDescriptorFinder = pluginDescriptorFinder; } @Override public Path verify(Path path) throws Exception { if (path == null) { throw new IllegalArgumentException("path can not be null"); } if (!pluginDescriptorFinder.isApplicable(path)) { /*插件包不合法。*/ throw new Exception(path.toString() + " : plugin illegal"); } PluginDescriptor pluginDescriptor = pluginDescriptorFinder.find(path); if (pluginDescriptor == null) { throw new Exception(path.toString() + " : Not found plugin Descriptor"); } if (StrUtil.isEmpty(pluginDescriptor.getPluginId())) { throw new Exception(path.toString() + " : Plugin id can't be empty"); } if (StrUtil.isEmpty(pluginDescriptor.getPluginClass())) { throw new Exception(path.toString() + " : Not found plugin Class"); } return postVerify(path, pluginDescriptor); } /** *

合法后的校验.可扩展校验。

* * @param path 路径 * @param pluginDescriptor 插件解析者 * @return 返回路径 * @throws Exception 插件异常 */ protected Path postVerify(Path path, PluginDescriptor pluginDescriptor) throws Exception { return path; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy