X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FDefaultExecutionFlow.java;h=bf1cf99a5f5efc8e3b3da117407ce58c831b0537;hb=3781dcd363f0f6265fae0ac758fd40cf4254ebc9;hp=0d88c96fde2fddd28c2c1d1e04829765b7c64bb4;hpb=d2affd4fedaef80edc403ce9c9bcaef70397d052;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java index 0d88c96fd..bf1cf99a5 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.argeo.slc.core.execution; import java.util.ArrayList; @@ -15,6 +31,7 @@ import org.argeo.slc.execution.ExecutionSpec; import org.argeo.slc.execution.ExecutionSpecAttribute; import org.argeo.slc.structure.StructureAware; import org.argeo.slc.structure.StructureRegistry; +import org.springframework.aop.scope.ScopedObject; import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.validation.MapBindingResult; @@ -91,7 +108,7 @@ public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean, public void run() { try { for (Runnable executable : executables) { - executable.run(); + this.doExecuteRunnable(executable); } } catch (RuntimeException e) { if (failOnError) @@ -107,18 +124,32 @@ public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean, } } + public void doExecuteRunnable(Runnable runnable) { + runnable.run(); + } + @SuppressWarnings(value = { "unchecked" }) public void afterPropertiesSet() throws Exception { + if (path == null) { + if (name.charAt(0) == '/') { + path = name.substring(0, name.lastIndexOf('/')); + } + } + if (path != null) { for (Runnable executable : executables) { - if (executable instanceof StructureAware) { + if (executable instanceof StructureAware + && !(executable instanceof ScopedObject)) { ((StructureAware) executable).notifyCurrentPath( registry, new TreeSPath(path)); } else if (executable instanceof DefaultExecutionFlow) { // so we don't need to have DefaultExecutionFlow // implementing StructureAware + // FIXME: probably has side effects DefaultExecutionFlow flow = (DefaultExecutionFlow) executable; - flow.setPath(path + '/' + flow.getName()); + String newPath = path + '/' + flow.getName(); + flow.setPath(newPath); + log.warn(newPath + " was forcibly set on " + flow); } } } @@ -172,14 +203,21 @@ public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean, .getAttributes().get(key).getValue() != null); } + @Override public String toString() { - return new StringBuffer("Flow ").append(name).toString(); + return new StringBuffer("Execution flow ").append(name).toString(); } + @Override public boolean equals(Object obj) { return ((ExecutionFlow) obj).getName().equals(name); } + @Override + public int hashCode() { + return name.hashCode(); + } + public String getPath() { return path; }