diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-09 23:15:02 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-09 23:15:02 +0000 |
commit | 2851fd54c5ccd85d068c15ec3471b553b0052307 (patch) | |
tree | cc007c5020eded7ffe63adce2d7a58a138bd1f71 /java/sca/modules | |
parent | 212e0b44dac194a5fa9a37c386985fa43bbf016b (diff) |
Defer the creation of WorkManager to avoid the JNDI lookup
Also clear the openejb related system properties to avoid warnings in JNDI lookup
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@675379 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r-- | java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java index b331517c85..90c13e6da8 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java @@ -56,16 +56,22 @@ public class Jsr237WorkScheduler implements WorkScheduler { * @param jsr237WorkManager JSR 237 work manager. */ public Jsr237WorkScheduler() { - + } + + private synchronized WorkManager getWorkManager() { + if (jsr237WorkManager != null) { + return jsr237WorkManager; + } try { - InitialContext ctx = new InitialContext(); - jsr237WorkManager = (WorkManager) ctx.lookup("java:comp/env/wm/TuscanyWorkManager"); + InitialContext ctx = new InitialContext(); + jsr237WorkManager = (WorkManager)ctx.lookup("java:comp/env/wm/TuscanyWorkManager"); } catch (NamingException e) { // ignore } if (jsr237WorkManager == null) { jsr237WorkManager = new ThreadPoolWorkManager(10); } + return jsr237WorkManager; } /** @@ -94,10 +100,10 @@ public class Jsr237WorkScheduler implements WorkScheduler { Jsr237Work<T> jsr237Work = new Jsr237Work<T>(work); try { if (listener == null) { - jsr237WorkManager.schedule(jsr237Work); + getWorkManager().schedule(jsr237Work); } else { Jsr237WorkListener<T> jsr237WorkListener = new Jsr237WorkListener<T>(listener, work); - jsr237WorkManager.schedule(jsr237Work, jsr237WorkListener); + getWorkManager().schedule(jsr237Work, jsr237WorkListener); } } catch (IllegalArgumentException ex) { if (listener != null) { |