From: <jbo...@li...> - 2005-12-18 22:36:51
|
Author: wrzep Date: 2005-12-18 17:36:44 -0500 (Sun, 18 Dec 2005) New Revision: 1851 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/InvalidPluginPropertiesException.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java Log: comments, comments, comments http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/InvalidPluginPropertiesException.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/InvalidPluginPropertiesException.java 2005-12-18 22:16:03 UTC (rev 1850) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/InvalidPluginPropertiesException.java 2005-12-18 22:36:44 UTC (rev 1851) @@ -1,5 +1,9 @@ package org.jboss.forge.status.plugins; +/** + * @author pawel + * Signals that properties passed to the plugin are missed or incorrect. + */ public class InvalidPluginPropertiesException extends Exception { public InvalidPluginPropertiesException(String msg) { Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java 2005-12-18 22:16:03 UTC (rev 1850) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/KosmosStatusPlugin.java 2005-12-18 22:36:44 UTC (rev 1851) @@ -35,14 +35,21 @@ /** * @author Pawel Wrzeszcz +* Superclass for kosmos-service based plugins. */ public abstract class KosmosStatusPlugin extends StatusPlugin { protected abstract String getKosmosServiceProperty(); - private Map<String,Map> projectsMaps; + /** + * Binds project ids with kosmos-service specyfic Maps. + */ + private Map<String,Map> projectMaps; + /** + * Kosmos service adress. + */ protected String serviceURL; protected Logger log; @@ -51,17 +58,27 @@ super(); log = Logger.getLogger(this.getClass()); - projectsMaps = new HashMap<String,Map>(); + projectMaps = new HashMap<String,Map>(); } + /* (non-Javadoc) + * @see org.jboss.forge.status.plugins.StatusPlugin#init(java.lang.String, java.lang.String, org.jboss.forge.common.projects.Projects, org.w3c.dom.Node) + */ public void init(String name, String id, Projects projects, Node propertiesNode) throws InvalidPluginPropertiesException { super.init(name, id, projects,propertiesNode); - Map<String,String> properties = XmlTools.getMapFromNodeElements(propertiesNode); - getProperties(properties); + + getServiceProperty(propertiesNode); } - private void getProperties(Map<String,String> properties) throws InvalidPluginPropertiesException { + /** + * Gets service URL from the given Node with plugin properites. + * + * @param propertiesNode Node with plugin specyfic properties + * @throws InvalidPluginPropertiesException + */ + private void getServiceProperty(Node propertiesNode) throws InvalidPluginPropertiesException { + Map<String,String> properties = XmlTools.getMapFromNodeElements(propertiesNode); if (properties.isEmpty()) { throw new InvalidPluginPropertiesException("Missing properties for " + getName() + " plugin."); @@ -75,28 +92,39 @@ } } + /** + * For the given service specyfic Map, computes plugin specyfic value. + * + * @param projectMap service specyfic Map + * @return Plugin value + */ protected abstract int getPluginSpecyficValue(Map projectMap); + + + /** + * @return Default Plugin value, when service is not specified. + */ protected abstract int getPluginSpecyficDefaultValue(); + /** + * Returns service specyfic Map for the project, + * which is equals given <code>projectId</code> + * + * @param projectId + * @return service specyfic Map + */ protected abstract Map getProjectMap(String projectId); - protected void printMap(Map map) { //debug - if (map != null) { - - for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { - Object obj = (Object) iter.next(); - System.out.println("object: " + obj + " binding: " + map.get(obj)); - } - } - } - + /* (non-Javadoc) + * @see org.jboss.forge.status.Plugin#getValue(java.lang.String) + */ public int getValue(String projectId) { - if (!projectsMaps.containsKey(projectId)) { - projectsMaps.put(projectId, getProjectMap(projectId)); + if (!projectMaps.containsKey(projectId)) { + projectMaps.put(projectId, getProjectMap(projectId)); } - Map projectMap = projectsMaps.get(projectId); + Map projectMap = projectMaps.get(projectId); if (projectMap == null) { return getPluginSpecyficDefaultValue(); @@ -105,4 +133,13 @@ return getPluginSpecyficValue(projectMap); } + protected void printMap(Map map) { //debug + if (map != null) { + + for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { + Object obj = (Object) iter.next(); + System.out.println("object: " + obj + " binding: " + map.get(obj)); + } + } + } } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java 2005-12-18 22:16:03 UTC (rev 1850) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java 2005-12-18 22:36:44 UTC (rev 1851) @@ -29,12 +29,23 @@ /** * @author Pawel Wrzeszcz +* Superclass for the status plugins in the Status Matrix. */ public abstract class StatusPlugin extends Plugin { + /** + * Projects present in the Status Matrix. + */ protected Projects projects; + /** + * @param name Plugin name + * @param id Plugin id + * @param projects Projects present in the Status Matrix + * @param propertiesNode Node with plugin specyfic properties + * @throws InvalidPluginPropertiesException + */ public void init(String name, String id, Projects projects, Node propertiesNode) throws InvalidPluginPropertiesException { this.projects = projects; init(name, id, propertiesNode); |