1 15 package org.apache.hivemind.xml.definition.impl; 16 17 import java.util.ArrayList ; 18 import java.util.Collections ; 19 import java.util.List ; 20 21 import org.apache.hivemind.Element; 22 import org.apache.hivemind.definition.ConfigurationParser; 23 import org.apache.hivemind.definition.ConfigurationParserDefinition; 24 import org.apache.hivemind.definition.ConfigurationPointDefinition; 25 import org.apache.hivemind.definition.Contribution; 26 import org.apache.hivemind.definition.ContributionContext; 27 28 35 public final class XmlContributionImpl implements Contribution 36 { 37 private String _contributingModuleId; 38 39 private List _elements; 40 41 public XmlContributionImpl(String moduleId, List elements) 42 { 43 _contributingModuleId = moduleId; 44 _elements = elements; 45 } 46 47 public String getContributingModuleId() 48 { 49 return _contributingModuleId; 50 } 51 52 public void addElements(List elements) 53 { 54 if (_elements == null) 55 _elements = new ArrayList (elements); 56 else 57 _elements.addAll(elements); 58 } 59 60 public List getElements() 61 { 62 if (_elements == null) 63 return Collections.EMPTY_LIST; 64 65 return _elements; 66 } 67 68 71 public void contribute(ContributionContext context) 72 { 73 ConfigurationPointDefinition cpd = context.getConfigurationPoint() 75 .getConfigurationPointDefinition(); 76 ConfigurationParserDefinition parserDef = cpd.getParser(HiveMindSchemaParser.INPUT_FORMAT_NAME); 77 if (parserDef == null) 78 { 79 context.mergeContribution(getElements()); 81 } else { 82 ConfigurationParser parser = parserDef.getParserConstructor().constructParser(context); 84 Object contribution = parser.parse(context, getElements()); 85 context.mergeContribution(contribution); 86 } 87 } 88 89 } | Popular Tags |