You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2003/01/12 20:07:07 UTC
cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java ThreadPoolMX.java
costin 2003/01/12 11:07:07
Modified: util/java/org/apache/tomcat/util/threads ThreadPool.java
ThreadPoolMX.java
Log:
Few more changes ( on the new jmx code ).
Old code will continue to use the normal pool, new code can get a JMX
pool if JMX is available.
We could move some of the methods I added to ThreadPoolMX.
One big issue: support for chainging pool params at runtime !
Revision Changes Path
1.8 +27 -10 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
Index: ThreadPool.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ThreadPool.java 11 Jan 2003 06:55:24 -0000 1.7
+++ ThreadPool.java 12 Jan 2003 19:07:07 -0000 1.8
@@ -123,8 +123,6 @@
/* Flag to control if the main thread is 'daemon' */
protected boolean isDaemon=true;
-
- static int debug=0;
/** The threads that are part of the pool.
* Key is Thread, value is the ControlRunnable
@@ -133,6 +131,10 @@
protected Vector listeners=new Vector();
+ /** Name of the threadpool
+ */
+ protected String name=null;
+
/**
* Helper object for logging
**/
@@ -148,17 +150,32 @@
}
- public static ThreadPool createThreadPool() {
- try {
- Class.forName( "org.apache.commons.modeler.Registry");
- Class tpc=Class.forName( "org.apache.tomcat.util.threads.ThreadPoolMX");
- ThreadPool res=(ThreadPool)tpc.newInstance();
- return res;
- } catch( Exception ex ) {
+ /** Create a ThreadPool instance.
+ *
+ * @param jmx True if you want a pool with JMX support. A regular pool
+ * will be returned if JMX or the modeler are not available.
+ *
+ * @return ThreadPool instance. If JMX support is requested, you need to
+ * call register() in order to set a name.
+ */
+ public static ThreadPool createThreadPool(boolean jmx) {
+ if( jmx ) {
+ try {
+ Class.forName( "org.apache.commons.modeler.Registry");
+ Class tpc=Class.forName( "org.apache.tomcat.util.threads.ThreadPoolMX");
+ ThreadPool res=(ThreadPool)tpc.newInstance();
+ return res;
+ } catch( Exception ex ) {
+ }
}
return new ThreadPool();
}
+ public void register( String name ) {
+ // nothing in the base class - it'll register in jmx mode
+ // We could use the name to create a ThreadGroup and name threads
+ }
+
public synchronized void start() {
stopThePool=false;
currentThreadCount = 0;
@@ -213,7 +230,7 @@
}
public static int getDebug() {
- return debug;
+ return 0;
}
/** The default is true - the created threads will be
1.2 +2 -14 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPoolMX.java
Index: ThreadPoolMX.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPoolMX.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ThreadPoolMX.java 11 Jan 2003 06:52:27 -0000 1.1
+++ ThreadPoolMX.java 12 Jan 2003 19:07:07 -0000 1.2
@@ -81,23 +81,11 @@
super();
}
- public void setDomain(String domain) {
- this.domain=domain;
- }
- public String getDomain() {
- return domain;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
+ public void register(String name) {
this.name=name;
reg=Registry.getRegistry();
try {
- reg.registerComponent(this, domain, "ThreadPool",
- "name=" + name);
+ reg.registerComponent(this, domain, "ThreadPool", name);
} catch( Exception ex ) {
log.error( "Error registering thread pool", ex );
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>