本文整理汇总了Java中net.xeoh.plugins.base.PluginManager.getPlugin方法的典型用法代码示例。如果您正苦于以下问题:Java PluginManager.getPlugin方法的具体用法?Java PluginManager.getPlugin怎么用?Java PluginManager.getPlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.xeoh.plugins.base.PluginManager
的用法示例。
在下文中一共展示了PluginManager.getPlugin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: thisPlugin
import net.xeoh.plugins.base.PluginManager; //导入方法依赖的package包/类
/**
* Allows you to get the plugin you want if it's installed. Advise : put it in the dependencies
*
* @param plugin_name String The name of the wanted plugin
* @return Corpoplugins The plugin with the given name
*/
public static Corpoplugins thisPlugin(String plugin_name) {
// Setting up the PluginManager from jspf
PluginManager pm = PluginManagerFactory.createPluginManager();
try {
configString = getConfig();
if (Install.isInstalled(plugin_name))
pm.addPluginsFrom(new File(PLUGINDIRECTORY + plugin_name.toLowerCase() + System.getProperty("file.separator")).toURI());
return pm.getPlugin(Corpoplugins.class);
} catch (IOException e) {
System.err.println(e.getMessage());
}
return null;
}
示例2: updatePlugin
import net.xeoh.plugins.base.PluginManager; //导入方法依赖的package包/类
/**
* Will update the given plugin. Will check if the plugin is already installed, compare its version,
* if its dependencies are present (will execute a dry run of install for it).
* And then use Delete and Install to reinstall the plugin.
*
* @param path_to_update String The plugin which will be updated.
* @param debug boolean Will display the progression of the action if true.
* @see core.Install
* @see Delete
*/
public static void updatePlugin(String path_to_update, boolean debug) {
File plugin_path = new File(path_to_update);
try {
if (!plugin_path.exists() || !plugin_path.isFile())
throw new IsNotFileException(path_to_update);
// Setting up the PluginManger from jspf
PluginManager pm = PluginManagerFactory.createPluginManager();
// adding the path to verify
pm.addPluginsFrom(plugin_path.toURI());
// getting the class which implements our plugin interface
Corpoplugins extension = pm.getPlugin(Corpoplugins.class);
Pluginspecs new_plugin_specs;
configString = ActionBase.getConfig(); // Get the configuration file
new_plugin_specs = extension.getClass()
.getAnnotation(Pluginspecs.class); // Get the Pluginspecs from jar
if (debug) System.out.print(Flags.getString("install.plugin-specs")
+ extension.getClass());
if (new_plugin_specs == null)
throw new PluginSpecsNotFoundException(extension.getClass()
.toString()); // if there is no annotations
if (debug) {
System.out.println(Flags.getString("done"));
System.out.print(Flags.getString("update.verification"));
}
if (!Install.isInstalled(new_plugin_specs.name()))
throw new PluginNotFoundException(new_plugin_specs.name()); // if the plugin is NOT installed
if (debug) {
System.out.println(Flags.getString("done"));
System.out.print(Flags.getString("install.dependencies"));
}
Install.hasDependencies(new_plugin_specs); // if all the dependencies are present
if (debug) {
System.out.println(Flags.getString("done"));
System.out.print(Flags.getString("update.version"));
}
if (!compareVersion(new_plugin_specs))//if the plugin installed is newer
throw new PluginIsNewer(new_plugin_specs.name());
if (debug) {
System.out.println(Flags.getString("done"));
}
Delete.deletePlugin(new_plugin_specs.name(), debug);
Install.installPlugin(path_to_update, debug);
} catch (IOException | PluginNotFoundException | PluginSpecsNotFoundException |
PluginDependenciesNotPresentException | IsNotFileException | PluginIsNewer e) {
System.err.println(e.getMessage());
}
}
示例3: pluginDetails
import net.xeoh.plugins.base.PluginManager; //导入方法依赖的package包/类
/**
* Gives the specifications of the given plugin, used in --help
*
* @param plugin_name String the name of the plugin.
* @param debug true to display debug information
* @return The plugin specifications.
*/
public static String pluginDetails(String plugin_name, boolean debug) {
String plugin = EMPTYSTRING;
// Setting up the PluginManger from jspf
PluginManager pm = PluginManagerFactory.createPluginManager();
// adding the path to verify
pm.addPluginsFrom(new File(PLUGINDIRECTORY + plugin_name.toLowerCase() + System.getProperty("file.separator")).toURI());
// getting the class which implements our plugin interface
Corpoplugins extension = pm.getPlugin(Corpoplugins.class);
try {
configString = getConfig();
Delete.findPluginLine(plugin_name);
if (debug) System.out.print(Flags.getString("install.plugin-specs")
+ extension.getClass());
Pluginspecs plugin_specs = extension.getClass()
.getAnnotation(Pluginspecs.class);
if (plugin_specs == null)
throw new PluginSpecsNotFoundException(extension.getClass()
.toString()); // if there is no annotations
if (debug) System.out.println(Flags.getString("done"));
plugin += "Plugin name: " + plugin_specs.name() + System.lineSeparator();
plugin += "Description: " + plugin_specs.description() + System.lineSeparator();
plugin += "Version: " + plugin_specs.version() + System.lineSeparator();
plugin += "Author: " + plugin_specs.author() + System.lineSeparator();
plugin += "Supported formats: ";
for (String format : plugin_specs.extensions()) {
plugin += " ." + format;
}
plugin += System.lineSeparator() + "Dependencies: ";
for (String dependency : plugin_specs.dependencies()) {
plugin += dependency + ", ";
}
} catch (PluginSpecsNotFoundException | IOException | PluginNotFoundException e) {
System.err.println(e.getMessage());
}
return plugin;
}
示例4: installPlugin
import net.xeoh.plugins.base.PluginManager; //导入方法依赖的package包/类
/**
* Will install the specified plugin. Will if the plugin is extended from the Corpoplugin interface,
* check if it's aready installed, then will copy it under : installation_folder/plugin_name/
*
* @param path_to_install String Is the path to the plugin to install
* @param debug boolean Will display the progression of the action if true.
* @see Delete
*/
public static void installPlugin(String path_to_install, boolean debug) {
File plugin_path = new File(path_to_install);
try {
if (!plugin_path.exists() || !plugin_path.isFile())
throw new IsNotFileException((path_to_install));
// Setting up the PluginManger from jspf
PluginManager pm = PluginManagerFactory.createPluginManager();
// adding the path to verify
pm.addPluginsFrom(plugin_path.toURI());
// getting the class which implements our plugin interface
Corpoplugins extension = pm.getPlugin(Corpoplugins.class);
Pluginspecs plugin_specs;
configString = ActionBase.getConfig(); // Get the configuration file
plugin_specs = extension.getClass()
.getAnnotation(Pluginspecs.class); // Get the Pluginspecs from jar
if (debug) System.out.print(Flags.getString("install.plugin-specs")
+ extension.getClass());
if (plugin_specs == null)
throw new PluginSpecsNotFoundException(extension.getClass()
.toString()); // if there is no annotations
if (debug) System.out.println(Flags.getString("done"));
if (debug) System.out.print(Flags.getString("install.verification"));
if (isInstalled(plugin_specs.name()))
throw new PluginIsInstalledException(plugin_specs.name()); // if the plugin is already installed
if (debug) System.out.println(Flags.getString("done"));
if (debug) System.out.print(Flags.getString("install.dependencies"));
hasDependencies(plugin_specs); // if all the dependencies are present
if (debug) System.out.println(Flags.getString("done"));
if (debug) System.out.print(Flags.getString("install.copyjar")
+ plugin_specs.name().toLowerCase()
+ Flags.getString("install.copyjar2"));
copyPlugintoDirectory(plugin_specs.name(), plugin_path);
if (debug) System.out.println(Flags.getString("done"));
if (debug) System.out.print(Flags.getString("install.adding-properties"));
addPlugintoConfig(plugin_specs);
if (debug) System.out.println(Flags.getString("done"));
System.out.println(Flags.getString("install.success"));
} catch (IOException | PluginDependenciesNotPresentException | PluginIsInstalledException
| PluginSpecsNotFoundException | IsNotJarException | IsNotFileException e) {
System.err.println(e.getMessage());
}
}