/** * Answer if the name is a missing plugin's command name. If a bnd file * contains the command name of a plugin, and that plugin is not available, * then an error is reported during manifest calculation. This allows the * plugin to fail to load when it is not needed. * * We first get the plugins to ensure it is properly initialized. * * @param name * @return */ public boolean isMissingPlugin(String name) { getPlugins(); return missingCommand != null && missingCommand.contains(name); }
/** * Answer if the name is a missing plugin's command name. If a bnd file * contains the command name of a plugin, and that plugin is not available, then * an error is reported during manifest calculation. This allows the * plugin to fail to load when it is not needed. * * We first get the plugins to ensure it is properly initialized. * * @param name * @return */ public boolean isMissingPlugin(String name) { getPlugins(); return missingCommand != null && missingCommand.contains(name); }
/** * Returns the first plugin it can find of the given type. * * @param <T> * @param clazz * @return */ public <T> T getPlugin(Class<T> clazz) { Set<Object> all = getPlugins(); for (Object plugin : all) { if (clazz.isInstance(plugin)) return clazz.cast(plugin); } return null; }
/** * Return a list of plugins that implement the given class. * * @param clazz * Each returned plugin implements this class/interface * @return A list of plugins */ public <T> List<T> getPlugins(Class<T> clazz) { List<T> l = new ArrayList<T>(); Set<Object> all = getPlugins(); for (Object plugin : all) { if (clazz.isInstance(plugin)) l.add(clazz.cast(plugin)); } return l; }
/** * Return a list of plugins that implement the given class. * * @param clazz * Each returned plugin implements this class/interface * @return A list of plugins */ public <T> List<T> getPlugins(Class<T> clazz) { List<T> l = new ArrayList<T>(); List<Object> all = getPlugins(); for (Object plugin : all) { if (clazz.isInstance(plugin)) l.add(clazz.cast(plugin)); } return l; }
/** * Return a list of plugins. Plugins are defined with the -plugin command. * They are class names, optionally associated with attributes. Plugins can * implement the Plugin interface to see these attributes. * * Any object can be a plugin. * * @return */ protected synchronized Set<Object> getPlugins() { if (this.plugins != null) return this.plugins; missingCommand = new HashSet<String>(); Set<Object> list = new LinkedHashSet<Object>(); // The owner of the plugin is always in there. list.add(this); setTypeSpecificPlugins(list); if (parent != null) list.addAll(parent.getPlugins()); // We only use plugins now when they are defined on our level // and not if it is in our parent. We inherit from our parent // through the previous block. if (properties.containsKey(PLUGIN)) { String spe = getProperty(PLUGIN); if (spe.equals(NONE)) return new LinkedHashSet<Object>(); loadPlugins(list, spe); } return this.plugins = list; }
public File[] get(String bsn, String version) throws Exception { VersionRange range = new VersionRange("0"); if (version != null) range = new VersionRange(version); List<BsnToMavenPath> plugins = ((Processor) reporter).getPlugins(BsnToMavenPath.class); if ( plugins.isEmpty()) plugins.add(this); for (BsnToMavenPath cvr : plugins) { String[] paths = cvr.getGroupAndArtifact(bsn); if (paths != null) { File[] files = find(paths[0], paths[1], range); if (files != null) return files; } } reporter.trace("Cannot find in maven: %s-%s", bsn, version); return null; }
public File[] get(String bsn, String version) throws Exception { VersionRange range = new VersionRange("0"); if (version != null) range = new VersionRange(version); List<BsnToMavenPath> plugins = ((Processor) reporter) .getPlugins(BsnToMavenPath.class); for (BsnToMavenPath cvr : plugins) { String[] paths = cvr.getGroupAndArtifact(bsn); if (paths != null) { File[] files = find(paths[0], paths[1], range); if (files != null) return files; } } reporter.trace("Cannot find in maven: %s-%s", bsn, version); return null; }