Author: rmannibucau Date: Wed May 21 18:16:16 2014 New Revision: 1596638 URL: http://svn.apache.org/r1596638 Log: TOMEE-1219 keeping previous config for quartz pool size
Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/timer/DefaultTimerThreadPoolAdapter.java Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/timer/DefaultTimerThreadPoolAdapter.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/timer/DefaultTimerThreadPoolAdapter.java?rev=1596638&r1=1596637&r2=1596638&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/timer/DefaultTimerThreadPoolAdapter.java (original) +++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/timer/DefaultTimerThreadPoolAdapter.java Wed May 21 18:16:16 2014 @@ -18,11 +18,11 @@ package org.apache.openejb.core.timer; import org.apache.openejb.loader.SystemInstance; +import org.apache.openejb.quartz.SchedulerConfigException; +import org.apache.openejb.quartz.spi.ThreadPool; import org.apache.openejb.util.ExecutorBuilder; import org.apache.openejb.util.LogCategory; import org.apache.openejb.util.Logger; -import org.apache.openejb.quartz.SchedulerConfigException; -import org.apache.openejb.quartz.spi.ThreadPool; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; @@ -49,7 +49,7 @@ public class DefaultTimerThreadPoolAdapt /** * Mock support for property: org.quartz.threadPool.threadCount */ - private int threadCount = 3; + private int threadCount = Integer.parseInt(SystemInstance.get().getProperty(OPENEJB_TIMER_POOL_SIZE, "3")); /** * Mock support for property: org.quartz.threadPool.threadPriority @@ -58,28 +58,7 @@ public class DefaultTimerThreadPoolAdapt private final Object threadAvailableLock = new Object(); - private final boolean threadPoolExecutorUsed; - - public DefaultTimerThreadPoolAdapter() { - final TimerExecutor timerExecutor = SystemInstance.get().getComponent(TimerExecutor.class); - - if (timerExecutor != null) { - this.executor = timerExecutor.executor; - } else { - this.executor = new ExecutorBuilder() - .size(3) - .prefix("EjbTimerPool") - .build(SystemInstance.get().getOptions()); - - SystemInstance.get().setComponent(TimerExecutor.class, new TimerExecutor(this.executor)); - } - - this.threadPoolExecutorUsed = this.executor instanceof ThreadPoolExecutor; - - if (!this.threadPoolExecutorUsed) { - logger.warning("Unrecognized ThreadPool implementation [" + this.executor.getClass().getName() + "] is used, EJB Timer service may not work correctly"); - } - } + private boolean threadPoolExecutorUsed; // This is to prevent other parts of the code becoming dependent // on the executor produced for EJB Timers @@ -145,7 +124,25 @@ public class DefaultTimerThreadPoolAdapt } @Override - public void initialize() throws SchedulerConfigException { + public synchronized void initialize() throws SchedulerConfigException { + final TimerExecutor timerExecutor = SystemInstance.get().getComponent(TimerExecutor.class); + + if (timerExecutor != null) { + this.executor = timerExecutor.executor; + } else { + this.executor = new ExecutorBuilder() + .size(threadCount) + .prefix("EjbTimerPool") + .build(SystemInstance.get().getOptions()); + + SystemInstance.get().setComponent(TimerExecutor.class, new TimerExecutor(this.executor)); + } + + this.threadPoolExecutorUsed = this.executor instanceof ThreadPoolExecutor; + + if (!this.threadPoolExecutorUsed) { + logger.warning("Unrecognized ThreadPool implementation [" + this.executor.getClass().getName() + "] is used, EJB Timer service may not work correctly"); + } } @Override