From fa15e0d0a70b92ba12153f5d5d02d7e900fc25d2 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Mon, 22 Oct 2012 10:38:04 +0000 Subject: [PATCH] SLC Flow Spring XML format v1.2 git-svn-id: https://svn.argeo.org/slc/trunk@5629 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../META-INF/spring/helloworld.xml | 10 +- demo/slc_demo_rcp.properties | 3 - .../META-INF/spring.schemas | 3 +- .../xml/FlowBeanDefinitionParser.java | 28 +- .../xml/SpecBeanDefinitionParser.java | 19 +- .../slc/core/execution/xml/slc-flow-1.2.xsd | 401 ++++++++++++++++++ .../org.argeo.slc.launcher/build.properties | 1 - .../JcrExecutionModulesListener.java | 9 +- .../slc/osgi/deploy/OsgiResourceSet.java | 4 + .../org/argeo/slc/lib/linux/redhat.xml | 55 ++- 10 files changed, 488 insertions(+), 45 deletions(-) create mode 100644 runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd diff --git a/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml b/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml index 605dd087a..0d249dc9c 100644 --- a/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml +++ b/demo/modules/org.argeo.slc.demo.minimal/META-INF/spring/helloworld.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd"> + http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-1.2.xsd"> @@ -11,12 +11,12 @@ - - - - + Print Hello World! with variable + + + diff --git a/demo/slc_demo_rcp.properties b/demo/slc_demo_rcp.properties index b0e35fd92..e71130993 100644 --- a/demo/slc_demo_rcp.properties +++ b/demo/slc_demo_rcp.properties @@ -8,7 +8,6 @@ org.argeo.slc.agent,\ org.argeo.slc.agent.jcr,\ org.argeo.slc.support.maven,\ org.argeo.slc.server.repo,\ -org.argeo.infra.slc.dist,\ # Start internal web server #org.argeo.dep.osgi.catalina.start,\ @@ -19,8 +18,6 @@ slc.executionModules=org.argeo.slc.demo.ant,\ org.argeo.slc.demo.basic,\ org.argeo.slc.demo.minimal,\ -#spring.security.strategy=MODE_INHERITABLETHREADLOCAL - eclipse.application=org.argeo.slc.client.rcp.application org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.slcExecutionPerspective #org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.dist.distributionPerspective diff --git a/runtime/org.argeo.slc.core/META-INF/spring.schemas b/runtime/org.argeo.slc.core/META-INF/spring.schemas index 07987bbdd..229d4c5f6 100644 --- a/runtime/org.argeo.slc.core/META-INF/spring.schemas +++ b/runtime/org.argeo.slc.core/META-INF/spring.schemas @@ -1,2 +1,3 @@ -http\://www.argeo.org/schema/slc-flow.xsd=org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd +http\://www.argeo.org/schema/slc-flow.xsd=org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd +http\://www.argeo.org/schema/slc-flow-1.2.xsd=org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd http\://www.argeo.org/schema/slc-flow-0.12.xsd=org/argeo/slc/core/execution/xml/slc-flow-0.12.xsd 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 f2e961fbc..23b050748 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 @@ -18,6 +18,8 @@ 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; @@ -35,9 +37,10 @@ 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); @SuppressWarnings("unchecked") @Override @@ -45,7 +48,7 @@ public class FlowBeanDefinitionParser extends BeanDefinitionBuilder builder) { String path = element.getAttribute("path"); if (StringUtils.hasText(path)) - builder.addPropertyValue("path", path); + log.warn("The 'path' attribute is not used anymore to build flows"); String spec = element.getAttribute("spec"); if (StringUtils.hasText(spec)) @@ -63,14 +66,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); } @@ -91,6 +97,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()); @@ -116,8 +134,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); } diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java index 7aa6d9faa..704baccbb 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/xml/SpecBeanDefinitionParser.java @@ -33,6 +33,7 @@ import org.springframework.util.StringUtils; import org.springframework.util.xml.DomUtils; import org.w3c.dom.Element; +/** Interprets the tag */ public class SpecBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { private Log log = LogFactory.getLog(SpecBeanDefinitionParser.class); @@ -41,9 +42,9 @@ public class SpecBeanDefinitionParser extends @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { - builder.getBeanDefinition().setDescription(DomUtils.getChildElementValueByTagName(element, - "description")); - + builder.getBeanDefinition().setDescription( + DomUtils.getChildElementValueByTagName(element, "description")); + ManagedMap attributes = new ManagedMap(); // Primitives @@ -82,8 +83,8 @@ public class SpecBeanDefinitionParser extends for (Element choiceElem : choices) { BeanDefinitionBuilder choiceBuilder = BeanDefinitionBuilder .genericBeanDefinition(RefValueChoice.class); - choiceBuilder.addPropertyValue("name", choiceElem - .getAttribute("name")); + choiceBuilder.addPropertyValue("name", + choiceElem.getAttribute("name")); String desc = choiceElem.getAttribute("description"); if (StringUtils.hasText(desc)) choiceBuilder.addPropertyValue("description", desc); @@ -93,8 +94,8 @@ public class SpecBeanDefinitionParser extends refAttrBuilder.addPropertyValue("choices", choiceBeans); } - putInAttributes(attributes, refAttrElem, refAttrBuilder - .getBeanDefinition(), "ref"); + putInAttributes(attributes, refAttrElem, + refAttrBuilder.getBeanDefinition(), "ref"); } builder.addPropertyValue("attributes", attributes); @@ -102,9 +103,11 @@ public class SpecBeanDefinitionParser extends protected void addCommonProperties(Element element, ParserContext parserContext, BeanDefinitionBuilder specAttr) { + addBooleanProperty("isImmutable", specAttr, element); + addBooleanProperty("isConstant", specAttr, element); + addBooleanProperty("isHidden", specAttr, element); addBooleanProperty("isParameter", specAttr, element); addBooleanProperty("isFrozen", specAttr, element); - addBooleanProperty("isHidden", specAttr, element); Object value = NamespaceUtils.parseValue(element, parserContext, specAttr.getBeanDefinition(), "value"); diff --git a/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd b/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd new file mode 100644 index 000000000..308c38f21 --- /dev/null +++ b/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/execution/xml/slc-flow-1.2.xsd @@ -0,0 +1,401 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/runtime/org.argeo.slc.launcher/build.properties b/runtime/org.argeo.slc.launcher/build.properties index 7aa34daee..f0cc4f1b4 100644 --- a/runtime/org.argeo.slc.launcher/build.properties +++ b/runtime/org.argeo.slc.launcher/build.properties @@ -1,3 +1,2 @@ -additional.bundles = org.springframework.xml source.. = src/main/java/,\ src/main/resources/ diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java index b66f09405..f63acb5c0 100644 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java +++ b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java @@ -275,7 +275,11 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener, // execution spec ExecutionSpec executionSpec = efd.getExecutionSpec(); String esName = executionSpec.getName(); - if (!(esName == null || esName.equals(ExecutionSpec.INTERNAL_NAME))) { + if (esName == null || esName.equals(ExecutionSpec.INTERNAL_NAME) + || esName.contains("#")/* automatically generated bean name */) { + // internal spec node + mapExecutionSpec(flowNode, executionSpec); + } else { // reference spec node Node executionSpecsNode = moduleNode.hasNode(SLC_EXECUTION_SPECS) ? moduleNode .getNode(SLC_EXECUTION_SPECS) : moduleNode @@ -290,9 +294,6 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener, executionSpec.getDescription()); mapExecutionSpec(executionSpecNode, executionSpec); flowNode.setProperty(SLC_SPEC, executionSpecNode); - } else { - // internal spec node - mapExecutionSpec(flowNode, executionSpec); } // values diff --git a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/deploy/OsgiResourceSet.java b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/deploy/OsgiResourceSet.java index 8660eee1c..32073e78f 100644 --- a/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/deploy/OsgiResourceSet.java +++ b/runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/deploy/OsgiResourceSet.java @@ -24,6 +24,10 @@ import org.springframework.osgi.io.OsgiBundleResourceLoader; import org.springframework.osgi.io.OsgiBundleResourcePatternResolver; import org.springframework.osgi.util.OsgiBundleUtils; +/** + * Retrieves ressources from an OSGi bundle either the active one or another one + * referenced by its symbolic name. + */ public class OsgiResourceSet extends DefaultResourceSet implements BundleContextAware { private BundleContext bundleContext; diff --git a/runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/lib/linux/redhat.xml b/runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/lib/linux/redhat.xml index 66b85261f..98c1cc701 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/lib/linux/redhat.xml +++ b/runtime/org.argeo.slc.support.simple/src/main/resources/org/argeo/slc/lib/linux/redhat.xml @@ -1,34 +1,25 @@ - + + http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-1.2.xsd"> + @@ -53,4 +44,32 @@ + + + + + + + + + + + + authconfig + --enableldap + --enableldapauth + --enablecache + --enablemkhomedir + --ldapserver=@{ldapserver} + --ldapbasedn=@{ldapbasedn} + --passalgo=sha256 + --updateall + + + + + + + \ No newline at end of file -- 2.39.2