/** * Invoking this class from the command line just runs * <code>checkConfiguration</code> and shows the results. * There are no command-line options. * * @param argv the command line arguments given * @throws Exception if error */ public void main(String[] argv) throws Exception { checkConfiguration(); }
private boolean checkSelfNamed(Class cls) { Class sup = cls.getSuperclass(); if (sup == null) { return false; } else if (sup.equals(SelfNamedPlugin.class)) { return true; } else { return checkSelfNamed(sup); } }
private void checkNames(String iname) { try { configureNamedPlugin(iname); } catch (ClassNotFoundException ce) { // bogus classname should be old news by now. } }
Iterator<String> ii = allInterfaces.iterator(); while (ii.hasNext()) { checkClassname(ii.next(), "key interface or class"); } else { val = val.trim(); if (checkClassname(val, "implementation class")) { allImpls.put(val, val); } else { for (String val : vals) { if (checkClassname(val, "implementation class")) { allImpls.put(val, val); } else { for (String val : vals) { if (checkClassname(val, "selfnamed implementation class")) { allImpls.put(val, val); checkSelfNamed(val); checkNames(key); log.error("Named plugin config not found for: " + NAMED_PREFIX + key); } else { checkNames(key); for (String val : vals) { if (checkClassname(classname, "implementation class")) { allImpls.put(classname, classname);
for (int i = 0; i < classname.length; ++i) { log.debug("Adding Sequence plugin for interface= " + iname + ", class=" + classname[i]); result[i] = getAnonymousPlugin(classname[i]);
found += installNamedConfigs(iname, className, names); "Self-named plugin class \"" + classname + "\" returned null or empty name list!"); } else { found += installNamedConfigs(iname, classname, names);
/** * Returns an instance of the singleton (single) plugin implementing * the given interface. There must be exactly one single plugin * configured for this interface, otherwise the * <code>PluginConfigurationError</code> is thrown. * <p> * Note that this is the only "get plugin" method which throws an * exception. It is typically used at initialization time to set up * a permanent part of the system so any failure is fatal. * * @param interfaceClass interface Class object * @return instance of plugin * @throws PluginConfigurationError if no matching singleton plugin is configured. */ @Override public Object getSinglePlugin(Class interfaceClass) throws PluginConfigurationError, PluginInstantiationException { String iname = interfaceClass.getName(); // NOTE: module name is ignored, as single plugins ALWAYS begin with SINGLE_PREFIX String key = SINGLE_PREFIX + iname; // configuration format is prefix.<interface> = <classname> String classname = configurationService.getProperty(key); if (classname != null) { return getAnonymousPlugin(classname.trim()); } else { throw new PluginConfigurationError("No Single Plugin configured for interface \"" + iname + "\""); } }
/** * Returns whether a plugin exists which implements the specified interface * and has a specified name. If a matching plugin is found to be configured, * return true. If there is no matching plugin, return false. * * @param interfaceClass the interface class of the plugin * @param name under which the plugin implementation is configured. * @return true if plugin was found to be configured, false otherwise */ @Override public boolean hasNamedPlugin(Class interfaceClass, String name) throws PluginInstantiationException { try { String iname = interfaceClass.getName(); configureNamedPlugin(iname); String key = iname + SEP + name; return namedPluginClasses.get(key) != null; } catch (ClassNotFoundException e) { throw new PluginInstantiationException("Cannot load plugin class: " + e.toString(), e); } }
private boolean checkSelfNamed(String iname) { try { if (!checkSelfNamed(Class.forName(iname, true, loader))) { log.error("The class \"" + iname + "\" is NOT a subclass of SelfNamedPlugin but it should be!"); } } catch (ClassNotFoundException ce) { log.error("No class definition found for self-named class interface: \"" + iname + "\""); } return false; }
try { String iname = interfaceClass.getName(); configureNamedPlugin(iname); String prefix = iname + SEP; ArrayList<String> result = new ArrayList<String>();
try { String iname = interfaceClass.getName(); configureNamedPlugin(iname); String key = iname + SEP + name; String cname = namedPluginClasses.get(key);