From da6754202d2cd8af14d12cc974410e43f49b7376 Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Wed, 19 Aug 2015 17:48:23 +0200
Subject: [PATCH] formatting; added runNow for testing purposes

---
 .../teetime/framework/AbstractRunnableStage.java  | 15 +++++++++------
 .../teetime/framework/RunnableProducerStage.java  |  5 +++++
 .../queue/takestrategy/SCBundleTakeStrategy.java  | 15 +++++++++++++++
 3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/main/java/teetime/framework/AbstractRunnableStage.java b/src/main/java/teetime/framework/AbstractRunnableStage.java
index 2cb63c88..01bed6df 100644
--- a/src/main/java/teetime/framework/AbstractRunnableStage.java
+++ b/src/main/java/teetime/framework/AbstractRunnableStage.java
@@ -40,7 +40,9 @@ abstract class AbstractRunnableStage implements Runnable {
 	@Override
 	public final void run() {
 		final Stage stage = this.stage; // should prevent the stage to be reloaded after a volatile read
-		this.logger.debug("Executing runnable stage...");
+		final Logger logger = this.logger; // should prevent the logger to be reloaded after a volatile read
+
+		logger.debug("Executing runnable stage...");
 
 		try {
 			try {
@@ -53,17 +55,17 @@ abstract class AbstractRunnableStage implements Runnable {
 						executeStage();
 					}
 				} catch (TerminateException e) {
-					this.stage.abort();
+					stage.abort();
 					stage.getOwningContext().abortConfigurationRun();
 				} finally {
 					afterStageExecution();
 				}
 
 			} catch (RuntimeException e) {
-				this.logger.error(TERMINATING_THREAD_DUE_TO_THE_FOLLOWING_EXCEPTION, e);
+				logger.error(TERMINATING_THREAD_DUE_TO_THE_FOLLOWING_EXCEPTION, e);
 				throw e;
 			} catch (InterruptedException e) {
-				this.logger.error(TERMINATING_THREAD_DUE_TO_THE_FOLLOWING_EXCEPTION, e);
+				logger.error(TERMINATING_THREAD_DUE_TO_THE_FOLLOWING_EXCEPTION, e);
 			}
 		} finally {
 			if (stage.getTerminationStrategy() != TerminationStrategy.BY_INTERRUPT) {
@@ -71,8 +73,9 @@ abstract class AbstractRunnableStage implements Runnable {
 			}
 		}
 
-		logger.debug("Finished runnable stage. (" + stage.getId() + ")");
-
+		if (logger.isDebugEnabled()) {
+			logger.debug("Finished runnable stage. (" + stage.getId() + ")");
+		}
 	}
 
 	protected abstract void beforeStageExecution() throws InterruptedException;
diff --git a/src/main/java/teetime/framework/RunnableProducerStage.java b/src/main/java/teetime/framework/RunnableProducerStage.java
index 61cecd07..76a9831b 100644
--- a/src/main/java/teetime/framework/RunnableProducerStage.java
+++ b/src/main/java/teetime/framework/RunnableProducerStage.java
@@ -53,4 +53,9 @@ public class RunnableProducerStage extends AbstractRunnableStage {
 		logger.trace("waitForStartingSignal");
 		startSemaphore.acquire();
 	}
+
+	void runNow() {
+		triggerStartingSignal();
+		super.run();
+	}
 }
diff --git a/src/main/java/teetime/util/framework/concurrent/queue/takestrategy/SCBundleTakeStrategy.java b/src/main/java/teetime/util/framework/concurrent/queue/takestrategy/SCBundleTakeStrategy.java
index 20c1fae1..6690c524 100644
--- a/src/main/java/teetime/util/framework/concurrent/queue/takestrategy/SCBundleTakeStrategy.java
+++ b/src/main/java/teetime/util/framework/concurrent/queue/takestrategy/SCBundleTakeStrategy.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime)
+ *
+ * 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.util.framework.concurrent.queue.takestrategy;
 
 import java.util.Queue;
-- 
GitLab