summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java13
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java2
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler4
-rw-r--r--sca-java-2.x/trunk/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java2
4 files changed, 14 insertions, 7 deletions
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java
index 9e6f3b3087..380ca818c5 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java
@@ -20,7 +20,9 @@ package org.apache.tuscany.sca.core.work.impl;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.Map;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.work.NotificationListener;
import org.apache.tuscany.sca.work.WorkScheduler;
@@ -43,13 +45,20 @@ public class DefaultWorkScheduler implements WorkScheduler, LifeCycleListener {
* Underlying JSR-237 work manager
*/
private ThreadPoolWorkManager jsr237WorkManager;
+ private int maxThreads = 0;
/**
* Initializes the JSR 237 work manager.
*
* @param jsr237WorkManager JSR 237 work manager.
*/
- public DefaultWorkScheduler() {
+ public DefaultWorkScheduler(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ if (attributes != null) {
+ String value = attributes.get("maxThreads");
+ if (value != null) {
+ maxThreads = Integer.parseInt(value.trim());
+ }
+ }
}
private synchronized ThreadPoolWorkManager getWorkManager() {
@@ -63,7 +72,7 @@ public class DefaultWorkScheduler implements WorkScheduler, LifeCycleListener {
// // ignore
// }
if (jsr237WorkManager == null) {
- jsr237WorkManager = new ThreadPoolWorkManager(0);
+ jsr237WorkManager = new ThreadPoolWorkManager(maxThreads);
}
return jsr237WorkManager;
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java
index e7728ca9a9..1cd70c75de 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java
@@ -66,7 +66,7 @@ public class ThreadPoolWorkManager {
// creates daemon threads.
executor = Executors.newCachedThreadPool(factory);
} else {
- executor = Executors.newFixedThreadPool(threadPoolSize);
+ executor = Executors.newFixedThreadPool(threadPoolSize, factory);
}
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler b/sca-java-2.x/trunk/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler
index 576e52d8ea..90e887739a 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler
+++ b/sca-java-2.x/trunk/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler
@@ -14,6 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-
-org.apache.tuscany.sca.core.work.impl.DefaultWorkScheduler
-
+org.apache.tuscany.sca.core.work.impl.DefaultWorkScheduler;maxThreads=0
diff --git a/sca-java-2.x/trunk/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java b/sca-java-2.x/trunk/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java
index c0f35d427c..4ec0f55867 100644
--- a/sca-java-2.x/trunk/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java
+++ b/sca-java-2.x/trunk/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java
@@ -45,7 +45,7 @@ public class Jsr237WorkSchedulerTestCase {
*/
@BeforeClass
public static void setup() {
- workSchedular = new DefaultWorkScheduler();
+ workSchedular = new DefaultWorkScheduler(null, null);
}
/**