A rar should not make any reference to other parts of JBoss,
ThreadPool, MBeanServer or any other crap.
A RAR should be a standalone file with no dependencies
except those defined by the JCA model or its own
internal definition.
There is a perfectly good thread pool available in JCA,
it is a part of the spec, it is called the
javax.resource.spi.work.WorkManager
which you can get from the BootstrapContext passed
to you during ResourceAdapter.start()
On Sat, 2006-08-05 at 18:07 -0400, jboss-cvs-commits(a)lists.jboss.org
wrote:
Author: alesj
Date: 2006-08-05 18:07:25 -0400 (Sat, 05 Aug 2006)
New Revision: 55353
Added:
trunk/connector/src/main/org/jboss/resource/adapter/quartz/inflow/JBossQuartzThreadPool.java
Log:
Quartz's ThreadPoll using JCA's thread pool.
Added:
trunk/connector/src/main/org/jboss/resource/adapter/quartz/inflow/JBossQuartzThreadPool.java
===================================================================
---
trunk/connector/src/main/org/jboss/resource/adapter/quartz/inflow/JBossQuartzThreadPool.java 2006-08-05
20:02:45 UTC (rev 55352)
+++
trunk/connector/src/main/org/jboss/resource/adapter/quartz/inflow/JBossQuartzThreadPool.java 2006-08-05
22:07:25 UTC (rev 55353)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.resource.adapter.quartz.inflow;
+
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.util.threadpool.RunnableTaskWrapper;
+import org.jboss.util.threadpool.ThreadPool;
+import org.quartz.SchedulerConfigException;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Thread pool used to fire Quartz Jobs.
+ *
+ * By default it uses 'in house' thread pool - JCA's
WorkerManagerThreadPool.
+ * You can create your own instance of JBoss's thread pool and instantiate it in
+ * jbossjca-service.xml or any other -service.xml deploy file.
+ * Simply link it with JMX object name - see property threadPoolObjectName.
+ *
+ * @see quartz.properties
+ * #org.quartz.threadPool.threadPoolObjectName=jboss.jca:service=MyThreadPool
+ *
+ * @author ales.justin(a)genera-lynx.com
+ */
+public class JBossQuartzThreadPool implements org.quartz.spi.ThreadPool
+{
+ private static final String WORK_MANAGER_THREAD_POOL =
"jboss.jca:service=WorkManagerThreadPool";
+
+ private String threadPoolObjectName = WORK_MANAGER_THREAD_POOL;
+
+ private int poolSize;
+
+ private org.jboss.util.threadpool.ThreadPool threadPool;
+
+ public void initialize() throws SchedulerConfigException
+ {
+ try
+ {
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+ ObjectName tpObjectName = new ObjectName(getThreadPoolObjectName());
+ threadPool = (ThreadPool) server.getAttribute(tpObjectName,
"Instance");
+ poolSize = ((Integer) server.getAttribute(tpObjectName,
"MaximumPoolSize")).intValue();
+ }
+ catch (Exception e)
+ {
+ throw new SchedulerConfigException("Unable to use jboss thread
pool.", e);
+ }
+ }
+
+ public int getPoolSize()
+ {
+ return poolSize;
+ }
+
+ public boolean runInThread(Runnable runnable)
+ {
+ RunnableTaskWrapper runnableTaskWrapper = new RunnableTaskWrapper(runnable, 0,
0);
+ threadPool.run(runnableTaskWrapper);
+ return runnableTaskWrapper.isComplete();
+ }
+
+ /**
+ * JBoss Thread Pool is stopped by ServiceController.
+ * By default it waits for threads (jobs) to finish.
+ *
+ * @see org.jboss.util.threadpool.BasicThreadPool#stop();
+ */
+ public void shutdown(boolean waitForJobsToComplete)
+ {
+ }
+
+ // -------- setters & getters
+
+ public String getThreadPoolObjectName()
+ {
+ return threadPoolObjectName;
+ }
+
+ public void setThreadPoolObjectName(String threadPoolObjectName)
+ {
+ this.threadPoolObjectName = threadPoolObjectName;
+ }
+
+}
_______________________________________________
jboss-cvs-commits mailing list
jboss-cvs-commits(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-cvs-commits --
xxxxxxxxxxxxxxxxxxxxxxxxxxx
Adrian Brock
Chief Scientist
JBoss a division of Red Hat
xxxxxxxxxxxxxxxxxxxxxxxxxxx