donaldp 2002/09/28 02:56:46
Modified: event build.xml default.properties
event/src/java/org/apache/excalibur/event/command
TPCThreadManager.java TPSPThreadManager.java
Added: event/src/java/org/apache/excalibur/event/command
EventThreadPool.java
event/src/test/org/apache/excalibur/event/command/test
EventThreadPoolTestCase.java
Removed: event/src/java/org/apache/excalibur/thread
ThreadControl.java ThreadPool.java
event/src/java/org/apache/excalibur/thread/impl
DefaultThreadControl.java DefaultThreadPool.java
ExecutableRunnable.java WorkerThread.java
event/src/test/org/apache/excalibur/thread/impl/test
DefaultThreadPoolTestCase.java
Log:
Update Event to use new thread package.
Revision Changes Path
1.35 +2 -2 jakarta-avalon-excalibur/event/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/event/build.xml,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- build.xml 25 Sep 2002 15:01:43 -0000 1.34
+++ build.xml 28 Sep 2002 09:56:45 -0000 1.35
@@ -14,7 +14,7 @@
<pathelement location="${build.classes}"/>
<pathelement location="${excalibur-collections.jar}"/>
<pathelement location="${excalibur-concurrent.jar}"/>
- <pathelement location="${excalibur-threadcontext.jar}"/>
+ <pathelement location="${excalibur-thread.jar}"/>
<pathelement location="${excalibur-scratchpad.jar}"/>
<pathelement location="${avalon-framework.jar}"/>
<pathelement location="${checkstyle.jar}"/>
@@ -47,7 +47,7 @@
<ant antfile="${depchecker.prefix}/depchecker.xml"
target="checkCollections"/>
<ant antfile="${depchecker.prefix}/depchecker.xml"
target="checkConcurrent"/>
<ant antfile="${depchecker.prefix}/depchecker.xml" target="checkFramework"/>
- <ant antfile="${depchecker.prefix}/depchecker.xml"
target="checkThreadcontext"/>
+ <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkThread"/>
</target>
<target name="dependencies-test" depends="dist-jar, dependencies"
1.19 +1 -1 jakarta-avalon-excalibur/event/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/event/default.properties,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- default.properties 25 Sep 2002 15:01:43 -0000 1.18
+++ default.properties 28 Sep 2002 09:56:45 -0000 1.19
@@ -1 +1 @@
-# -------------------------------------------------------------------
# B U I L D
P R O P E R T I E S
#
-------------------------------------------------------------------
# Specifies
default property values
# Overridden by ../default.properties and all ant.properties
#
Not user-editable; use ant.properties files instead
name=excalibur-event
Name=Excalibur Event
dir-name=event
version=1.0a
package-version=0.99
year=2002
#
--------------------------------------------------
# REQUIRED LIBRARIES
# --------------------------------------------------
# ----- Excalibur util, version
1.0 or later -----
excalibur-util.home=${basedir}/../util/dist
excalibur-util.lib=${excalibur-util.home}
excalibur-util.jar=${excalibur-util.lib}/excalibur-util-1.0.jar
# ----- Excalibur
threadcontext, version 1.0 or later -----
excalibur-threadcontext.home=${basedir}/../threadcontext/dist
excalibur-threadcontext.lib=${excalibur-threadcontext.home}
excalibur-threadcontext.jar=${excalibur-threadcontext.lib}/excalibur-threadcontext-1.0.jar
# ----- Excalibur Collections, version 1.0 or later -----
excalibur-collections.home=${basedir}/../collections/dist
excalibur-collections.lib=${excalibur-collections.home}
excalibur-collections.jar=${excalibur-collections.lib}/excalibur-collections-1.0.jar
# ----- Excalibur Concurrent, version 1.0 or later -----
excalibur-concurrent.home=${basedir}/../concurrent/dist
excalibur-concurrent.lib=${excalibur-concurrent.home}
excalibur-concurrent.jar=${excalibur-concurrent.lib}/excalibur-concurrent-1.0.jar
#
----- Excalibur Core -----
excalibur-core.home=${basedir}/../all
excalibur-core.lib=${excalibur-core.home}/build/lib
excalibur-core.jar=${excalibur-core.lib}/excalibur-core.jar
# ----- Avalon Framework,
version 4.1 or later -----
avalon-framework.home=${basedir}/../../jakarta-avalon
avalon-framework.lib=${avalon-framework.home}/build/lib
avalon-framework.jar=${avalon-framework.lib}/avalon-framework.jar
#
--------------------------------------------------
# REQUIRED LIBRARIES FOR
UNIT TESTS
# --------------------------------------------------
# For unit testing
#
----- Excalibur Testcase, version 1.0 or later -----
excalibur-testcase.home=${basedir}/../testcase/dist
excalibur-testcase.lib=${excalibur-testcase.home}
excalibur-testcase.jar=${excalibur-testcase.lib}/excalibur-testcase-1.0.jar
# -----
Excalibur Pool, version 1.0 or later -----
excalibur-pool.home=${basedir}/../pool/dist
excalibur-pool.lib=${excalibur-pool.home}
excalibur-pool.jar=${excalibur-pool.lib}/excalibur-pool-1.1.jar
# ----- Logkit -----
logkit.home=${basedir}/../../jakarta-avalon-logkit
logkit.lib=${logkit.home}/build/lib
logkit.jar=${logkit.lib}/logkit.jar
# ----- Excalibur instrument, version 1.0 or
later -----
excalibur-instrument.home=${basedir}/../instrument/dist
excalibur-instrument.lib=${excalibur-instrument.home}
excalibur-instrument.jar=${excalibur-instrument.lib}/excalibur-instrument-0.3.jar
#
----- Excalibur instrument-manager, version 1.0 or later -----
excalibur-instrument-manager.home=${basedir}/../instrument-manager/dist
excalibur-instrument-manager.lib=${excalibur-instrument-manager.home}
excalibur-instrument-manager.jar=${excalibur-instrument-manager.lib}/excalibur-instrument-manager-0.3.jar
excalibur-instrument-manager-interfaces.jar=${excalibur-instrument-manager.lib}/excalibur-instrument-manager-interfaces-0.3.jar
# --------------------------------------------------
# Settings used to configure
compile environment
build.debug = on
build.optimize = off
build.deprecation = off
build.compress = false
junit.failonerror = false
# location of intermediate products
build.dir = build
build.testsrc = ${build.dir}/testsrc
build.testclasses =
${build.dir}/testclasses
build.lib = ${build.dir}/lib
build.conf = ${build.dir}/conf
build.classes = ${build.dir}/classes
build.tests = ${build.dir}/tests
build.reports =
${build.dir}/reports
# Set the properties for source directories
src.dir = src
java.dir = ${src.dir}/java
conf.dir = ${src.dir}/conf
test.dir = ${src.dir}/test
#
needed by Cocoon
build.context = ${build.dir}/documentation
build.docs =
${build.dir}/docs
build.xdocs = ${build.dir}/xdocs
context.dir =
../../jakarta-avalon/src/documentation
tools.dir = ../../jakarta-avalon/tools
tools.jar = ${java.home}/../lib/tools.jar
docs.dir = docs
xdocs.dir = ${src.dir}/xdocs
# Set the properties for distribution directories
dist.dir = dist
dist.javadocs =
${docs.dir}/api
# name of .zip/.tar.gz/.bz2 files and their top-level directory
dist.name = ${name}-${version}
# name of jar file
jar.name = ${name}-${version}.jar
# property indicating directory where all distribution archives are placed
dist.base
= distributions
depchecker.prefix=.
\ No newline at end of file
+# -------------------------------------------------------------------
# B U I L D
P R O P E R T I E S
#
-------------------------------------------------------------------
# Specifies
default property values
# Overridden by ../default.properties and all ant.properties
#
Not user-editable; use ant.properties files instead
name=excalibur-event
Name=Excalibur Event
dir-name=event
version=1.0a
package-version=0.99
year=2002
#
--------------------------------------------------
# REQUIRED LIBRARIES
# --------------------------------------------------
# ----- Excalibur util, version
1.0 or later -----
excalibur-util.home=${basedir}/../util/dist
excalibur-util.lib=${excalibur-util.home}
excalibur-util.jar=${excalibur-util.lib}/excalibur-util-1.0.jar
# ----- Excalibur
thread, version 1.0 or later -----
excalibur-thread.home=${basedir}/../thread/dist
excalibur-thread.lib=${excalibur-thread.home}
excalibur-thread.jar=${excalibur-thread.lib}/excalibur-thread-1.0.jar
# -----
Excalibur Collections, version 1.0 or later -----
excalibur-collections.home=${basedir}/../collections/dist
excalibur-collections.lib=${excalibur-collections.home}
excalibur-collections.jar=${excalibur-collections.lib}/excalibur-collections-1.0.jar
# ----- Excalibur Concurrent, version 1.0 or later -----
excalibur-concurrent.home=${basedir}/../concurrent/dist
excalibur-concurrent.lib=${excalibur-concurrent.home}
excalibur-concurrent.jar=${excalibur-concurrent.lib}/excalibur-concurrent-1.0.jar
#
----- Excalibur Core -----
excalibur-core.home=${basedir}/../all
excalibur-core.lib=${excalibur-core.home}/build/lib
excalibur-core.jar=${excalibur-core.lib}/excalibur-core.jar
# ----- Avalon Framework,
version 4.1 or later -----
avalon-framework.home=${basedir}/../../jakarta-avalon
avalon-framework.lib=${avalon-framework.home}/build/lib
avalon-framework.jar=${avalon-framework.lib}/avalon-framework.jar
#
--------------------------------------------------
# REQUIRED LIBRARIES FOR
UNIT TESTS
# --------------------------------------------------
# For unit testing
#
----- Excalibur Testcase, version 1.0 or later -----
excalibur-testcase.home=${basedir}/../testcase/dist
excalibur-testcase.lib=${excalibur-testcase.home}
excalibur-testcase.jar=${excalibur-testcase.lib}/excalibur-testcase-1.0.jar
# -----
Excalibur Pool, version 1.0 or later -----
excalibur-pool.home=${basedir}/../pool/dist
excalibur-pool.lib=${excalibur-pool.home}
excalibur-pool.jar=${excalibur-pool.lib}/excalibur-pool-1.1.jar
# ----- Logkit -----
logkit.home=${basedir}/../../jakarta-avalon-logkit
logkit.lib=${logkit.home}/build/lib
logkit.jar=${logkit.lib}/logkit.jar
# ----- Excalibur instrument, version 1.0 or
later -----
excalibur-instrument.home=${basedir}/../instrument/dist
excalibur-instrument.lib=${excalibur-instrument.home}
excalibur-instrument.jar=${excalibur-instrument.lib}/excalibur-instrument-0.3.jar
#
----- Excalibur instrument-manager, version 1.0 or later -----
excalibur-instrument-manager.home=${basedir}/../instrument-manager/dist
excalibur-instrument-manager.lib=${excalibur-instrument-manager.home}
excalibur-instrument-manager.jar=${excalibur-instrument-manager.lib}/excalibur-instrument-manager-0.3.jar
excalibur-instrument-manager-interfaces.jar=${excalibur-instrument-manager.lib}/excalibur-instrument-manager-interfaces-0.3.jar
# --------------------------------------------------
# Settings used to configure
compile environment
build.debug = on
build.optimize = off
build.deprecation = off
build.compress = false
junit.failonerror = false
# location of intermediate products
build.dir = build
build.testsrc = ${build.dir}/testsrc
build.testclasses =
${build.dir}/testclasses
build.lib = ${build.dir}/lib
build.conf = ${build.dir}/conf
build.classes = ${build.dir}/classes
build.tests = ${build.dir}/tests
build.reports =
${build.dir}/reports
# Set the properties for source directories
src.dir = src
java.dir = ${src.dir}/java
conf.dir = ${src.dir}/conf
test.dir = ${src.dir}/test
#
needed by Cocoon
build.context = ${build.dir}/documentation
build.docs =
${build.dir}/docs
build.xdocs = ${build.dir}/xdocs
context.dir =
../../jakarta-avalon/src/documentation
tools.dir = ../../jakarta-avalon/tools
tools.jar = ${java.home}/../lib/tools.jar
docs.dir = docs
xdocs.dir = ${src.dir}/xdocs
# Set the properties for distribution directories
dist.dir = dist
dist.javadocs =
${docs.dir}/api
# name of .zip/.tar.gz/.bz2 files and their top-level directory
dist.name = ${name}-${version}
# name of jar file
jar.name = ${name}-${version}.jar
# property indicating directory where all distribution archives are placed
dist.base
= distributions
depchecker.prefix=.
\ No newline at end of file
1.30 +2 -5
jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/event/command/TPCThreadManager.java
Index: TPCThreadManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/event/command/TPCThreadManager.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- TPCThreadManager.java 28 Sep 2002 09:42:32 -0000 1.29
+++ TPCThreadManager.java 28 Sep 2002 09:56:45 -0000 1.30
@@ -53,7 +53,6 @@
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.excalibur.thread.impl.DefaultThreadPool;
import org.apache.excalibur.util.SystemUtil;
/**
@@ -67,7 +66,7 @@
*/
public final class TPCThreadManager extends AbstractThreadManager implements
Parameterizable
{
- private DefaultThreadPool m_tpool;
+ private EventThreadPool m_tpool;
private long m_blockTimeout = 1000L;
private int m_processors = -1;
private int m_threadsPerProcessor = 1;
@@ -128,15 +127,13 @@
throw new IllegalStateException( "ThreadManager is already initailized"
);
}
- m_tpool = new DefaultThreadPool( "TPCThreadManager",
+ m_tpool = new EventThreadPool( "TPCThreadManager",
( m_processors *
m_threadsPerProcessor ) + 1, (int)m_blockTimeout );
if( null == getLogger() )
{
this.enableLogging( new NullLogger() );
}
-
- m_tpool.enableLogging( getLogger() );
setThreadPool( m_tpool );
1.15 +1 -2
jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/event/command/TPSPThreadManager.java
Index: TPSPThreadManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/event/command/TPSPThreadManager.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TPSPThreadManager.java 28 Sep 2002 09:42:32 -0000 1.14
+++ TPSPThreadManager.java 28 Sep 2002 09:56:45 -0000 1.15
@@ -56,7 +56,6 @@
import org.apache.excalibur.event.Source;
import org.apache.excalibur.thread.ThreadControl;
import org.apache.excalibur.thread.ThreadPool;
-import org.apache.excalibur.thread.impl.DefaultThreadPool;
/**
* This is a <code>ThreadManager</code> which provides a threadpool per
@@ -103,7 +102,7 @@
int processors = Math.max( numProcessors, 1 );
int threads = Math.max( threadsPerProcessor, 1 );
- m_threadPool = new DefaultThreadPool( "TPCThreadManager",
+ m_threadPool = new EventThreadPool( "TPCThreadManager",
( processors * threads ) +
1, (int) timeOut );
m_sleepTime = sleepTime;
1.1
jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/event/command/EventThreadPool.java
Index: EventThreadPool.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
must not be used to endorse or promote products derived from this software
without prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.excalibur.event.command;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.excalibur.mpool.BlockingFixedSizePool;
import org.apache.excalibur.mpool.ObjectFactory;
import org.apache.excalibur.thread.ThreadPool;
import org.apache.excalibur.thread.impl.AbstractThreadPool;
import org.apache.excalibur.thread.impl.WorkerThread;
/**
* This class is the public frontend for the thread pool code.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
*/
public class EventThreadPool
extends AbstractThreadPool
implements ObjectFactory, Disposable, ThreadPool
{
private BlockingFixedSizePool m_pool;
public EventThreadPool( final int capacity )
throws Exception
{
this( "Worker Pool", capacity );
}
public EventThreadPool( final String name, final int capacity )
throws Exception
{
this( name, capacity, 1000 );
}
public EventThreadPool( final String name,
final int capacity,
final int timeout )
throws Exception
{
super( name, new ThreadGroup( name ) );
m_pool = new BlockingFixedSizePool( this, capacity, timeout );
m_pool.initialize();
}
public void dispose()
{
m_pool.dispose();
m_pool = null;
}
public Object newInstance()
{
return createWorker();
}
public void dispose( final Object object )
{
if( object instanceof WorkerThread )
{
destroyWorker( (WorkerThread) object );
}
}
public Class getCreatedClass()
{
return WorkerThread.class;
}
/**
* Retrieve a worker thread from pool.
*
* @return the worker thread retrieved from pool
*/
protected WorkerThread getWorker()
{
final WorkerThread thread = (WorkerThread) m_pool.acquire();
if( null == thread )
{
final String message =
"Unable to access thread pool due to timeout exceeded";
throw new IllegalStateException( message );
}
return thread;
}
protected void releaseWorker( final WorkerThread worker )
{
m_pool.release( worker );
}
}
1.1
jakarta-avalon-excalibur/event/src/test/org/apache/excalibur/event/command/test/EventThreadPoolTestCase.java
Index: EventThreadPoolTestCase.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
must not be used to endorse or promote products derived from this software
without prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.excalibur.event.command.test;
import junit.framework.TestCase;
import org.apache.excalibur.event.command.EventThreadPool;
/**
* TestCase for EventThreadPool.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Eung-ju Park</a>
*/
public class EventThreadPoolTestCase
extends TestCase
{
public EventThreadPoolTestCase( final String name )
{
super( name );
}
public void testWithThreadContext()
throws Exception
{
final EventThreadPool pool = new EventThreadPool( "default", 10 );
pool.execute( new DummyRunnable() );
}
public void testWithoutThreadContext()
throws Exception
{
final EventThreadPool pool = new EventThreadPool( "default", 10 );
pool.execute( new DummyRunnable() );
}
private static class DummyRunnable
implements Runnable
{
public void run()
{
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>