public static Version getLatestAvailableVersion(RepositoryConnection cn) throws RepositoryException { List<Version> allVersions = new ArrayList<Version>(); RepositoryResult<Statement> res = cn.getStatements(MIVVI_DESKTOP_CLIENT, RdfUtil.Doap.release, null, false); while (res.hasNext()) { Statement stmt = res.next(); Resource v = RdfUtil.asResource(stmt.getObject()); if (v != null) { String rev = RdfUtil.getStringProperty(cn, v, RdfUtil.Doap.revision); if (rev != null) { try { allVersions.add(Version.parse(rev)); } catch (ParseException pe) { // Ignore this version } } } } Collections.sort(allVersions); if (allVersions.size() > 0) { return allVersions.get(allVersions.size() - 1); } else { return null; } }
@Override public Version unmarshal(String string) throws Exception { if (string == null) { return null; } else { return Version.parse(string); } }
private void load(Class<? extends Plugin> pluginClass, Properties properties) { // A plugin can be instantiated only once if (PLUGINS.containsKey(pluginClass)) { Application.LOGGER.error("Plugin for " + pluginClass + " is already loaded"); return; } Plugin plugin; try { plugin = pluginClass.newInstance(); } catch (InstantiationException e) { Application.LOGGER.error("Error while instantiating plugin from " + pluginClass, e); return; } catch (IllegalAccessException e) { Application.LOGGER.error( "Plugin class default constructor not accessible for " + pluginClass, e); return; } // register the plugin PLUGINS.put(pluginClass, plugin); // Load the properties if available if (properties != null) { plugin.name = properties.getProperty("plugin.name"); plugin.version = Version.parse(properties.getProperty("plugin.version")); plugin.description = properties.getProperty("plugin.description"); } else { // in case the application is loading the plugin directly plugin.name = pluginClass.getSimpleName(); plugin.version = null; plugin.description = null; } // Let the plugin initialize Application.LOGGER.trace( "Initializing Plugin - " + plugin.name + " - " + pluginClass.getCanonicalName()); plugin.onInit(app); }