X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2Fxml%2FFlowBeanDefinitionParser.java;h=ca64d12f5296802d0bd40f9316317a49c5eec4cc;hb=9ec3a30ade2e331102f3e38667129dc68bece661;hp=36d50dd75aff8c8b16999cccfd34ca77a9563a75;hpb=1fdb1b4e7b1d2b0cabb6483238301b857a6392fa;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/FlowBeanDefinitionParser.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/FlowBeanDefinitionParser.java index 36d50dd75..ca64d12f5 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/FlowBeanDefinitionParser.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/FlowBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Mathieu Baudier + * Copyright (C) 2007-2012 Argeo GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.argeo.slc.core.execution.xml; import java.util.ArrayList; import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.argeo.slc.SlcException; import org.argeo.slc.core.execution.DefaultExecutionFlow; import org.argeo.slc.execution.ExecutionFlow; @@ -36,18 +37,30 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +/** Interprets the tag */ public class FlowBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { - // private Log log = LogFactory.getLog(FlowBeanDefinitionParser.class); + private Log log = LogFactory.getLog(FlowBeanDefinitionParser.class); + + /** Whether the user has already be warned on path attribute usage. */ + private Boolean warnedAboutPathAttribute = false; @SuppressWarnings("unchecked") @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String path = element.getAttribute("path"); - if (StringUtils.hasText(path)) + if (StringUtils.hasText(path)) { builder.addPropertyValue("path", path); + // warns user only once + if (!warnedAboutPathAttribute) + log.warn("The path=\"\" attribute is deprecated" + + " and will be removed in a later release." + + " Use ."); + warnedAboutPathAttribute = true; + } + String spec = element.getAttribute("spec"); if (StringUtils.hasText(spec)) builder.getBeanDefinition().getConstructorArgumentValues() @@ -64,14 +77,17 @@ public class FlowBeanDefinitionParser extends builder.getBeanDefinition().setDescription( DomUtils.getChildElementValueByTagName(element, "description")); - List execElems = new ArrayList(); List argsElems = new ArrayList(); + List execElems = new ArrayList(); + List specElems = new ArrayList(); NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof Element) { if (DomUtils.nodeNameEquals(node, "arg")) argsElems.add((Element) node); + else if (DomUtils.nodeNameEquals(node, "spec")) + specElems.add((Element) node); else if (!DomUtils.nodeNameEquals(node, "description")) execElems.add((Element) node); } @@ -92,6 +108,18 @@ public class FlowBeanDefinitionParser extends .addGenericArgumentValue(args); } + // Execution specs + if (StringUtils.hasText(spec) && specElems.size() != 0) + throw new SlcException("A flow cannot have multiple specs"); + if (specElems.size() == 1) { + Object specObj = NamespaceUtils.parseBeanOrReference( + specElems.get(0), parserContext, + builder.getBeanDefinition()); + builder.getBeanDefinition().getConstructorArgumentValues() + .addGenericArgumentValue(specObj); + } else if (specElems.size() > 1) + throw new SlcException("A flow cannot have multiple specs"); + // Executables if (execElems.size() != 0) { ManagedList executables = new ManagedList(execElems.size()); @@ -117,8 +145,8 @@ public class FlowBeanDefinitionParser extends } catch (ClassNotFoundException e) { try { return (Class) Thread - .currentThread().getContextClassLoader().loadClass( - clss); + .currentThread().getContextClassLoader() + .loadClass(clss); } catch (ClassNotFoundException e1) { throw new SlcException("Cannot load class " + clss, e); }