diff --git a/.gitignore b/.gitignore index f070d111b06416efc88d69f2196138665ef7147f..4f8e9aab565ffac3c3536f482ba87cccd8dbc83d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,48 @@ -/bin -/target +# Mac OS .DS_Store +.AppleDouble +.LSOverride + + +# TeeTime specific teetime.log /src/main/resources/hugetext.txt + +# Java +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties + + +*.pydevproject +.metadata +.gradle +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index f7ab6fb3cf36816e88e20cc2aeff5602b519b997..0000000000000000000000000000000000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "src/site/markdown/wiki"] - path = src/site/markdown/wiki - url = gitlab@build.se.informatik.uni-kiel.de:chw/teetime.wiki.git diff --git a/pom.xml b/pom.xml index f4c48fb8430ec5e14dfd568e5d1544be848c13a0..e303bbd0ccaaeb918e0d8e17ad46fa0b0a2acf71 100644 --- a/pom.xml +++ b/pom.xml @@ -25,16 +25,12 @@ <java.version>1.6</java.version> <checkstyle.version>2.17</checkstyle.version> - <findbugs.version>3.0.2</findbugs.version> + <findbugs.version>3.0.3</findbugs.version> <pmd.version>3.5</pmd.version> <javadoc.version>2.10.3</javadoc.version> </properties> <distributionManagement> - <site> - <id>teetime.sf.net</id> - <url>scp://shell.sourceforge.net/home/project-web/teetime/htdocs</url> - </site> <snapshotRepository> <id>teetime-deployment</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> @@ -115,7 +111,7 @@ <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> - <version>1.7.12</version> + <version>1.7.13</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> @@ -143,6 +139,24 @@ <build> <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.6</version> + <configuration> + <descriptorRefs> + <descriptorRef>jar-with-dependencies</descriptorRef> + </descriptorRefs> + </configuration> + <executions> + <execution> + <id>make-assembly</id> <!-- this is used for inheritance merges --> + <phase>package</phase> <!-- bind to the packaging phase --> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> @@ -493,4 +507,4 @@ </profile> </profiles> -</project> +</project> \ No newline at end of file diff --git a/src/changes/changes.xml b/src/changes/changes.xml index fd90099190270595bea522d835b26a00bea3f6ca..3f2a18050756fb05673721b264108a771f27d6b0 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -9,6 +9,9 @@ <action dev="ntd" type="add" issue="163"> Introduced error codes. </action> + <action dev="ntd" type="add" issue="247"> + Configuration can now be executed from command line. + </action> </release> <release version="2.0" date="30.09.2015" description="Camellia Release"> <action dev="ntd" type="add" issue="93"> diff --git a/src/main/java/teetime/framework/Execution.java b/src/main/java/teetime/framework/Execution.java index 6a746f261fce9f89c42992a32737f594299ab991..7bf68323354bdeca93c2f703bcd392cde8d08cf5 100644 --- a/src/main/java/teetime/framework/Execution.java +++ b/src/main/java/teetime/framework/Execution.java @@ -15,12 +15,16 @@ */ package teetime.framework; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import teetime.framework.signal.ValidatingSignal; import teetime.framework.validation.AnalysisNotValidException; @@ -40,7 +44,7 @@ import teetime.framework.validation.AnalysisNotValidException; */ public final class Execution<T extends Configuration> { - // private static final Logger LOGGER = LoggerFactory.getLogger(Execution.class); + private static final Logger LOGGER = LoggerFactory.getLogger(Execution.class); private final T configuration; private final ConfigurationContext configurationContext; @@ -166,4 +170,30 @@ public final class Execution<T extends Configuration> { return this.configuration; } + private static List<Configuration> configLoader(final String... args) { + List<Configuration> instances = new ArrayList<Configuration>(); + for (String each : args) { + try { + Class<?> clazz = Class.forName(each); + Object obj = clazz.newInstance(); + if (obj instanceof Configuration) { + instances.add((Configuration) obj); + } + } catch (ClassNotFoundException e) { + LOGGER.error("Could not find class " + each); + } catch (InstantiationException e) { + LOGGER.error("Could not instantiate class " + each, e); + } catch (IllegalAccessException e) { + LOGGER.error("IllegalAccessException arised while instantiating class " + each, e); + } + } + return instances; + } + + public static void main(final String... args) { + List<Configuration> instances = configLoader(args); + for (Configuration configuration : instances) { + new Execution<Configuration>(configuration).executeBlocking(); // NOPMD + } + } } diff --git a/src/test/java/teetime/framework/ExecutionTest.java b/src/test/java/teetime/framework/ExecutionTest.java index 77943bb04d57556e1c4d32fa095ee4138b2f5679..3b080325fd65e72cc8237bd2bf28a28f37c8093b 100644 --- a/src/test/java/teetime/framework/ExecutionTest.java +++ b/src/test/java/teetime/framework/ExecutionTest.java @@ -205,4 +205,11 @@ public class ExecutionTest { new Execution<NameConfig>(configuration); // do not execute, but just initialize the execution } + @Test + public void mainMethod() { + assertFalse(MainMethodTestConfig.executed); + Execution.main("teetime.framework.MainMethodTestConfig"); + assertTrue(MainMethodTestConfig.executed); + } + } diff --git a/src/test/java/teetime/framework/MainMethodTestConfig.java b/src/test/java/teetime/framework/MainMethodTestConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..138a1bfb8e374c771b3dc1ab89a7d578ba2e65d4 --- /dev/null +++ b/src/test/java/teetime/framework/MainMethodTestConfig.java @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime-framework.github.io) + * + * 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 teetime.framework; + +import teetime.stage.InitialElementProducer; + +public class MainMethodTestConfig extends Configuration { + + public static boolean executed = false; + + public MainMethodTestConfig() { + connectPorts(new InitialElementProducer<Object>(new Object()).getOutputPort(), new StaticSetter().getInputPort()); + } + + private class StaticSetter extends AbstractConsumerStage<Object> { + + @Override + protected void execute(final Object element) { + executed = true; + } + + } + +}