net.sourceforge.cruisecontrol
Class ProjectXMLHelper

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.ProjectXMLHelper
All Implemented Interfaces:
ProjectHelper

public class ProjectXMLHelper
extends java.lang.Object
implements ProjectHelper

Instantiates a project from a JDOM Element. Supports the use of Ant-like patterns in attribute values that look like this: ${propertyname}


Constructor Summary
ProjectXMLHelper()
           
ProjectXMLHelper(java.util.Map projectProperties, PluginRegistry projectPlugins)
           
 
Method Summary
 java.lang.Object configurePlugin(org.jdom.Element pluginElement, boolean skipChildElements)
          TODO: also check that instantiated class implements/extends correct interface/class
 java.lang.Object getConfiguredPlugin(PluginXMLHelper pluginHelper, java.lang.String pluginName)
          Get a [partially] configured plugin instance given its plugin name.
static void parsePropertiesInElement(org.jdom.Element element, java.util.Map props, boolean failIfMissing)
           
static java.lang.String parsePropertiesInString(java.util.Map props, java.lang.String string, boolean failIfMissing)
          Parses a string by replacing all occurrences of a property macro with the resolved value of the property.
static void registerProperty(java.util.Map props, org.jdom.Element propertyElement, boolean failIfMissing)
          Registers one or more properties as defined in a property element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectXMLHelper

public ProjectXMLHelper()

ProjectXMLHelper

public ProjectXMLHelper(java.util.Map projectProperties,
                        PluginRegistry projectPlugins)
Method Detail

configurePlugin

public java.lang.Object configurePlugin(org.jdom.Element pluginElement,
                                        boolean skipChildElements)
                                 throws CruiseControlException
TODO: also check that instantiated class implements/extends correct interface/class

Specified by:
configurePlugin in interface ProjectHelper
Throws:
CruiseControlException

getConfiguredPlugin

public java.lang.Object getConfiguredPlugin(PluginXMLHelper pluginHelper,
                                            java.lang.String pluginName)
                                     throws CruiseControlException
Get a [partially] configured plugin instance given its plugin name.

Parameters:
pluginName -
Returns:
null if the plugin was never configured.
Throws:
CruiseControlException - if the registered class cannot be loaded, if a property cannot be resolved, if the plugin configuration fails

registerProperty

public static void registerProperty(java.util.Map props,
                                    org.jdom.Element propertyElement,
                                    boolean failIfMissing)
                             throws CruiseControlException
Registers one or more properties as defined in a property element.

Parameters:
propertyElement - The element from which we will register properties
Throws:
CruiseControlException

parsePropertiesInString

public static java.lang.String parsePropertiesInString(java.util.Map props,
                                                       java.lang.String string,
                                                       boolean failIfMissing)
                                                throws CruiseControlException
Parses a string by replacing all occurrences of a property macro with the resolved value of the property. Nested macros are allowed - the inner most macro will be resolved first, moving out from there.

Parameters:
string - The string to be parsed
Returns:
The parsed string
Throws:
CruiseControlException - if a property cannot be resolved

parsePropertiesInElement

public static void parsePropertiesInElement(org.jdom.Element element,
                                            java.util.Map props,
                                            boolean failIfMissing)
                                     throws CruiseControlException
Throws:
CruiseControlException