You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:24:23 UTC
[sling-org-apache-sling-commons-threads] annotated tag
org.apache.sling.commons.threads-2.0.2-incubator created (now a3e33ed)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git.
at a3e33ed (tag)
tagging 2862f32c436b9f92efa5029cec531a2cad8846bd (commit)
by Felix Meschberger
on Thu Jun 18 09:21:02 2009 +0000
- Log -----------------------------------------------------------------
org.apache.sling.commons.threads-2.0.2-incubator
-----------------------------------------------------------------------
This annotated tag includes the following new commits:
new cdf4581 Add new threads module for providing thread pools.
new c3a54e0 Set svn:ignore
new 6569a93 Use thread pool to create new threads instead of directly instantiating threads.
new a216040 Create own thread pool for eventing.
new 5dfc716 Use thread pooling for scheduler as well. Create own pool for eventing.
new f8c7fb7 Use jvm default thread factory and always provide priority and daemon settings.
new a5761c4 Use thread pool configuration object to be extensible.
new b9020b0 Move licence and notice to top level dir.
new e413af3 Add incubator disclaimer.
new 1597daa Add notice files.
new 3020eb2 Write first element in pom in one line (to avoid problems with the maven release plugin) and minor pom fixes.
new 2c687bd Update notice files.
new 4c666b9 SLING-417: Move sling/threads to commons/threads
new 8d1f9f1 SLING-417: Move threads to commons.
new 23e3268 Eclude maven-eclipse.xml generated by the maven eclipse plugin.
new 5fa8b5a SLING-442: Clean up exports, imports, dependencies and used plugins.
new f7b228d SLING-479 Fix @scr.tags: - normalize metadata attribute settings to "no" - ensure proper metadata and ds attributes are set - create metatype.properties files where required - fix metatype.properties files
new b8442a7 SLING-483: Add excludes for javadocs (WiP)
new f31810f SLING-495 - NOTICE files generated using mknotice script
new 7a30ca2 SLING-495 - NOTICE files updated according to changes in revision 662927
new fc95c64 SLING-495 - NOTICE files regenerated with revision 663097 changes
new 601db57 Use released version of parent pom.
new e4986f9 [maven-release-plugin] prepare release org.apache.sling.commons.threads-2.0.0-incubator
new 7097543 [maven-release-plugin] prepare for next development iteration
new bac4721 Fix reference to parent pom.
new 88286dd SLING-521: Restore more notice files.
new dc0cc02 SLING-521: Separate between notice files for bin and src dists.
new 82242fd SLING-521: Separate between notice files for bin and src dists.
new 64c2458 SLING-521: Separate between notice files for bin and src dists.
new b29c28c Change copyright year to 2008.
new 77f106f [maven-release-plugin] copy for tag org.apache.sling.commons.threads-2.0.2-incubator
new 0061bf1 Move Sling to new TLP location
new 2862f32 Move Sling to new TLP location
The 33 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].
[sling-org-apache-sling-commons-threads] 16/33: SLING-442: Clean up
exports, imports, dependencies and used plugins.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 5fa8b5ac707cf8f879e0c2c0f6979897ddec19e8
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon May 26 14:43:58 2008 +0000
SLING-442: Clean up exports, imports, dependencies and used plugins.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@660202 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index e2902e5..3134d87 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,7 +61,7 @@
<configuration>
<instructions>
<Export-Package>
- org.apache.sling.commons.threads
+ org.apache.sling.commons.threads;version=${pom.version}
</Export-Package>
<Private-Package>
org.apache.sling.commons.threads.impl
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 29/33: SLING-521: Separate
between notice files for bin and src dists.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 64c2458701314f4105045c8d72328159ce5acc56
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jun 13 13:30:32 2008 +0000
SLING-521: Separate between notice files for bin and src dists.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@667529 13f79535-47bb-0310-9956-ffa450edef68
---
README.txt | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/README.txt b/README.txt
index 956aeab..37ca813 100644
--- a/README.txt
+++ b/README.txt
@@ -1,7 +1,6 @@
Apache Sling Threads
-WE NEED A LOT MORE HERE!!!!!!!!!!!!!!!!!!
-
+Support for thread handling like pooling.
Disclaimer
==========
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 31/33:
[maven-release-plugin] copy for tag
org.apache.sling.commons.threads-2.0.2-incubator
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 77f106f5310528c14fdbff5fc5ffc373ce47e5b1
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Jun 17 07:07:41 2008 +0000
[maven-release-plugin] copy for tag org.apache.sling.commons.threads-2.0.2-incubator
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.threads-2.0.2-incubator@668432 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pom.xml b/pom.xml
index 8446ab3..324059e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,13 +23,13 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>2-incubator-SNAPSHOT</version>
+ <version>3-incubator</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
<artifactId>org.apache.sling.commons.threads</artifactId>
<packaging>bundle</packaging>
- <version>2.0.1-incubator-SNAPSHOT</version>
+ <version>2.0.2-incubator</version>
<name>Sling - Thread Support</name>
<description>
@@ -37,9 +37,9 @@
</description>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads</developerConnection>
- <url>http://svn.apache.org/viewvc/incubator/sling/trunk/commons/threads</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.threads-2.0.2-incubator</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.threads-2.0.2-incubator</developerConnection>
+ <url>http://svn.apache.org/viewvc/incubator/sling/tags/org.apache.sling.commons.threads-2.0.2-incubator</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 20/33: SLING-495 - NOTICE
files updated according to changes in revision 662927
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 7a30ca27763da5b5767d3246d6e848423ac8488c
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Jun 4 08:05:20 2008 +0000
SLING-495 - NOTICE files updated according to changes in revision 662927
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@663025 13f79535-47bb-0310-9956-ffa450edef68
---
NOTICE | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/NOTICE b/NOTICE
index b27f3cd..f9d6842 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,16 +1,11 @@
Apache Sling - Thread Support
-Copyright 2007-2008 The Apache Software Foundation
-Based on source code originally developed by
-Day Software (http://www.day.com/).
+Apache Sling
+Copyright 2008 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-See http://www.apache.org/legal/3party.html for the ASF policy on
-third-party licenses.
-This product includes software developed at http://slf4j.org, distributed
-under the slf4j MIT-like license (http://slf4j.org/license.html).
+Based on source code originally developed by
+Day Software (http://www.day.com/).
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 06/33: Use jvm default
thread factory and always provide priority and daemon settings.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit f8c7fb77fc8d5ee384cdfda92254ee0d3597b775
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 18 14:55:27 2008 +0000
Use jvm default thread factory and always provide priority and daemon settings.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@628769 13f79535-47bb-0310-9956-ffa450edef68
---
.../sling/threads/impl/DefaultThreadFactory.java | 79 ----------------------
.../sling/threads/impl/DefaultThreadPool.java | 27 +++-----
.../sling/threads/impl/ExtendedThreadFactory.java | 64 ++++++++++--------
3 files changed, 42 insertions(+), 128 deletions(-)
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadFactory.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadFactory.java
deleted file mode 100644
index 2cffa80..0000000
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadFactory.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.threads.impl;
-
-
-/**
- * This class is responsible to create new Thread instances.
- * It's a very basic implementation.
- *
- * @version $Id$
- */
-public class DefaultThreadFactory
- implements ExtendedThreadFactory {
-
- /** The daemon mode */
- private boolean isDaemon = DefaultThreadPoolManager.DEFAULT_DAEMON_MODE;
-
- /** The priority of newly created Threads */
- private int priority = DefaultThreadPoolManager.DEFAULT_THREAD_PRIORITY;
-
- /**
- * @see org.apache.sling.threads.impl.ExtendedThreadFactory#setDaemon(boolean)
- */
- public void setDaemon( boolean isDaemon ) {
- this.isDaemon = isDaemon;
- }
-
- /**
- * @see org.apache.sling.threads.impl.ExtendedThreadFactory#isDaemon()
- */
- public boolean isDaemon() {
- return this.isDaemon;
- }
-
- /**
- * @see org.apache.sling.threads.impl.ExtendedThreadFactory#setPriority(int)
- */
- public void setPriority( final int priority ) {
- if( ( Thread.MAX_PRIORITY == priority ) ||
- ( Thread.MIN_PRIORITY == priority ) ||
- ( Thread.NORM_PRIORITY == priority ) ) {
- this.priority = priority;
- } else {
- throw new IllegalStateException("Unknown priority " + priority);
- }
- }
-
- /**
- * @see org.apache.sling.threads.impl.ExtendedThreadFactory#getPriority()
- */
- public int getPriority() {
- return this.priority;
- }
-
- /**
- * @see org.apache.sling.threads.impl.ExtendedThreadFactory#newThread(java.lang.Runnable)
- */
- public Thread newThread( final Runnable command ) {
- final Thread thread = new Thread( command );
- thread.setPriority( this.priority );
- thread.setDaemon( this.isDaemon );
-
- return thread;
- }
-}
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
index f685c15..37289bd 100644
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
@@ -17,6 +17,7 @@
package org.apache.sling.threads.impl;
import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.SynchronousQueue;
@@ -80,15 +81,14 @@ public class DefaultThreadPool
}
// factory
- final ThreadFactory threadFactory;
+ final ThreadFactory delegateThreadFactory;
if (factory == null) {
- logger.warn("No ThreadFactory is configured. Will use a "
- + DefaultThreadFactory.class.getName());
- threadFactory = new DefaultThreadFactory();
+ logger.warn("No ThreadFactory is configured. Will use JVM default thread factory."
+ + ExtendedThreadFactory.class.getName());
+ delegateThreadFactory = Executors.defaultThreadFactory();
} else {
- threadFactory = factory;
+ delegateThreadFactory = factory;
}
-
// Min pool size
// make sure we have enough threads for the default thread pool as we
// need one for ourself
@@ -102,19 +102,8 @@ public class DefaultThreadPool
// Max pool size
maxPoolSize = (maxPoolSize < 0) ? Integer.MAX_VALUE : maxPoolSize;
- // Set priority and daemon if the factory is an extended factory
- if ( threadFactory instanceof ExtendedThreadFactory ) {
- final ExtendedThreadFactory extTF = (ExtendedThreadFactory)threadFactory;
- extTF.setPriority(priority);
- extTF.setDaemon(isDaemon);
- } else {
- if ( priority != Thread.NORM_PRIORITY ) {
- this.logger.warn("ThreadFactory " + threadFactory + " does not support setting the priority or daemon setting.");
- }
- if ( isDaemon != DefaultThreadPoolManager.DEFAULT_DAEMON_MODE ) {
- this.logger.warn("ThreadFactory " + threadFactory + " does not support setting the daemon mode.");
- }
- }
+ // Set priority and daemon flag
+ final ExtendedThreadFactory threadFactory = new ExtendedThreadFactory(delegateThreadFactory, priority, isDaemon);
// Keep alive time
if (keepAliveTime < 0) {
diff --git a/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java b/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java
index 5ad586f..7a030a7 100644
--- a/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java
+++ b/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java
@@ -18,50 +18,54 @@ package org.apache.sling.threads.impl;
import java.util.concurrent.ThreadFactory;
+
/**
- * This is an extension to the {@link ThreadFactory}.
+ * This class is responsible to create new Thread instances.
+ * It's a very basic implementation.
*
* @version $Id$
*/
-public interface ExtendedThreadFactory
- extends ThreadFactory {
+public final class ExtendedThreadFactory implements ThreadFactory {
- /**
- * Set the daemon mode of created <code>Thread</code>s should have
- *
- * @param isDaemon Whether new {@link Thread}s should run as daemons.
- */
- void setDaemon( boolean isDaemon );
+ /** The daemon mode */
+ private final boolean isDaemon;
- /**
- * Get the daemon mode created <code>Thread</code>s will have
- *
- * @return Whether new {@link Thread}s should run as daemons.
- */
- boolean isDaemon();
+ /** The priority of newly created Threads */
+ private final int priority;
+
+ /** The real factory. */
+ private final ThreadFactory factory;
/**
- * Set the priority newly created <code>Thread</code>s should have
+ * Create a new wrapper for a thread factory handling the
*
* @param priority One of {@link Thread#MIN_PRIORITY}, {@link
* Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY}
+ * @param isDaemon Whether new {@link Thread}s should run as daemons.
*/
- void setPriority( int priority );
+ public ExtendedThreadFactory(final ThreadFactory factory,
+ final int priority,
+ final boolean isDaemon) {
+ this.isDaemon = isDaemon;
+ if( ( Thread.MAX_PRIORITY == priority ) ||
+ ( Thread.MIN_PRIORITY == priority ) ||
+ ( Thread.NORM_PRIORITY == priority ) ) {
+ this.priority = priority;
+ } else {
+ throw new IllegalStateException("Unknown priority " + priority);
+ }
+ this.factory = factory;
+ }
/**
- * Get the priority newly created <code>Thread</code>s will have
- *
- * @return One of {@link Thread#MIN_PRIORITY}, {@link
- * Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY}
+ * Invoke the thread factory and set the daemon flag and priority.
+ * @see java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable)
*/
- int getPriority();
+ public Thread newThread( final Runnable command ) {
+ final Thread thread = this.factory.newThread(command);
+ thread.setPriority( this.priority );
+ thread.setDaemon( this.isDaemon );
- /**
- * Create a new Thread for a {@link Runnable} command
- *
- * @param command The <code>Runnable</code>
- *
- * @return new <code>Thread</code>
- */
- Thread newThread( Runnable command );
+ return thread;
+ }
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 21/33: SLING-495 - NOTICE
files regenerated with revision 663097 changes
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit fc95c6486884a7344ca67e7c02d4602ab33d9187
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Wed Jun 4 13:50:29 2008 +0000
SLING-495 - NOTICE files regenerated with revision 663097 changes
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@663098 13f79535-47bb-0310-9956-ffa450edef68
---
NOTICE | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/NOTICE b/NOTICE
index f9d6842..512a7ef 100644
--- a/NOTICE
+++ b/NOTICE
@@ -6,6 +6,6 @@ Copyright 2008 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
-Based on source code originally developed by
-Day Software (http://www.day.com/).
+Apache Sling is based on source code originally developed
+by Day Software (http://www.day.com/).
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 32/33: Move Sling to new
TLP location
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 0061bf1f84f23556cc2a22c128e5db53d753e890
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Thu Jun 18 09:21:02 2009 +0000
Move Sling to new TLP location
git-svn-id: https://svn.eu.apache.org/repos/asf/sling/tags/org.apache.sling.commons.threads-2.0.2-incubator@785979 13f79535-47bb-0310-9956-ffa450edef68
---
LICENSE | 202 +++++++++++++++++++++
NOTICE | 8 +
README.txt | 36 ++++
pom.xml | 91 ++++++++++
.../apache/sling/commons/threads/ThreadPool.java | 44 +++++
.../sling/commons/threads/ThreadPoolConfig.java | 202 +++++++++++++++++++++
.../sling/commons/threads/ThreadPoolManager.java | 56 ++++++
.../commons/threads/impl/DefaultThreadPool.java | 194 ++++++++++++++++++++
.../threads/impl/DefaultThreadPoolManager.java | 133 ++++++++++++++
.../threads/impl/ExtendedThreadFactory.java | 79 ++++++++
src/main/resources/META-INF/DISCLAIMER | 7 +
src/main/resources/META-INF/LICENSE | 202 +++++++++++++++++++++
src/main/resources/META-INF/NOTICE | 8 +
13 files changed, 1262 insertions(+)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..3a4d87e
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,8 @@
+Apache Sling Threads
+Copyright 2008 The Apache Software Foundation
+
+Apache Sling is based on source code originally developed
+by Day Software (http://www.day.com/).
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..37ca813
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,36 @@
+Apache Sling Threads
+
+Support for thread handling like pooling.
+
+Disclaimer
+==========
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
+
+Getting Started
+===============
+
+This component uses a Maven 2 (http://maven.apache.org/) build
+environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/)
+2.0.7 or later. We recommend to use the latest Maven version.
+
+If you have Maven 2 installed, you can compile and
+package the jar using the following command:
+
+ mvn package
+
+See the Maven 2 documentation for other build features.
+
+The latest source code for this component is available in the
+Subversion (http://subversion.tigris.org/) source repository of
+the Apache Software Foundation. If you have Subversion installed,
+you can checkout the latest source using the following command:
+
+ svn checkout http://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads
+
+See the Subversion documentation for other source control features.
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..324059e
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>3-incubator</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.sling.commons.threads</artifactId>
+ <packaging>bundle</packaging>
+ <version>2.0.2-incubator</version>
+
+ <name>Sling - Thread Support</name>
+ <description>
+ Support for thread handling like pooling.
+ </description>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.threads-2.0.2-incubator</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.threads-2.0.2-incubator</developerConnection>
+ <url>http://svn.apache.org/viewvc/incubator/sling/tags/org.apache.sling.commons.threads-2.0.2-incubator</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.sling.commons.threads;version=${pom.version}
+ </Export-Package>
+ <Private-Package>
+ org.apache.sling.commons.threads.impl
+ </Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <excludePackageNames>
+ org.apache.sling.commons.threads.impl
+ </excludePackageNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/commons/threads/ThreadPool.java b/src/main/java/org/apache/sling/commons/threads/ThreadPool.java
new file mode 100644
index 0000000..e99c13e
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/threads/ThreadPool.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.threads;
+
+/**
+ * The ThreadPool interface allows to start runnables by
+ * getting threads from a managed pool.
+ *
+ * @version $Id$
+ */
+public interface ThreadPool {
+
+ /**
+ * Execute a runnable
+ * @param runnable The {@link Runnable} to execute
+ */
+ void execute(Runnable runnable);
+
+ /**
+ * The name of the thread pool.
+ */
+ String getName();
+
+ /**
+ * Shut down the thread pool.
+ */
+ void shutdown();
+
+ ThreadPoolConfig getConfiguration();
+}
diff --git a/src/main/java/org/apache/sling/commons/threads/ThreadPoolConfig.java b/src/main/java/org/apache/sling/commons/threads/ThreadPoolConfig.java
new file mode 100644
index 0000000..1274aaa
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/threads/ThreadPoolConfig.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.threads;
+
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * The ThreadPool configuration.
+ *
+ * @version $Id$
+ */
+public final class ThreadPoolConfig {
+
+ /** The thread pool policies. */
+ public enum ThreadPoolPolicy {
+ ABORT,
+ DISCARD,
+ DISCARDOLDEST,
+ RUN
+ };
+
+ public enum ThreadPriority {
+ NORM,
+ MIN,
+ MAX
+ };
+
+ /** The min pool size. */
+ private int minPoolSize = 5;
+
+ /** The max pool size. */
+ private int maxPoolSize = 5;
+
+ /** The queue size */
+ private int queueSize = -1;
+
+ /** The keep alive time. */
+ private long keepAliveTime = 60000L;
+
+ /** The thread pool policy. Default is RUN. */
+ private ThreadPoolPolicy blockPolicy = ThreadPoolPolicy.RUN;
+
+ private boolean shutdownGraceful = false;
+
+ private int shutdownWaitTimeMs = -1;
+
+ private ThreadFactory factory;
+
+ private ThreadPriority priority = ThreadPriority.NORM;
+
+ private boolean isDaemon = false;
+
+ /** Can this configuration still be changed? */
+ private boolean isWritable = true;
+
+ /**
+ * Create a new default configuration.
+ */
+ public ThreadPoolConfig() {
+ // nothing to do
+ }
+
+ /**
+ * Clone an existing configuration
+ * @param copy The config to clone
+ */
+ public ThreadPoolConfig(ThreadPoolConfig copy) {
+ this.minPoolSize = copy.minPoolSize;
+ this.maxPoolSize = copy.maxPoolSize;
+ this.queueSize = copy.queueSize;
+ this.keepAliveTime = copy.keepAliveTime;
+ this.blockPolicy = copy.blockPolicy;
+ this.shutdownGraceful = copy.shutdownGraceful;
+ this.shutdownWaitTimeMs = copy.shutdownWaitTimeMs;
+ this.factory = copy.factory;
+ this.priority = copy.priority;
+ this.isDaemon = copy.isDaemon;
+ }
+
+ protected void checkWritable() {
+ if ( !isWritable ) {
+ throw new IllegalStateException("ThreadPoolConfig is read-only.");
+ }
+ }
+
+ /**
+ * Make the configuration read-only.
+ */
+ public void makeReadOnly() {
+ this.isWritable = false;
+ }
+
+ public int getMinPoolSize() {
+ return minPoolSize;
+ }
+
+ public void setMinPoolSize(int minPoolSize) {
+ this.checkWritable();
+ this.minPoolSize = minPoolSize;
+ }
+
+ public int getMaxPoolSize() {
+ return maxPoolSize;
+ }
+
+ public void setMaxPoolSize(int maxPoolSize) {
+ this.checkWritable();
+ this.maxPoolSize = maxPoolSize;
+ }
+
+ public int getQueueSize() {
+ return queueSize;
+ }
+
+ public void setQueueSize(int queueSize) {
+ this.checkWritable();
+ this.queueSize = queueSize;
+ }
+
+ public long getKeepAliveTime() {
+ return keepAliveTime;
+ }
+
+ public void setKeepAliveTime(long keepAliveTime) {
+ this.checkWritable();
+ this.keepAliveTime = keepAliveTime;
+ }
+
+ public ThreadPoolPolicy getBlockPolicy() {
+ return blockPolicy;
+ }
+
+ public void setBlockPolicy(ThreadPoolPolicy blockPolicy) {
+ this.checkWritable();
+ this.blockPolicy = blockPolicy;
+ if ( blockPolicy == null ) {
+ throw new IllegalArgumentException("Policy must not be null.");
+ }
+ }
+
+ public boolean isShutdownGraceful() {
+ return shutdownGraceful;
+ }
+
+ public void setShutdownGraceful(boolean shutdownGraceful) {
+ this.checkWritable();
+ this.shutdownGraceful = shutdownGraceful;
+ }
+
+ public int getShutdownWaitTimeMs() {
+ return shutdownWaitTimeMs;
+ }
+
+ public void setShutdownWaitTimeMs(int shutdownWaitTimeMs) {
+ this.checkWritable();
+ this.shutdownWaitTimeMs = shutdownWaitTimeMs;
+ }
+
+ public ThreadFactory getFactory() {
+ return factory;
+ }
+
+ public void setFactory(ThreadFactory factory) {
+ this.checkWritable();
+ this.factory = factory;
+ }
+
+ public ThreadPriority getPriority() {
+ return priority;
+ }
+
+ public void setPriority(ThreadPriority priority) {
+ this.checkWritable();
+ if ( priority == null ) {
+ throw new IllegalArgumentException("Priority must not be null.");
+ }
+ this.priority = priority;
+ }
+
+ public boolean isDaemon() {
+ return isDaemon;
+ }
+
+ public void setDaemon(boolean isDaemon) {
+ this.checkWritable();
+ this.isDaemon = isDaemon;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/commons/threads/ThreadPoolManager.java b/src/main/java/org/apache/sling/commons/threads/ThreadPoolManager.java
new file mode 100644
index 0000000..fc9c060
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/threads/ThreadPoolManager.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.threads;
+
+
+/**
+ * The <cod>ThreadPoolManager</code> manages thread pools.
+ *
+ * @version $Id$
+ */
+public interface ThreadPoolManager {
+
+ /** The default thread pool name */
+ String DEFAULT_THREADPOOL_NAME = "default";
+
+ /**
+ * Add a new pool.
+ * If a pool with the same name already exists, the new pool is not added
+ * and false is returned.
+ * @param pool The pool.
+ * @return True if the pool could be added, false otherwise.
+ */
+ boolean add(ThreadPool pool);
+
+ /**
+ * Get a thread pool.
+ * If there is no thread pool with the given name, the default thread
+ * pool is returned.
+ * @param name The name of the thread pool or null for the default pool.
+ */
+ ThreadPool get(String name);
+
+ /**
+ * Create a new thread pool.
+ * If a pool with the same name already exists, no new pool is created
+ * and <code>null</code> is returned.
+ * @param name Name must not be null.
+ * @param config The thread pool configuration.
+ */
+ ThreadPool create(String name,
+ ThreadPoolConfig config);
+}
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
new file mode 100644
index 0000000..7c19c75
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.threads.impl;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.sling.commons.threads.ThreadPool;
+import org.apache.sling.commons.threads.ThreadPoolConfig;
+import org.apache.sling.commons.threads.ThreadPoolManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The DefaultThreadPool class implements the {@link ThreadPool} interface.
+ * Instances of this class are managed by the {@link ThreadPoolManager}.
+ *
+ * @version $Id$
+ */
+public class DefaultThreadPool
+ implements ThreadPool {
+
+ /** By default we use the logger for this class. */
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ /** The name of this thread pool */
+ protected final String name;
+
+ /** The executor. */
+ protected ThreadPoolExecutor executor;
+
+ protected final ThreadPoolConfig configuration;
+
+ /**
+ * Create a new thread pool.
+ * @param name - The name of the thread pool. If null {@link DefaultThreadPoolManager#DEFAULT_THREADPOOL_NAME}
+ * is used
+ */
+ public DefaultThreadPool(final String name,
+ ThreadPoolConfig origConfig) {
+ this.logger.info("ThreadPool [{}] initializing ...", name);
+
+ // name
+ if ( name != null ) {
+ this.name = name;
+ } else {
+ this.name = DefaultThreadPoolManager.DEFAULT_THREADPOOL_NAME;
+ }
+
+ this.configuration = new ThreadPoolConfig(origConfig);
+
+ // factory
+ final ThreadFactory delegateThreadFactory;
+ if (this.configuration.getFactory() == null) {
+ logger.warn("No ThreadFactory is configured. Will use JVM default thread factory."
+ + ExtendedThreadFactory.class.getName());
+ delegateThreadFactory = Executors.defaultThreadFactory();
+ } else {
+ delegateThreadFactory = this.configuration.getFactory();
+ }
+ // Min pool size
+ if (this.configuration.getMinPoolSize() < 1) {
+ this.configuration.setMinPoolSize(1);
+ this.logger.warn("min-pool-size < 1 for pool \"" + name + "\". Set to 1");
+ }
+ // Max pool size
+ if ( this.configuration.getMaxPoolSize() < 0 ) {
+ this.configuration.setMaxPoolSize(Integer.MAX_VALUE);
+ }
+
+ // Set priority and daemon flag
+ final ExtendedThreadFactory threadFactory = new ExtendedThreadFactory(delegateThreadFactory, this.configuration.getPriority(), this.configuration.isDaemon());
+
+ // Keep alive time
+ if (this.configuration.getKeepAliveTime() < 0) {
+ this.configuration.setKeepAliveTime(1000);
+ this.logger.warn("keep-alive-time-ms < 0 for pool \"" + name + "\". Set to 1000");
+ }
+
+ // Queue
+ final BlockingQueue<Runnable> queue;
+ if (this.configuration.getQueueSize() != 0) {
+ if (this.configuration.getQueueSize() > 0) {
+ queue = new java.util.concurrent.ArrayBlockingQueue<Runnable>(this.configuration.getQueueSize());
+ } else {
+ queue = new LinkedBlockingQueue<Runnable>();
+ }
+ } else {
+ queue = new SynchronousQueue<Runnable>();
+ }
+
+ RejectedExecutionHandler handler = null;
+ switch (this.configuration.getBlockPolicy()) {
+ case ABORT :
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ break;
+ case DISCARD :
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ break;
+ case DISCARDOLDEST :
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ break;
+ case RUN :
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ break;
+ }
+ this.executor = new ThreadPoolExecutor(this.configuration.getMinPoolSize(),
+ this.configuration.getMaxPoolSize(),
+ this.configuration.getKeepAliveTime(),
+ TimeUnit.MILLISECONDS,
+ queue,
+ threadFactory,
+ handler);
+ this.configuration.makeReadOnly();
+ this.logger.info("ThreadPool [{}] initialized.", name);
+ }
+
+ /**
+ * @see org.apache.sling.commons.threads.ThreadPool#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * @see org.apache.sling.commons.threads.ThreadPool#getConfiguration()
+ */
+ public ThreadPoolConfig getConfiguration() {
+ return this.configuration;
+ }
+
+ /**
+ * @see org.apache.sling.commons.threads.ThreadPool#execute(java.lang.Runnable)
+ */
+ public void execute(Runnable runnable) {
+ if ( this.executor == null ) {
+ throw new IllegalStateException("Thread pool " + this.name + " is already shutdown.");
+ }
+ if ( runnable != null ) {
+ this.logger.debug("Executing runnable: {},pool={}", runnable, this.name);
+
+ this.executor.execute(runnable);
+ }
+ }
+
+ /**
+ * @see org.apache.sling.commons.threads.ThreadPool#shutdown()
+ */
+ public void shutdown() {
+ if ( this.executor != null ) {
+ if (this.configuration.isShutdownGraceful()) {
+ this.executor.shutdown();
+ } else {
+ this.executor.shutdownNow();
+ }
+
+ try {
+ if (this.configuration.getShutdownWaitTimeMs() > 0) {
+ if (!this.executor.awaitTermination(this.configuration.getShutdownWaitTimeMs(), TimeUnit.MILLISECONDS)) {
+ logger.warn("running commands have not terminated within "
+ + this.configuration.getShutdownWaitTimeMs()
+ + "ms. Will shut them down by interruption");
+ this.executor.shutdownNow();
+ }
+ }
+ } catch (final InterruptedException ie) {
+ this.logger.error("Cannot shutdown ThreadPool", ie);
+ }
+ this.executor = null;
+ }
+ }
+}
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
new file mode 100644
index 0000000..4ed4811
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.threads.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.commons.threads.ThreadPool;
+import org.apache.sling.commons.threads.ThreadPoolConfig;
+import org.apache.sling.commons.threads.ThreadPoolManager;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The DefaultThreadPoolManager implements the {@link ThreadPoolManager} interface
+ * and is responsible to manage {@link ThreadPool}s.
+ *
+ * @scr.component metatype="no"
+ * @scr.service interface="org.apache.sling.commons.threads.ThreadPoolManager"
+ *
+ * @version $Id$
+ */
+public class DefaultThreadPoolManager implements ThreadPoolManager {
+
+ /** By default we use the logger for this class. */
+ protected Logger logger = LoggerFactory.getLogger(getClass());
+
+ /** The managed thread pools */
+ protected final Map<String, ThreadPool> pools = new HashMap<String, ThreadPool>();
+
+ /**
+ * Activate this component.
+ */
+ protected void activate(ComponentContext context) throws Exception {
+ this.logger.info("Starting thread pool manager.");
+ final ThreadPool defaultPool = new DefaultThreadPool(
+ DEFAULT_THREADPOOL_NAME,
+ new ThreadPoolConfig());
+ synchronized ( this.pools ) {
+ this.pools.put(defaultPool.getName(), defaultPool);
+ }
+ this.logger.info("Thread pool manager startet with default pool.");
+ }
+
+ /**
+ * Deactivate this component.
+ */
+ protected void deactivate(ComponentContext context) throws Exception {
+ this.logger.info("Stopping thread pool manager.");
+ this.logger.debug("Disposing all thread pools");
+
+ synchronized ( this.pools ) {
+ for (ThreadPool pool : this.pools.values()) {
+ this.logger.debug("Shutting down thread pool {}", pool.getName());
+
+ pool.shutdown();
+
+ this.logger.debug("Thread pool " + pool.getName() + " is shut down.");
+ }
+ this.pools.clear();
+ }
+ this.logger.info("Thread pool manager stopped.");
+ }
+
+ /**
+ * @see org.apache.sling.commons.threads.ThreadPoolManager#add(org.apache.sling.commons.threads.ThreadPool)
+ */
+ public boolean add(ThreadPool pool) {
+ synchronized ( this.pools ) {
+ if (null != pools.get(pool.getName())) {
+ return false;
+ }
+ pools.put(pool.getName(), pool);
+ }
+ return true;
+ }
+
+ /**
+ * @see org.apache.sling.commons.threads.ThreadPoolManager#get(java.lang.String)
+ */
+ public ThreadPool get(String name) {
+ if ( name == null ) {
+ name = DEFAULT_THREADPOOL_NAME;
+ }
+ synchronized (this.pools) {
+ ThreadPool pool = this.pools.get(name);
+ if ( pool == null && !(name.equals(DEFAULT_THREADPOOL_NAME))) {
+ this.logger.info("Requested pool {} is not available, returning default pool.", name);
+ pool = this.pools.get(DEFAULT_THREADPOOL_NAME);
+ }
+ return pool;
+ }
+ }
+
+ /**
+ * @see org.apache.sling.commons.threads.ThreadPoolManager#create(java.lang.String, org.apache.sling.commons.threads.ThreadPoolConfig)
+ */
+ public ThreadPool create(String name,
+ ThreadPoolConfig config) {
+ if ( name == null ) {
+ throw new IllegalArgumentException("Name must not be null.");
+ }
+ if ( config == null ) {
+ throw new IllegalArgumentException("Config must not be null.");
+ }
+ synchronized ( this.pools ) {
+ ThreadPool pool = this.pools.get(name);
+ if ( pool != null ) {
+ // pool already exists
+ return null;
+ }
+ pool = new DefaultThreadPool(name, config);
+ this.pools.put(name, pool);
+ return pool;
+ }
+ }
+
+}
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java b/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
new file mode 100644
index 0000000..b213fd8
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.commons.threads.impl;
+
+import java.util.concurrent.ThreadFactory;
+
+import org.apache.sling.commons.threads.ThreadPoolConfig;
+
+
+/**
+ * This class is responsible to create new Thread instances.
+ * It's a very basic implementation.
+ *
+ * @version $Id$
+ */
+public final class ExtendedThreadFactory implements ThreadFactory {
+
+ /** The daemon mode */
+ private final boolean isDaemon;
+
+ /** The priority of newly created Threads */
+ private final int priority;
+
+ /** The real factory. */
+ private final ThreadFactory factory;
+
+ /**
+ * Create a new wrapper for a thread factory handling the
+ *
+ * @param priority A non null value.
+ * @param isDaemon Whether new {@link Thread}s should run as daemons.
+ */
+ public ExtendedThreadFactory(final ThreadFactory factory,
+ final ThreadPoolConfig.ThreadPriority priority,
+ final boolean isDaemon) {
+ this.isDaemon = isDaemon;
+ if ( priority == null ) {
+ throw new IllegalStateException("Prioriy must not be null.");
+ }
+ switch ( priority ) {
+ case NORM : this.priority = Thread.NORM_PRIORITY;
+ break;
+ case MIN : this.priority = Thread.MIN_PRIORITY;
+ break;
+ case MAX : this.priority = Thread.MAX_PRIORITY;
+ break;
+ default: // this can never happen
+ this.priority = Thread.NORM_PRIORITY;
+ break;
+ }
+ this.factory = factory;
+ }
+
+ /**
+ * Invoke the thread factory and set the daemon flag and priority.
+ * @see java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable)
+ */
+ public Thread newThread( final Runnable command ) {
+ final Thread thread = this.factory.newThread(command);
+ thread.setPriority( this.priority );
+ thread.setDaemon( this.isDaemon );
+
+ return thread;
+ }
+}
diff --git a/src/main/resources/META-INF/DISCLAIMER b/src/main/resources/META-INF/DISCLAIMER
new file mode 100644
index 0000000..90850c2
--- /dev/null
+++ b/src/main/resources/META-INF/DISCLAIMER
@@ -0,0 +1,7 @@
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
\ No newline at end of file
diff --git a/src/main/resources/META-INF/LICENSE b/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000..3a4d87e
--- /dev/null
+++ b/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,8 @@
+Apache Sling Threads
+Copyright 2008 The Apache Software Foundation
+
+Apache Sling is based on source code originally developed
+by Day Software (http://www.day.com/).
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 28/33: SLING-521: Separate
between notice files for bin and src dists.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 82242fd2e496ce085f852a904fd8bf4c06ce9e84
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jun 13 10:58:09 2008 +0000
SLING-521: Separate between notice files for bin and src dists.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@667471 13f79535-47bb-0310-9956-ffa450edef68
---
README.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.txt b/README.txt
index 16e5797..956aeab 100644
--- a/README.txt
+++ b/README.txt
@@ -1,3 +1,5 @@
+Apache Sling Threads
+
WE NEED A LOT MORE HERE!!!!!!!!!!!!!!!!!!
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 10/33: Add notice files.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 1597daa853757a086ce9636adb7df947653ee174
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Apr 14 13:16:05 2008 +0000
Add notice files.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@647791 13f79535-47bb-0310-9956-ffa450edef68
---
NOTICE | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..48434ce
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,26 @@
+Apache Sling Threads
+Copyright 2007-2008 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+
+II. Used Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright 2006 The OSGi Alliance.
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+slf4j (http://www.sl4j.org)
+Licensed under the MIT License.
+
+
+III. License Summary
+- Apache License 2.0
+- MIT License
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 13/33: SLING-417: Move
sling/threads to commons/threads
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 4c666b90a7796e0efe1a17152196e5ea3f262ff1
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon May 5 06:23:49 2008 +0000
SLING-417: Move sling/threads to commons/threads
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@653302 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 25/33: Fix reference to
parent pom.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit bac47210fbcd6fd88915176ee8e60888d6fb7e8d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Jun 5 05:51:38 2008 +0000
Fix reference to parent pom.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@663458 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 3016805..8446ab3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>1-incubator</version>
+ <version>2-incubator-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 26/33: SLING-521: Restore
more notice files.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 88286dda881a362cb3f3d58606c21f88fdd7f4a1
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Jun 10 14:28:07 2008 +0000
SLING-521: Restore more notice files.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@666121 13f79535-47bb-0310-9956-ffa450edef68
---
NOTICE | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/NOTICE b/NOTICE
index 512a7ef..f39eb41 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,11 +1,9 @@
-Apache Sling - Thread Support
-
-Apache Sling
-Copyright 2008 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
+Apache Sling Threads
+Copyright 2007-2008 The Apache Software Foundation
Apache Sling is based on source code originally developed
by Day Software (http://www.day.com/).
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 04/33: Create own thread
pool for eventing.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit a2160409e97928deefe30aa0032b84373411420a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 18 09:51:26 2008 +0000
Create own thread pool for eventing.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@628671 13f79535-47bb-0310-9956-ffa450edef68
---
.../apache/sling/threads/ThreadPoolManager.java | 42 +++++++++++-
.../sling/threads/impl/DefaultThreadPool.java | 55 +++++-----------
.../threads/impl/DefaultThreadPoolManager.java | 75 +++++++++++++++-------
3 files changed, 106 insertions(+), 66 deletions(-)
diff --git a/src/main/java/org/apache/sling/threads/ThreadPoolManager.java b/src/main/java/org/apache/sling/threads/ThreadPoolManager.java
index 603aa46..62610b4 100644
--- a/src/main/java/org/apache/sling/threads/ThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/threads/ThreadPoolManager.java
@@ -16,6 +16,8 @@
*/
package org.apache.sling.threads;
+import java.util.concurrent.ThreadFactory;
+
/**
* The <cod>ThreadPoolManager</code> manages thread pools.
*
@@ -23,18 +25,54 @@ package org.apache.sling.threads;
*/
public interface ThreadPoolManager {
+ /** The default thread pool name */
+ String DEFAULT_THREADPOOL_NAME = "default";
+
+ /** The thread pool policies. */
+ enum ThreadPoolPolicy {
+ ABORT,
+ DISCARD,
+ DISCARDOLDEST,
+ RUN
+ };
+
+ /** The default policy */
+ ThreadPoolPolicy DEFAULT_BLOCK_POLICY = ThreadPoolPolicy.RUN;
+
/**
* Add a new pool.
* If a pool with the same name already exists, the new pool is not added
* and false is returned.
- * @param pool The pool
+ * @param pool The pool.
* @return True if the pool could be added, false otherwise.
*/
boolean add(ThreadPool pool);
/**
- * Get a thread pool
+ * Get a thread pool.
+ * If there is no thread pool with the given name, the default thread
+ * pool is returned.
* @param name The name of the thread pool or null for the default pool.
*/
ThreadPool get(String name);
+
+ /**
+ * Create a new thread pool.
+ * If a pool with the same name already exists, no new pool is created
+ * and <code>null</code> is returned.
+ * @param name Name must not be null.
+ * @param blockPolicy The thread pool policy or null for the default.
+ * @param factory A thread factory or null for the default favtory.
+ */
+ ThreadPool create(String name,
+ int minPoolSize,
+ int maxPoolSize,
+ final int queueSize,
+ long keepAliveTime,
+ ThreadPoolPolicy blockPolicy,
+ final boolean shutdownGraceful,
+ final int shutdownWaitTimeMs,
+ final ThreadFactory factory,
+ final int priority,
+ final boolean isDaemon);
}
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
index c3fb849..1682abf 100644
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
@@ -59,31 +59,12 @@ public class DefaultThreadPool
* @param name - The name of the thread pool. If null {@link DefaultThreadPoolManager#DEFAULT_THREADPOOL_NAME}
* is used
*/
- public DefaultThreadPool(final String name) {
- this(DefaultThreadPoolManager.DEFAULT_THREADPOOL_NAME,
- DefaultThreadPoolManager.DEFAULT_MIN_POOL_SIZE,
- DefaultThreadPoolManager.DEFAULT_MAX_POOL_SIZE,
- DefaultThreadPoolManager.DEFAULT_QUEUE_SIZE,
- DefaultThreadPoolManager.DEFAULT_KEEP_ALIVE_TIME,
- DefaultThreadPoolManager.DEFAULT_BLOCK_POLICY,
- DefaultThreadPoolManager.DEFAULT_SHUTDOWN_GRACEFUL,
- DefaultThreadPoolManager.DEFAULT_SHUTDOWN_WAIT_TIME,
- null,
- DefaultThreadPoolManager.DEFAULT_THREAD_PRIORITY,
- DefaultThreadPoolManager.DEFAULT_DAEMON_MODE);
- }
-
- /**
- * Create a new thread pool.
- * @param name - The name of the thread pool. If null {@link DefaultThreadPoolManager#DEFAULT_THREADPOOL_NAME}
- * is used
- */
public DefaultThreadPool(final String name,
int minPoolSize,
int maxPoolSize,
final int queueSize,
long keepAliveTime,
- String blockPolicy,
+ ThreadPoolManager.ThreadPoolPolicy blockPolicy,
final boolean shutdownGraceful,
final int shutdownWaitTimeMs,
final ThreadFactory factory,
@@ -156,26 +137,20 @@ public class DefaultThreadPool
if ( blockPolicy == null ) {
blockPolicy = DefaultThreadPoolManager.DEFAULT_BLOCK_POLICY;
}
- final RejectedExecutionHandler handler;
- if (DefaultThreadPoolManager.POLICY_ABORT.equalsIgnoreCase(blockPolicy)) {
- handler = new ThreadPoolExecutor.AbortPolicy();
- } else if (DefaultThreadPoolManager.POLICY_DISCARD.equalsIgnoreCase(blockPolicy)) {
- handler = new ThreadPoolExecutor.AbortPolicy();
- } else if (DefaultThreadPoolManager.POLICY_DISCARD_OLDEST.equalsIgnoreCase(blockPolicy)) {
- handler = new ThreadPoolExecutor.AbortPolicy();
- } else if (DefaultThreadPoolManager.POLICY_RUN.equalsIgnoreCase(blockPolicy)) {
- handler = new ThreadPoolExecutor.AbortPolicy();
- } else {
- final StringBuffer msg = new StringBuffer();
- msg.append("WARNING: Unknown block-policy configuration \"")
- .append(blockPolicy);
- msg.append("\". Should be one of \"").append(DefaultThreadPoolManager.POLICY_ABORT);
- msg.append("\",\"").append(DefaultThreadPoolManager.POLICY_DISCARD);
- msg.append("\",\"").append(DefaultThreadPoolManager.POLICY_DISCARD_OLDEST);
- msg.append("\",\"").append(DefaultThreadPoolManager.POLICY_RUN);
- msg.append("\". Will use \"").append(DefaultThreadPoolManager.DEFAULT_BLOCK_POLICY).append("\"");
- logger.warn(msg.toString());
- handler = new ThreadPoolExecutor.CallerRunsPolicy();
+ RejectedExecutionHandler handler = null;
+ switch (blockPolicy) {
+ case ABORT :
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ break;
+ case DISCARD :
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ break;
+ case DISCARDOLDEST :
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ break;
+ case RUN :
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ break;
}
this.shutdownGraceful = shutdownGraceful;
this.shutdownWaitTimeMs = shutdownWaitTimeMs;
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
index c2c6183..fcaa35e 100644
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
@@ -18,6 +18,7 @@ package org.apache.sling.threads.impl;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ThreadFactory;
import org.apache.sling.threads.ThreadPool;
import org.apache.sling.threads.ThreadPoolManager;
@@ -60,24 +61,6 @@ public class DefaultThreadPoolManager implements ThreadPoolManager {
/** The default shutdown waittime time */
protected final static int DEFAULT_SHUTDOWN_WAIT_TIME = -1;
- /** The default shutdown waittime time */
- protected final static String DEFAULT_THREADPOOL_NAME = "default";
-
- /** ThreadPool block policy ABORT */
- protected final static String POLICY_ABORT = "ABORT";
-
- /** ThreadPool block policy DISCARD */
- protected final static String POLICY_DISCARD = "DISCARD";
-
- /** ThreadPool block policy DISCARD-OLDEST */
- protected final static String POLICY_DISCARD_OLDEST = "DISCARDOLDEST";
-
- /** ThreadPool block policy RUN */
- protected final static String POLICY_RUN = "RUN";
-
- /** The default shutdown waittime time */
- protected final static String DEFAULT_BLOCK_POLICY = POLICY_RUN;
-
/** By default we use the logger for this class. */
protected Logger logger = LoggerFactory.getLogger(getClass());
@@ -101,7 +84,9 @@ public class DefaultThreadPoolManager implements ThreadPoolManager {
null,
DEFAULT_THREAD_PRIORITY,
DEFAULT_DAEMON_MODE);
- this.pools.put(defaultPool.getName(), defaultPool);
+ synchronized ( this.pools ) {
+ this.pools.put(defaultPool.getName(), defaultPool);
+ }
this.logger.info("Thread pool manager startet with default pool.");
}
@@ -112,14 +97,16 @@ public class DefaultThreadPoolManager implements ThreadPoolManager {
this.logger.info("Stopping thread pool manager.");
this.logger.debug("Disposing all thread pools");
- for (ThreadPool pool : this.pools.values()) {
- this.logger.debug("Shutting down thread pool {}", pool.getName());
+ synchronized ( this.pools ) {
+ for (ThreadPool pool : this.pools.values()) {
+ this.logger.debug("Shutting down thread pool {}", pool.getName());
- pool.shutdown();
+ pool.shutdown();
- this.logger.debug("Thread pool " + pool.getName() + " is shut down.");
+ this.logger.debug("Thread pool " + pool.getName() + " is shut down.");
+ }
+ this.pools.clear();
}
- this.pools.clear();
this.logger.info("Thread pool manager stopped.");
}
@@ -152,4 +139,44 @@ public class DefaultThreadPoolManager implements ThreadPoolManager {
return pool;
}
}
+
+ /**
+ * @see org.apache.sling.threads.ThreadPoolManager#create(java.lang.String, int, int, int, long, org.apache.sling.threads.ThreadPoolManager.ThreadPoolPolicy, boolean, int, java.util.concurrent.ThreadFactory, int, boolean)
+ */
+ public ThreadPool create(String name,
+ int minPoolSize,
+ int maxPoolSize,
+ int queueSize,
+ long keepAliveTime,
+ ThreadPoolPolicy blockPolicy,
+ boolean shutdownGraceful,
+ int shutdownWaitTimeMs,
+ ThreadFactory factory,
+ int priority,
+ boolean isDaemon) {
+ if ( name == null ) {
+ throw new IllegalArgumentException("Name must not be null.");
+ }
+ synchronized ( this.pools ) {
+ ThreadPool pool = this.pools.get(name);
+ if ( pool != null ) {
+ // pool already exists
+ return null;
+ }
+ pool = new DefaultThreadPool(name,
+ minPoolSize,
+ maxPoolSize,
+ queueSize,
+ keepAliveTime,
+ blockPolicy,
+ shutdownGraceful,
+ shutdownWaitTimeMs,
+ factory,
+ priority,
+ isDaemon);
+ this.pools.put(name, pool);
+ return pool;
+ }
+ }
+
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 14/33: SLING-417: Move
threads to commons.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 8d1f9f1b00bf9b1d6216f346729dfeee15923cb0
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon May 5 06:31:05 2008 +0000
SLING-417: Move threads to commons.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@653306 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 12 ++++++------
.../apache/sling/{ => commons}/threads/ThreadPool.java | 2 +-
.../sling/{ => commons}/threads/ThreadPoolConfig.java | 2 +-
.../sling/{ => commons}/threads/ThreadPoolManager.java | 2 +-
.../{ => commons}/threads/impl/DefaultThreadPool.java | 16 ++++++++--------
.../threads/impl/DefaultThreadPoolManager.java | 16 ++++++++--------
.../threads/impl/ExtendedThreadFactory.java | 6 +++---
7 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0dafeaf..e2902e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
<relativePath>../../parent/pom.xml</relativePath>
</parent>
- <artifactId>org.apache.sling.threads</artifactId>
+ <artifactId>org.apache.sling.commons.threads</artifactId>
<packaging>bundle</packaging>
<version>2.0.0-incubator-SNAPSHOT</version>
@@ -38,13 +38,13 @@
<scm>
<connection>
- scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads
+ scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads
</connection>
<developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads
+ scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads
</developerConnection>
<url>
- http://svn.apache.org/viewvc/incubator/sling/trunk/sling/threads
+ http://svn.apache.org/viewvc/incubator/sling/trunk/commons/threads
</url>
</scm>
@@ -61,10 +61,10 @@
<configuration>
<instructions>
<Export-Package>
- org.apache.sling.threads
+ org.apache.sling.commons.threads
</Export-Package>
<Private-Package>
- org.apache.sling.threads.impl
+ org.apache.sling.commons.threads.impl
</Private-Package>
</instructions>
</configuration>
diff --git a/src/main/java/org/apache/sling/threads/ThreadPool.java b/src/main/java/org/apache/sling/commons/threads/ThreadPool.java
similarity index 96%
rename from src/main/java/org/apache/sling/threads/ThreadPool.java
rename to src/main/java/org/apache/sling/commons/threads/ThreadPool.java
index db8eb0b..e99c13e 100644
--- a/src/main/java/org/apache/sling/threads/ThreadPool.java
+++ b/src/main/java/org/apache/sling/commons/threads/ThreadPool.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.threads;
+package org.apache.sling.commons.threads;
/**
* The ThreadPool interface allows to start runnables by
diff --git a/src/main/java/org/apache/sling/threads/ThreadPoolConfig.java b/src/main/java/org/apache/sling/commons/threads/ThreadPoolConfig.java
similarity index 99%
rename from src/main/java/org/apache/sling/threads/ThreadPoolConfig.java
rename to src/main/java/org/apache/sling/commons/threads/ThreadPoolConfig.java
index a5792db..1274aaa 100644
--- a/src/main/java/org/apache/sling/threads/ThreadPoolConfig.java
+++ b/src/main/java/org/apache/sling/commons/threads/ThreadPoolConfig.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.threads;
+package org.apache.sling.commons.threads;
import java.util.concurrent.ThreadFactory;
diff --git a/src/main/java/org/apache/sling/threads/ThreadPoolManager.java b/src/main/java/org/apache/sling/commons/threads/ThreadPoolManager.java
similarity index 97%
rename from src/main/java/org/apache/sling/threads/ThreadPoolManager.java
rename to src/main/java/org/apache/sling/commons/threads/ThreadPoolManager.java
index db7c4e6..fc9c060 100644
--- a/src/main/java/org/apache/sling/threads/ThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/commons/threads/ThreadPoolManager.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.threads;
+package org.apache.sling.commons.threads;
/**
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
similarity index 93%
rename from src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
rename to src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
index d66d810..7c19c75 100644
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPool.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.threads.impl;
+package org.apache.sling.commons.threads.impl;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executors;
@@ -25,9 +25,9 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import org.apache.sling.threads.ThreadPool;
-import org.apache.sling.threads.ThreadPoolConfig;
-import org.apache.sling.threads.ThreadPoolManager;
+import org.apache.sling.commons.threads.ThreadPool;
+import org.apache.sling.commons.threads.ThreadPoolConfig;
+import org.apache.sling.commons.threads.ThreadPoolManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -137,7 +137,7 @@ public class DefaultThreadPool
}
/**
- * @see org.apache.sling.threads.ThreadPool#getName()
+ * @see org.apache.sling.commons.threads.ThreadPool#getName()
*/
public String getName() {
return name;
@@ -145,14 +145,14 @@ public class DefaultThreadPool
/**
- * @see org.apache.sling.threads.ThreadPool#getConfiguration()
+ * @see org.apache.sling.commons.threads.ThreadPool#getConfiguration()
*/
public ThreadPoolConfig getConfiguration() {
return this.configuration;
}
/**
- * @see org.apache.sling.threads.ThreadPool#execute(java.lang.Runnable)
+ * @see org.apache.sling.commons.threads.ThreadPool#execute(java.lang.Runnable)
*/
public void execute(Runnable runnable) {
if ( this.executor == null ) {
@@ -166,7 +166,7 @@ public class DefaultThreadPool
}
/**
- * @see org.apache.sling.threads.ThreadPool#shutdown()
+ * @see org.apache.sling.commons.threads.ThreadPool#shutdown()
*/
public void shutdown() {
if ( this.executor != null ) {
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
similarity index 86%
rename from src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
rename to src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
index 72cdc32..258aaae 100644
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.threads.impl;
+package org.apache.sling.commons.threads.impl;
import java.util.HashMap;
import java.util.Map;
-import org.apache.sling.threads.ThreadPool;
-import org.apache.sling.threads.ThreadPoolConfig;
-import org.apache.sling.threads.ThreadPoolManager;
+import org.apache.sling.commons.threads.ThreadPool;
+import org.apache.sling.commons.threads.ThreadPoolConfig;
+import org.apache.sling.commons.threads.ThreadPoolManager;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
* and is responsible to manage {@link ThreadPool}s.
*
* @scr.component metatype="false"
- * @scr.service interface="org.apache.sling.threads.ThreadPoolManager"
+ * @scr.service interface="org.apache.sling.commons.threads.ThreadPoolManager"
*
* @version $Id$
*/
@@ -78,7 +78,7 @@ public class DefaultThreadPoolManager implements ThreadPoolManager {
}
/**
- * @see org.apache.sling.threads.ThreadPoolManager#add(org.apache.sling.threads.ThreadPool)
+ * @see org.apache.sling.commons.threads.ThreadPoolManager#add(org.apache.sling.commons.threads.ThreadPool)
*/
public boolean add(ThreadPool pool) {
synchronized ( this.pools ) {
@@ -91,7 +91,7 @@ public class DefaultThreadPoolManager implements ThreadPoolManager {
}
/**
- * @see org.apache.sling.threads.ThreadPoolManager#get(java.lang.String)
+ * @see org.apache.sling.commons.threads.ThreadPoolManager#get(java.lang.String)
*/
public ThreadPool get(String name) {
if ( name == null ) {
@@ -108,7 +108,7 @@ public class DefaultThreadPoolManager implements ThreadPoolManager {
}
/**
- * @see org.apache.sling.threads.ThreadPoolManager#create(java.lang.String, org.apache.sling.threads.ThreadPoolConfig)
+ * @see org.apache.sling.commons.threads.ThreadPoolManager#create(java.lang.String, org.apache.sling.commons.threads.ThreadPoolConfig)
*/
public ThreadPool create(String name,
ThreadPoolConfig config) {
diff --git a/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java b/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
similarity index 94%
rename from src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java
rename to src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
index 45a17a7..b213fd8 100644
--- a/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/ExtendedThreadFactory.java
@@ -14,18 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sling.threads.impl;
+package org.apache.sling.commons.threads.impl;
import java.util.concurrent.ThreadFactory;
-import org.apache.sling.threads.ThreadPoolConfig;
+import org.apache.sling.commons.threads.ThreadPoolConfig;
/**
* This class is responsible to create new Thread instances.
* It's a very basic implementation.
*
- * @version $Id: DefaultThreadFactory.java 628678 2008-02-18 10:40:12Z cziegeler $
+ * @version $Id$
*/
public final class ExtendedThreadFactory implements ThreadFactory {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 12/33: Update notice files.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 2c687bd93a4f68ea105dc16d2d5aa09a2084052e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Apr 14 15:52:14 2008 +0000
Update notice files.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@647863 13f79535-47bb-0310-9956-ffa450edef68
---
NOTICE | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/NOTICE b/NOTICE
index 48434ce..f2af859 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,26 +1,6 @@
Apache Sling Threads
Copyright 2007-2008 The Apache Software Foundation
-
-I. Included Software
-
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Licensed under the Apache License 2.0.
-
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright 2006 The OSGi Alliance.
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-slf4j (http://www.sl4j.org)
-Licensed under the MIT License.
-
-
-III. License Summary
-- Apache License 2.0
-- MIT License
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 24/33:
[maven-release-plugin] prepare for next development iteration
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 70975433bb8890cd7ceed989be210286091fe42e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Jun 4 15:04:05 2008 +0000
[maven-release-plugin] prepare for next development iteration
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@663155 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index fb35cee..3016805 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
<artifactId>org.apache.sling.commons.threads</artifactId>
<packaging>bundle</packaging>
- <version>2.0.0-incubator</version>
+ <version>2.0.1-incubator-SNAPSHOT</version>
<name>Sling - Thread Support</name>
<description>
@@ -37,9 +37,9 @@
</description>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.threads-2.0.0-incubator</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.threads-2.0.0-incubator</developerConnection>
- <url>http://svn.apache.org/viewvc/incubator/sling/tags/org.apache.sling.commons.threads-2.0.0-incubator</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads</developerConnection>
+ <url>http://svn.apache.org/viewvc/incubator/sling/trunk/commons/threads</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 18/33: SLING-483: Add
excludes for javadocs (WiP)
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit b8442a7c69e624fc61488e7eb1bed2597d368a9a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri May 30 08:53:30 2008 +0000
SLING-483: Add excludes for javadocs (WiP)
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@661597 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/pom.xml b/pom.xml
index 3134d87..5735ad0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,6 +71,19 @@
</plugin>
</plugins>
</build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <excludePackageNames>
+ org.apache.sling.commons.threads.impl
+ </excludePackageNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 08/33: Move licence and
notice to top level dir.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit b9020b0f2164f27893f2abf5f8a1c912bcc77592
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Apr 10 15:38:48 2008 +0000
Move licence and notice to top level dir.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@646849 13f79535-47bb-0310-9956-ffa450edef68
---
LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 202 insertions(+)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 19/33: SLING-495 - NOTICE
files generated using mknotice script
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit f31810fd1372819bb6cea871b7c5cf494ca0ad13
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Jun 3 12:24:26 2008 +0000
SLING-495 - NOTICE files generated using mknotice script
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@662766 13f79535-47bb-0310-9956-ffa450edef68
---
NOTICE | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/NOTICE b/NOTICE
index f2af859..b27f3cd 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,6 +1,16 @@
-Apache Sling Threads
+Apache Sling - Thread Support
Copyright 2007-2008 The Apache Software Foundation
+Based on source code originally developed by
+Day Software (http://www.day.com/).
+
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Licensed under the Apache License 2.0.
+
+See http://www.apache.org/legal/3party.html for the ASF policy on
+third-party licenses.
+
+This product includes software developed at http://slf4j.org, distributed
+under the slf4j MIT-like license (http://slf4j.org/license.html).
+
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 33/33: Move Sling to new
TLP location
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 2862f32c436b9f92efa5029cec531a2cad8846bd
Merge: 0061bf1 77f106f
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Thu Jun 18 09:21:02 2009 +0000
Move Sling to new TLP location
git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.threads-2.0.2-incubator@785979 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 17/33: SLING-479 Fix
@scr.tags: - normalize metadata attribute settings to "no" - ensure proper
metadata and ds attributes are set - create metatype.properties files where
required - fix metatype.properties files
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit f7b228d8023b280da1a9b4ccebd67d0d3d793799
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Tue May 27 10:42:20 2008 +0000
SLING-479 Fix @scr.tags:
- normalize metadata attribute settings to "no"
- ensure proper metadata and ds attributes are set
- create metatype.properties files where required
- fix metatype.properties files
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@660460 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
index 258aaae..4ed4811 100644
--- a/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
* The DefaultThreadPoolManager implements the {@link ThreadPoolManager} interface
* and is responsible to manage {@link ThreadPool}s.
*
- * @scr.component metatype="false"
+ * @scr.component metatype="no"
* @scr.service interface="org.apache.sling.commons.threads.ThreadPoolManager"
*
* @version $Id$
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 30/33: Change copyright
year to 2008.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit b29c28ce86db0fd1bc49b9bb5b4f1c4670528280
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jun 16 12:08:14 2008 +0000
Change copyright year to 2008.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@668130 13f79535-47bb-0310-9956-ffa450edef68
---
NOTICE | 2 +-
src/main/resources/META-INF/NOTICE | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/NOTICE b/NOTICE
index d02f261..3a4d87e 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,5 +1,5 @@
Apache Sling Threads
-Copyright 2007-2008 The Apache Software Foundation
+Copyright 2008 The Apache Software Foundation
Apache Sling is based on source code originally developed
by Day Software (http://www.day.com/).
diff --git a/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE
index d02f261..3a4d87e 100644
--- a/src/main/resources/META-INF/NOTICE
+++ b/src/main/resources/META-INF/NOTICE
@@ -1,5 +1,5 @@
Apache Sling Threads
-Copyright 2007-2008 The Apache Software Foundation
+Copyright 2008 The Apache Software Foundation
Apache Sling is based on source code originally developed
by Day Software (http://www.day.com/).
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 07/33: Use thread pool
configuration object to be extensible.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit a5761c4442ccf6e02c504b32d03d5826f7fd60ef
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 18 17:13:36 2008 +0000
Use thread pool configuration object to be extensible.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@628820 13f79535-47bb-0310-9956-ffa450edef68
---
.../java/org/apache/sling/threads/ThreadPool.java | 2 +-
.../org/apache/sling/threads/ThreadPoolConfig.java | 202 +++++++++++++++++++++
.../apache/sling/threads/ThreadPoolManager.java | 26 +--
.../sling/threads/impl/DefaultThreadPool.java | 78 ++++----
.../threads/impl/DefaultThreadPoolManager.java | 65 +------
.../sling/threads/impl/ExtendedThreadFactory.java | 30 +--
6 files changed, 263 insertions(+), 140 deletions(-)
diff --git a/src/main/java/org/apache/sling/threads/ThreadPool.java b/src/main/java/org/apache/sling/threads/ThreadPool.java
index c849ed5..db8eb0b 100644
--- a/src/main/java/org/apache/sling/threads/ThreadPool.java
+++ b/src/main/java/org/apache/sling/threads/ThreadPool.java
@@ -40,5 +40,5 @@ public interface ThreadPool {
*/
void shutdown();
- int getMaxPoolSize();
+ ThreadPoolConfig getConfiguration();
}
diff --git a/src/main/java/org/apache/sling/threads/ThreadPoolConfig.java b/src/main/java/org/apache/sling/threads/ThreadPoolConfig.java
new file mode 100644
index 0000000..a5792db
--- /dev/null
+++ b/src/main/java/org/apache/sling/threads/ThreadPoolConfig.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.threads;
+
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * The ThreadPool configuration.
+ *
+ * @version $Id$
+ */
+public final class ThreadPoolConfig {
+
+ /** The thread pool policies. */
+ public enum ThreadPoolPolicy {
+ ABORT,
+ DISCARD,
+ DISCARDOLDEST,
+ RUN
+ };
+
+ public enum ThreadPriority {
+ NORM,
+ MIN,
+ MAX
+ };
+
+ /** The min pool size. */
+ private int minPoolSize = 5;
+
+ /** The max pool size. */
+ private int maxPoolSize = 5;
+
+ /** The queue size */
+ private int queueSize = -1;
+
+ /** The keep alive time. */
+ private long keepAliveTime = 60000L;
+
+ /** The thread pool policy. Default is RUN. */
+ private ThreadPoolPolicy blockPolicy = ThreadPoolPolicy.RUN;
+
+ private boolean shutdownGraceful = false;
+
+ private int shutdownWaitTimeMs = -1;
+
+ private ThreadFactory factory;
+
+ private ThreadPriority priority = ThreadPriority.NORM;
+
+ private boolean isDaemon = false;
+
+ /** Can this configuration still be changed? */
+ private boolean isWritable = true;
+
+ /**
+ * Create a new default configuration.
+ */
+ public ThreadPoolConfig() {
+ // nothing to do
+ }
+
+ /**
+ * Clone an existing configuration
+ * @param copy The config to clone
+ */
+ public ThreadPoolConfig(ThreadPoolConfig copy) {
+ this.minPoolSize = copy.minPoolSize;
+ this.maxPoolSize = copy.maxPoolSize;
+ this.queueSize = copy.queueSize;
+ this.keepAliveTime = copy.keepAliveTime;
+ this.blockPolicy = copy.blockPolicy;
+ this.shutdownGraceful = copy.shutdownGraceful;
+ this.shutdownWaitTimeMs = copy.shutdownWaitTimeMs;
+ this.factory = copy.factory;
+ this.priority = copy.priority;
+ this.isDaemon = copy.isDaemon;
+ }
+
+ protected void checkWritable() {
+ if ( !isWritable ) {
+ throw new IllegalStateException("ThreadPoolConfig is read-only.");
+ }
+ }
+
+ /**
+ * Make the configuration read-only.
+ */
+ public void makeReadOnly() {
+ this.isWritable = false;
+ }
+
+ public int getMinPoolSize() {
+ return minPoolSize;
+ }
+
+ public void setMinPoolSize(int minPoolSize) {
+ this.checkWritable();
+ this.minPoolSize = minPoolSize;
+ }
+
+ public int getMaxPoolSize() {
+ return maxPoolSize;
+ }
+
+ public void setMaxPoolSize(int maxPoolSize) {
+ this.checkWritable();
+ this.maxPoolSize = maxPoolSize;
+ }
+
+ public int getQueueSize() {
+ return queueSize;
+ }
+
+ public void setQueueSize(int queueSize) {
+ this.checkWritable();
+ this.queueSize = queueSize;
+ }
+
+ public long getKeepAliveTime() {
+ return keepAliveTime;
+ }
+
+ public void setKeepAliveTime(long keepAliveTime) {
+ this.checkWritable();
+ this.keepAliveTime = keepAliveTime;
+ }
+
+ public ThreadPoolPolicy getBlockPolicy() {
+ return blockPolicy;
+ }
+
+ public void setBlockPolicy(ThreadPoolPolicy blockPolicy) {
+ this.checkWritable();
+ this.blockPolicy = blockPolicy;
+ if ( blockPolicy == null ) {
+ throw new IllegalArgumentException("Policy must not be null.");
+ }
+ }
+
+ public boolean isShutdownGraceful() {
+ return shutdownGraceful;
+ }
+
+ public void setShutdownGraceful(boolean shutdownGraceful) {
+ this.checkWritable();
+ this.shutdownGraceful = shutdownGraceful;
+ }
+
+ public int getShutdownWaitTimeMs() {
+ return shutdownWaitTimeMs;
+ }
+
+ public void setShutdownWaitTimeMs(int shutdownWaitTimeMs) {
+ this.checkWritable();
+ this.shutdownWaitTimeMs = shutdownWaitTimeMs;
+ }
+
+ public ThreadFactory getFactory() {
+ return factory;
+ }
+
+ public void setFactory(ThreadFactory factory) {
+ this.checkWritable();
+ this.factory = factory;
+ }
+
+ public ThreadPriority getPriority() {
+ return priority;
+ }
+
+ public void setPriority(ThreadPriority priority) {
+ this.checkWritable();
+ if ( priority == null ) {
+ throw new IllegalArgumentException("Priority must not be null.");
+ }
+ this.priority = priority;
+ }
+
+ public boolean isDaemon() {
+ return isDaemon;
+ }
+
+ public void setDaemon(boolean isDaemon) {
+ this.checkWritable();
+ this.isDaemon = isDaemon;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/threads/ThreadPoolManager.java b/src/main/java/org/apache/sling/threads/ThreadPoolManager.java
index 62610b4..db7c4e6 100644
--- a/src/main/java/org/apache/sling/threads/ThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/threads/ThreadPoolManager.java
@@ -16,7 +16,6 @@
*/
package org.apache.sling.threads;
-import java.util.concurrent.ThreadFactory;
/**
* The <cod>ThreadPoolManager</code> manages thread pools.
@@ -28,17 +27,6 @@ public interface ThreadPoolManager {
/** The default thread pool name */
String DEFAULT_THREADPOOL_NAME = "default";
- /** The thread pool policies. */
- enum ThreadPoolPolicy {
- ABORT,
- DISCARD,
- DISCARDOLDEST,
- RUN
- };
-
- /** The default policy */
- ThreadPoolPolicy DEFAULT_BLOCK_POLICY = ThreadPoolPolicy.RUN;
-
/**
* Add a new pool.
* If a pool with the same name already exists, the new pool is not added
@@ -61,18 +49,8 @@ public interface ThreadPoolManager {
* If a pool with the same name already exists, no new pool is created
* and <code>null</code> is returned.
* @param name Name must not be null.
- * @param blockPolicy The thread pool policy or null for the default.
- * @param factory A thread factory or null for the default favtory.
+ * @param config The thread pool configuration.
*/
ThreadPool create(String name,
- int minPoolSize,
- int maxPoolSize,
- final int queueSize,
- long keepAliveTime,
- ThreadPoolPolicy blockPolicy,
- final boolean shutdownGraceful,
- final int shutdownWaitTimeMs,
- final ThreadFactory factory,
- final int priority,
- final boolean isDaemon);
+ ThreadPoolConfig config);
}
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
index 37289bd..d66d810 100644
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
@@ -26,6 +26,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.sling.threads.ThreadPool;
+import org.apache.sling.threads.ThreadPoolConfig;
import org.apache.sling.threads.ThreadPoolManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,11 +50,7 @@ public class DefaultThreadPool
/** The executor. */
protected ThreadPoolExecutor executor;
- /** Should we wait for running jobs to terminate on shutdown ? */
- protected final boolean shutdownGraceful;
-
- /** How long to wait for running jobs to terminate on disposition */
- protected final int shutdownWaitTimeMs;
+ protected final ThreadPoolConfig configuration;
/**
* Create a new thread pool.
@@ -61,16 +58,7 @@ public class DefaultThreadPool
* is used
*/
public DefaultThreadPool(final String name,
- int minPoolSize,
- int maxPoolSize,
- final int queueSize,
- long keepAliveTime,
- ThreadPoolManager.ThreadPoolPolicy blockPolicy,
- final boolean shutdownGraceful,
- final int shutdownWaitTimeMs,
- final ThreadFactory factory,
- final int priority,
- final boolean isDaemon) {
+ ThreadPoolConfig origConfig) {
this.logger.info("ThreadPool [{}] initializing ...", name);
// name
@@ -80,42 +68,41 @@ public class DefaultThreadPool
this.name = DefaultThreadPoolManager.DEFAULT_THREADPOOL_NAME;
}
+ this.configuration = new ThreadPoolConfig(origConfig);
+
// factory
final ThreadFactory delegateThreadFactory;
- if (factory == null) {
+ if (this.configuration.getFactory() == null) {
logger.warn("No ThreadFactory is configured. Will use JVM default thread factory."
+ ExtendedThreadFactory.class.getName());
delegateThreadFactory = Executors.defaultThreadFactory();
} else {
- delegateThreadFactory = factory;
+ delegateThreadFactory = this.configuration.getFactory();
}
// Min pool size
- // make sure we have enough threads for the default thread pool as we
- // need one for ourself
- if (DefaultThreadPoolManager.DEFAULT_THREADPOOL_NAME.equals(name)
- && ((minPoolSize > 0) && (minPoolSize < DefaultThreadPoolManager.DEFAULT_MIN_POOL_SIZE))) {
- minPoolSize = DefaultThreadPoolManager.DEFAULT_MIN_POOL_SIZE;
- } else if (minPoolSize < 1) {
- minPoolSize = 1;
+ if (this.configuration.getMinPoolSize() < 1) {
+ this.configuration.setMinPoolSize(1);
this.logger.warn("min-pool-size < 1 for pool \"" + name + "\". Set to 1");
}
// Max pool size
- maxPoolSize = (maxPoolSize < 0) ? Integer.MAX_VALUE : maxPoolSize;
+ if ( this.configuration.getMaxPoolSize() < 0 ) {
+ this.configuration.setMaxPoolSize(Integer.MAX_VALUE);
+ }
// Set priority and daemon flag
- final ExtendedThreadFactory threadFactory = new ExtendedThreadFactory(delegateThreadFactory, priority, isDaemon);
+ final ExtendedThreadFactory threadFactory = new ExtendedThreadFactory(delegateThreadFactory, this.configuration.getPriority(), this.configuration.isDaemon());
// Keep alive time
- if (keepAliveTime < 0) {
- keepAliveTime = 1000;
+ if (this.configuration.getKeepAliveTime() < 0) {
+ this.configuration.setKeepAliveTime(1000);
this.logger.warn("keep-alive-time-ms < 0 for pool \"" + name + "\". Set to 1000");
}
// Queue
final BlockingQueue<Runnable> queue;
- if (queueSize != 0) {
- if (queueSize > 0) {
- queue = new java.util.concurrent.ArrayBlockingQueue<Runnable>(queueSize);
+ if (this.configuration.getQueueSize() != 0) {
+ if (this.configuration.getQueueSize() > 0) {
+ queue = new java.util.concurrent.ArrayBlockingQueue<Runnable>(this.configuration.getQueueSize());
} else {
queue = new LinkedBlockingQueue<Runnable>();
}
@@ -123,11 +110,8 @@ public class DefaultThreadPool
queue = new SynchronousQueue<Runnable>();
}
- if ( blockPolicy == null ) {
- blockPolicy = DefaultThreadPoolManager.DEFAULT_BLOCK_POLICY;
- }
RejectedExecutionHandler handler = null;
- switch (blockPolicy) {
+ switch (this.configuration.getBlockPolicy()) {
case ABORT :
handler = new ThreadPoolExecutor.AbortPolicy();
break;
@@ -141,15 +125,14 @@ public class DefaultThreadPool
handler = new ThreadPoolExecutor.AbortPolicy();
break;
}
- this.shutdownGraceful = shutdownGraceful;
- this.shutdownWaitTimeMs = shutdownWaitTimeMs;
- this.executor = new ThreadPoolExecutor(minPoolSize,
- maxPoolSize,
- keepAliveTime,
+ this.executor = new ThreadPoolExecutor(this.configuration.getMinPoolSize(),
+ this.configuration.getMaxPoolSize(),
+ this.configuration.getKeepAliveTime(),
TimeUnit.MILLISECONDS,
queue,
threadFactory,
handler);
+ this.configuration.makeReadOnly();
this.logger.info("ThreadPool [{}] initialized.", name);
}
@@ -160,11 +143,12 @@ public class DefaultThreadPool
return name;
}
+
/**
- * @see org.apache.sling.threads.ThreadPool#getMaxPoolSize()
+ * @see org.apache.sling.threads.ThreadPool#getConfiguration()
*/
- public int getMaxPoolSize() {
- return this.executor.getMaximumPoolSize();
+ public ThreadPoolConfig getConfiguration() {
+ return this.configuration;
}
/**
@@ -186,17 +170,17 @@ public class DefaultThreadPool
*/
public void shutdown() {
if ( this.executor != null ) {
- if (shutdownGraceful) {
+ if (this.configuration.isShutdownGraceful()) {
this.executor.shutdown();
} else {
this.executor.shutdownNow();
}
try {
- if (this.shutdownWaitTimeMs > 0) {
- if (!this.executor.awaitTermination(this.shutdownWaitTimeMs, TimeUnit.MILLISECONDS)) {
+ if (this.configuration.getShutdownWaitTimeMs() > 0) {
+ if (!this.executor.awaitTermination(this.configuration.getShutdownWaitTimeMs(), TimeUnit.MILLISECONDS)) {
logger.warn("running commands have not terminated within "
- + this.shutdownWaitTimeMs
+ + this.configuration.getShutdownWaitTimeMs()
+ "ms. Will shut them down by interruption");
this.executor.shutdownNow();
}
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
index fcaa35e..72cdc32 100644
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
@@ -18,9 +18,9 @@ package org.apache.sling.threads.impl;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.ThreadFactory;
import org.apache.sling.threads.ThreadPool;
+import org.apache.sling.threads.ThreadPoolConfig;
import org.apache.sling.threads.ThreadPoolManager;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
@@ -37,30 +37,6 @@ import org.slf4j.LoggerFactory;
*/
public class DefaultThreadPoolManager implements ThreadPoolManager {
- /** The default queue size */
- protected final static int DEFAULT_QUEUE_SIZE = -1;
-
- /** The default maximum pool size */
- protected final static int DEFAULT_MAX_POOL_SIZE = 5;
-
- /** The default minimum pool size */
- protected final static int DEFAULT_MIN_POOL_SIZE = 5;
-
- /** The default thread priority */
- protected final static int DEFAULT_THREAD_PRIORITY = Thread.NORM_PRIORITY;
-
- /** The default daemon mode */
- protected final static boolean DEFAULT_DAEMON_MODE = false;
-
- /** The default keep alive time */
- protected final static long DEFAULT_KEEP_ALIVE_TIME = 60000L;
-
- /** The default way to shutdown gracefully */
- protected final static boolean DEFAULT_SHUTDOWN_GRACEFUL = false;
-
- /** The default shutdown waittime time */
- protected final static int DEFAULT_SHUTDOWN_WAIT_TIME = -1;
-
/** By default we use the logger for this class. */
protected Logger logger = LoggerFactory.getLogger(getClass());
@@ -74,16 +50,7 @@ public class DefaultThreadPoolManager implements ThreadPoolManager {
this.logger.info("Starting thread pool manager.");
final ThreadPool defaultPool = new DefaultThreadPool(
DEFAULT_THREADPOOL_NAME,
- DEFAULT_MIN_POOL_SIZE,
- DEFAULT_MAX_POOL_SIZE,
- DEFAULT_QUEUE_SIZE,
- DEFAULT_KEEP_ALIVE_TIME,
- DEFAULT_BLOCK_POLICY,
- DEFAULT_SHUTDOWN_GRACEFUL,
- DEFAULT_SHUTDOWN_WAIT_TIME,
- null,
- DEFAULT_THREAD_PRIORITY,
- DEFAULT_DAEMON_MODE);
+ new ThreadPoolConfig());
synchronized ( this.pools ) {
this.pools.put(defaultPool.getName(), defaultPool);
}
@@ -141,39 +108,23 @@ public class DefaultThreadPoolManager implements ThreadPoolManager {
}
/**
- * @see org.apache.sling.threads.ThreadPoolManager#create(java.lang.String, int, int, int, long, org.apache.sling.threads.ThreadPoolManager.ThreadPoolPolicy, boolean, int, java.util.concurrent.ThreadFactory, int, boolean)
+ * @see org.apache.sling.threads.ThreadPoolManager#create(java.lang.String, org.apache.sling.threads.ThreadPoolConfig)
*/
public ThreadPool create(String name,
- int minPoolSize,
- int maxPoolSize,
- int queueSize,
- long keepAliveTime,
- ThreadPoolPolicy blockPolicy,
- boolean shutdownGraceful,
- int shutdownWaitTimeMs,
- ThreadFactory factory,
- int priority,
- boolean isDaemon) {
+ ThreadPoolConfig config) {
if ( name == null ) {
throw new IllegalArgumentException("Name must not be null.");
}
+ if ( config == null ) {
+ throw new IllegalArgumentException("Config must not be null.");
+ }
synchronized ( this.pools ) {
ThreadPool pool = this.pools.get(name);
if ( pool != null ) {
// pool already exists
return null;
}
- pool = new DefaultThreadPool(name,
- minPoolSize,
- maxPoolSize,
- queueSize,
- keepAliveTime,
- blockPolicy,
- shutdownGraceful,
- shutdownWaitTimeMs,
- factory,
- priority,
- isDaemon);
+ pool = new DefaultThreadPool(name, config);
this.pools.put(name, pool);
return pool;
}
diff --git a/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java b/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java
index 7a030a7..45a17a7 100644
--- a/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java
+++ b/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java
@@ -18,12 +18,14 @@ package org.apache.sling.threads.impl;
import java.util.concurrent.ThreadFactory;
+import org.apache.sling.threads.ThreadPoolConfig;
+
/**
* This class is responsible to create new Thread instances.
* It's a very basic implementation.
*
- * @version $Id$
+ * @version $Id: DefaultThreadFactory.java 628678 2008-02-18 10:40:12Z cziegeler $
*/
public final class ExtendedThreadFactory implements ThreadFactory {
@@ -39,21 +41,27 @@ public final class ExtendedThreadFactory implements ThreadFactory {
/**
* Create a new wrapper for a thread factory handling the
*
- * @param priority One of {@link Thread#MIN_PRIORITY}, {@link
- * Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY}
+ * @param priority A non null value.
* @param isDaemon Whether new {@link Thread}s should run as daemons.
*/
public ExtendedThreadFactory(final ThreadFactory factory,
- final int priority,
+ final ThreadPoolConfig.ThreadPriority priority,
final boolean isDaemon) {
this.isDaemon = isDaemon;
- if( ( Thread.MAX_PRIORITY == priority ) ||
- ( Thread.MIN_PRIORITY == priority ) ||
- ( Thread.NORM_PRIORITY == priority ) ) {
- this.priority = priority;
- } else {
- throw new IllegalStateException("Unknown priority " + priority);
- }
+ if ( priority == null ) {
+ throw new IllegalStateException("Prioriy must not be null.");
+ }
+ switch ( priority ) {
+ case NORM : this.priority = Thread.NORM_PRIORITY;
+ break;
+ case MIN : this.priority = Thread.MIN_PRIORITY;
+ break;
+ case MAX : this.priority = Thread.MAX_PRIORITY;
+ break;
+ default: // this can never happen
+ this.priority = Thread.NORM_PRIORITY;
+ break;
+ }
this.factory = factory;
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 23/33:
[maven-release-plugin] prepare release
org.apache.sling.commons.threads-2.0.0-incubator
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit e4986f962e472dedee4d33489659122993bee9e7
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Jun 4 15:03:55 2008 +0000
[maven-release-plugin] prepare release org.apache.sling.commons.threads-2.0.0-incubator
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@663153 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0b3cced..fb35cee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
<artifactId>org.apache.sling.commons.threads</artifactId>
<packaging>bundle</packaging>
- <version>2.0.0-incubator-SNAPSHOT</version>
+ <version>2.0.0-incubator</version>
<name>Sling - Thread Support</name>
<description>
@@ -37,15 +37,9 @@
</description>
<scm>
- <connection>
- scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads
- </connection>
- <developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads
- </developerConnection>
- <url>
- http://svn.apache.org/viewvc/incubator/sling/trunk/commons/threads
- </url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.threads-2.0.0-incubator</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/tags/org.apache.sling.commons.threads-2.0.0-incubator</developerConnection>
+ <url>http://svn.apache.org/viewvc/incubator/sling/tags/org.apache.sling.commons.threads-2.0.0-incubator</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 03/33: Use thread pool to
create new threads instead of directly instantiating threads.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 6569a9317a397032999d234f10b0bf7ce16a6c3d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 18 08:29:52 2008 +0000
Use thread pool to create new threads instead of directly instantiating threads.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@628641 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/sling/threads/impl/DefaultThreadPoolManager.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
index d122cd3..c2c6183 100644
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
@@ -144,7 +144,12 @@ public class DefaultThreadPoolManager implements ThreadPoolManager {
name = DEFAULT_THREADPOOL_NAME;
}
synchronized (this.pools) {
- return this.pools.get(name);
+ ThreadPool pool = this.pools.get(name);
+ if ( pool == null && !(name.equals(DEFAULT_THREADPOOL_NAME))) {
+ this.logger.info("Requested pool {} is not available, returning default pool.", name);
+ pool = this.pools.get(DEFAULT_THREADPOOL_NAME);
+ }
+ return pool;
}
}
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 02/33: Set svn:ignore
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit c3a54e0ff2233d0c73ddf0c58c01ef1747012f11
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 11 11:04:36 2008 +0000
Set svn:ignore
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@620458 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 11/33: Write first element
in pom in one line (to avoid problems with the maven release plugin) and
minor pom fixes.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 3020eb2ad946f59b5ec54700aec2b10b806e82b0
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Apr 14 13:34:08 2008 +0000
Write first element in pom in one line (to avoid problems with the maven release plugin) and minor pom fixes.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@647795 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5027142..0dafeaf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,9 +17,8 @@
specific language governing permissions and limitations
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.sling</groupId>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 15/33: Eclude
maven-eclipse.xml generated by the maven eclipse plugin.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 23e3268d6247323790daab25f67d45d8045d6de7
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon May 5 07:05:56 2008 +0000
Eclude maven-eclipse.xml generated by the maven eclipse plugin.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@653321 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 09/33: Add incubator
disclaimer.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit e413af3cdb05766c8b2fa974d753e9a1229673a5
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Apr 14 12:58:07 2008 +0000
Add incubator disclaimer.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@647780 13f79535-47bb-0310-9956-ffa450edef68
---
DISCLAIMER | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/DISCLAIMER b/DISCLAIMER
new file mode 100644
index 0000000..90850c2
--- /dev/null
+++ b/DISCLAIMER
@@ -0,0 +1,7 @@
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 27/33: SLING-521: Separate
between notice files for bin and src dists.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit dc0cc02d4f701a671f28cd1cdeed1accfb8f67cf
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jun 13 10:41:22 2008 +0000
SLING-521: Separate between notice files for bin and src dists.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@667466 13f79535-47bb-0310-9956-ffa450edef68
---
NOTICE | 1 -
README.txt | 35 ++++
.../main/resources/META-INF/DISCLAIMER | 0
src/main/resources/META-INF/LICENSE | 202 +++++++++++++++++++++
NOTICE => src/main/resources/META-INF/NOTICE | 1 -
5 files changed, 237 insertions(+), 2 deletions(-)
diff --git a/NOTICE b/NOTICE
index f39eb41..d02f261 100644
--- a/NOTICE
+++ b/NOTICE
@@ -6,4 +6,3 @@ by Day Software (http://www.day.com/).
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..16e5797
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,35 @@
+WE NEED A LOT MORE HERE!!!!!!!!!!!!!!!!!!
+
+
+Disclaimer
+==========
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
+
+Getting Started
+===============
+
+This component uses a Maven 2 (http://maven.apache.org/) build
+environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/)
+2.0.7 or later. We recommend to use the latest Maven version.
+
+If you have Maven 2 installed, you can compile and
+package the jar using the following command:
+
+ mvn package
+
+See the Maven 2 documentation for other build features.
+
+The latest source code for this component is available in the
+Subversion (http://subversion.tigris.org/) source repository of
+the Apache Software Foundation. If you have Subversion installed,
+you can checkout the latest source using the following command:
+
+ svn checkout http://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads
+
+See the Subversion documentation for other source control features.
diff --git a/DISCLAIMER b/src/main/resources/META-INF/DISCLAIMER
similarity index 100%
rename from DISCLAIMER
rename to src/main/resources/META-INF/DISCLAIMER
diff --git a/src/main/resources/META-INF/LICENSE b/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/NOTICE b/src/main/resources/META-INF/NOTICE
similarity index 87%
copy from NOTICE
copy to src/main/resources/META-INF/NOTICE
index f39eb41..d02f261 100644
--- a/NOTICE
+++ b/src/main/resources/META-INF/NOTICE
@@ -6,4 +6,3 @@ by Day Software (http://www.day.com/).
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 05/33: Use thread pooling
for scheduler as well. Create own pool for eventing.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 5dfc71609e13646330bbb72b68a4664bb565b254
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 18 10:40:12 2008 +0000
Use thread pooling for scheduler as well. Create own pool for eventing.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@628678 13f79535-47bb-0310-9956-ffa450edef68
---
src/main/java/org/apache/sling/threads/ThreadPool.java | 2 ++
.../java/org/apache/sling/threads/impl/DefaultThreadFactory.java | 2 +-
src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java | 7 +++++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/threads/ThreadPool.java b/src/main/java/org/apache/sling/threads/ThreadPool.java
index f10527e..c849ed5 100644
--- a/src/main/java/org/apache/sling/threads/ThreadPool.java
+++ b/src/main/java/org/apache/sling/threads/ThreadPool.java
@@ -39,4 +39,6 @@ public interface ThreadPool {
* Shut down the thread pool.
*/
void shutdown();
+
+ int getMaxPoolSize();
}
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadFactory.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadFactory.java
index 78a514e..2cffa80 100644
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadFactory.java
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadFactory.java
@@ -55,7 +55,7 @@ public class DefaultThreadFactory
( Thread.NORM_PRIORITY == priority ) ) {
this.priority = priority;
} else {
- throw new IllegalStateException("Unknown priority " + this.priority);
+ throw new IllegalStateException("Unknown priority " + priority);
}
}
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
index 1682abf..f685c15 100644
--- a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
@@ -172,6 +172,13 @@ public class DefaultThreadPool
}
/**
+ * @see org.apache.sling.threads.ThreadPool#getMaxPoolSize()
+ */
+ public int getMaxPoolSize() {
+ return this.executor.getMaximumPoolSize();
+ }
+
+ /**
* @see org.apache.sling.threads.ThreadPool#execute(java.lang.Runnable)
*/
public void execute(Runnable runnable) {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 22/33: Use released
version of parent pom.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit 601db57b864176a70645b9916a31b9d08013ed78
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Jun 4 14:16:40 2008 +0000
Use released version of parent pom.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/threads@663109 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 5735ad0..0b3cced 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>1-incubator-SNAPSHOT</version>
+ <version>1-incubator</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-threads] 01/33: Add new threads
module for providing thread pools.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.threads-2.0.2-incubator
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-threads.git
commit cdf45818eca719b0bbc76145a4d5909aa0cda42a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 11 11:03:12 2008 +0000
Add new threads module for providing thread pools.
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads@620457 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 85 ++++++++
.../java/org/apache/sling/threads/ThreadPool.java | 42 ++++
.../apache/sling/threads/ThreadPoolManager.java | 40 ++++
.../sling/threads/impl/DefaultThreadFactory.java | 79 +++++++
.../sling/threads/impl/DefaultThreadPool.java | 239 +++++++++++++++++++++
.../threads/impl/DefaultThreadPoolManager.java | 150 +++++++++++++
.../sling/threads/impl/ExtendedThreadFactory.java | 67 ++++++
7 files changed, 702 insertions(+)
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..5027142
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>1-incubator-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.sling.threads</artifactId>
+ <packaging>bundle</packaging>
+ <version>2.0.0-incubator-SNAPSHOT</version>
+
+ <name>Sling - Thread Support</name>
+ <description>
+ Support for thread handling like pooling.
+ </description>
+
+ <scm>
+ <connection>
+ scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/sling/threads
+ </developerConnection>
+ <url>
+ http://svn.apache.org/viewvc/incubator/sling/trunk/sling/threads
+ </url>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.sling.threads
+ </Export-Package>
+ <Private-Package>
+ org.apache.sling.threads.impl
+ </Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/threads/ThreadPool.java b/src/main/java/org/apache/sling/threads/ThreadPool.java
new file mode 100644
index 0000000..f10527e
--- /dev/null
+++ b/src/main/java/org/apache/sling/threads/ThreadPool.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.threads;
+
+/**
+ * The ThreadPool interface allows to start runnables by
+ * getting threads from a managed pool.
+ *
+ * @version $Id$
+ */
+public interface ThreadPool {
+
+ /**
+ * Execute a runnable
+ * @param runnable The {@link Runnable} to execute
+ */
+ void execute(Runnable runnable);
+
+ /**
+ * The name of the thread pool.
+ */
+ String getName();
+
+ /**
+ * Shut down the thread pool.
+ */
+ void shutdown();
+}
diff --git a/src/main/java/org/apache/sling/threads/ThreadPoolManager.java b/src/main/java/org/apache/sling/threads/ThreadPoolManager.java
new file mode 100644
index 0000000..603aa46
--- /dev/null
+++ b/src/main/java/org/apache/sling/threads/ThreadPoolManager.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.threads;
+
+/**
+ * The <cod>ThreadPoolManager</code> manages thread pools.
+ *
+ * @version $Id$
+ */
+public interface ThreadPoolManager {
+
+ /**
+ * Add a new pool.
+ * If a pool with the same name already exists, the new pool is not added
+ * and false is returned.
+ * @param pool The pool
+ * @return True if the pool could be added, false otherwise.
+ */
+ boolean add(ThreadPool pool);
+
+ /**
+ * Get a thread pool
+ * @param name The name of the thread pool or null for the default pool.
+ */
+ ThreadPool get(String name);
+}
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadFactory.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadFactory.java
new file mode 100644
index 0000000..78a514e
--- /dev/null
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadFactory.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.threads.impl;
+
+
+/**
+ * This class is responsible to create new Thread instances.
+ * It's a very basic implementation.
+ *
+ * @version $Id$
+ */
+public class DefaultThreadFactory
+ implements ExtendedThreadFactory {
+
+ /** The daemon mode */
+ private boolean isDaemon = DefaultThreadPoolManager.DEFAULT_DAEMON_MODE;
+
+ /** The priority of newly created Threads */
+ private int priority = DefaultThreadPoolManager.DEFAULT_THREAD_PRIORITY;
+
+ /**
+ * @see org.apache.sling.threads.impl.ExtendedThreadFactory#setDaemon(boolean)
+ */
+ public void setDaemon( boolean isDaemon ) {
+ this.isDaemon = isDaemon;
+ }
+
+ /**
+ * @see org.apache.sling.threads.impl.ExtendedThreadFactory#isDaemon()
+ */
+ public boolean isDaemon() {
+ return this.isDaemon;
+ }
+
+ /**
+ * @see org.apache.sling.threads.impl.ExtendedThreadFactory#setPriority(int)
+ */
+ public void setPriority( final int priority ) {
+ if( ( Thread.MAX_PRIORITY == priority ) ||
+ ( Thread.MIN_PRIORITY == priority ) ||
+ ( Thread.NORM_PRIORITY == priority ) ) {
+ this.priority = priority;
+ } else {
+ throw new IllegalStateException("Unknown priority " + this.priority);
+ }
+ }
+
+ /**
+ * @see org.apache.sling.threads.impl.ExtendedThreadFactory#getPriority()
+ */
+ public int getPriority() {
+ return this.priority;
+ }
+
+ /**
+ * @see org.apache.sling.threads.impl.ExtendedThreadFactory#newThread(java.lang.Runnable)
+ */
+ public Thread newThread( final Runnable command ) {
+ final Thread thread = new Thread( command );
+ thread.setPriority( this.priority );
+ thread.setDaemon( this.isDaemon );
+
+ return thread;
+ }
+}
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
new file mode 100644
index 0000000..c3fb849
--- /dev/null
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPool.java
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.threads.impl;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.sling.threads.ThreadPool;
+import org.apache.sling.threads.ThreadPoolManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The DefaultThreadPool class implements the {@link ThreadPool} interface.
+ * Instances of this class are managed by the {@link ThreadPoolManager}.
+ *
+ * @version $Id$
+ */
+public class DefaultThreadPool
+ implements ThreadPool {
+
+ /** By default we use the logger for this class. */
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ /** The name of this thread pool */
+ protected final String name;
+
+ /** The executor. */
+ protected ThreadPoolExecutor executor;
+
+ /** Should we wait for running jobs to terminate on shutdown ? */
+ protected final boolean shutdownGraceful;
+
+ /** How long to wait for running jobs to terminate on disposition */
+ protected final int shutdownWaitTimeMs;
+
+ /**
+ * Create a new thread pool.
+ * @param name - The name of the thread pool. If null {@link DefaultThreadPoolManager#DEFAULT_THREADPOOL_NAME}
+ * is used
+ */
+ public DefaultThreadPool(final String name) {
+ this(DefaultThreadPoolManager.DEFAULT_THREADPOOL_NAME,
+ DefaultThreadPoolManager.DEFAULT_MIN_POOL_SIZE,
+ DefaultThreadPoolManager.DEFAULT_MAX_POOL_SIZE,
+ DefaultThreadPoolManager.DEFAULT_QUEUE_SIZE,
+ DefaultThreadPoolManager.DEFAULT_KEEP_ALIVE_TIME,
+ DefaultThreadPoolManager.DEFAULT_BLOCK_POLICY,
+ DefaultThreadPoolManager.DEFAULT_SHUTDOWN_GRACEFUL,
+ DefaultThreadPoolManager.DEFAULT_SHUTDOWN_WAIT_TIME,
+ null,
+ DefaultThreadPoolManager.DEFAULT_THREAD_PRIORITY,
+ DefaultThreadPoolManager.DEFAULT_DAEMON_MODE);
+ }
+
+ /**
+ * Create a new thread pool.
+ * @param name - The name of the thread pool. If null {@link DefaultThreadPoolManager#DEFAULT_THREADPOOL_NAME}
+ * is used
+ */
+ public DefaultThreadPool(final String name,
+ int minPoolSize,
+ int maxPoolSize,
+ final int queueSize,
+ long keepAliveTime,
+ String blockPolicy,
+ final boolean shutdownGraceful,
+ final int shutdownWaitTimeMs,
+ final ThreadFactory factory,
+ final int priority,
+ final boolean isDaemon) {
+ this.logger.info("ThreadPool [{}] initializing ...", name);
+
+ // name
+ if ( name != null ) {
+ this.name = name;
+ } else {
+ this.name = DefaultThreadPoolManager.DEFAULT_THREADPOOL_NAME;
+ }
+
+ // factory
+ final ThreadFactory threadFactory;
+ if (factory == null) {
+ logger.warn("No ThreadFactory is configured. Will use a "
+ + DefaultThreadFactory.class.getName());
+ threadFactory = new DefaultThreadFactory();
+ } else {
+ threadFactory = factory;
+ }
+
+ // Min pool size
+ // make sure we have enough threads for the default thread pool as we
+ // need one for ourself
+ if (DefaultThreadPoolManager.DEFAULT_THREADPOOL_NAME.equals(name)
+ && ((minPoolSize > 0) && (minPoolSize < DefaultThreadPoolManager.DEFAULT_MIN_POOL_SIZE))) {
+ minPoolSize = DefaultThreadPoolManager.DEFAULT_MIN_POOL_SIZE;
+ } else if (minPoolSize < 1) {
+ minPoolSize = 1;
+ this.logger.warn("min-pool-size < 1 for pool \"" + name + "\". Set to 1");
+ }
+ // Max pool size
+ maxPoolSize = (maxPoolSize < 0) ? Integer.MAX_VALUE : maxPoolSize;
+
+ // Set priority and daemon if the factory is an extended factory
+ if ( threadFactory instanceof ExtendedThreadFactory ) {
+ final ExtendedThreadFactory extTF = (ExtendedThreadFactory)threadFactory;
+ extTF.setPriority(priority);
+ extTF.setDaemon(isDaemon);
+ } else {
+ if ( priority != Thread.NORM_PRIORITY ) {
+ this.logger.warn("ThreadFactory " + threadFactory + " does not support setting the priority or daemon setting.");
+ }
+ if ( isDaemon != DefaultThreadPoolManager.DEFAULT_DAEMON_MODE ) {
+ this.logger.warn("ThreadFactory " + threadFactory + " does not support setting the daemon mode.");
+ }
+ }
+
+ // Keep alive time
+ if (keepAliveTime < 0) {
+ keepAliveTime = 1000;
+ this.logger.warn("keep-alive-time-ms < 0 for pool \"" + name + "\". Set to 1000");
+ }
+
+ // Queue
+ final BlockingQueue<Runnable> queue;
+ if (queueSize != 0) {
+ if (queueSize > 0) {
+ queue = new java.util.concurrent.ArrayBlockingQueue<Runnable>(queueSize);
+ } else {
+ queue = new LinkedBlockingQueue<Runnable>();
+ }
+ } else {
+ queue = new SynchronousQueue<Runnable>();
+ }
+
+ if ( blockPolicy == null ) {
+ blockPolicy = DefaultThreadPoolManager.DEFAULT_BLOCK_POLICY;
+ }
+ final RejectedExecutionHandler handler;
+ if (DefaultThreadPoolManager.POLICY_ABORT.equalsIgnoreCase(blockPolicy)) {
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ } else if (DefaultThreadPoolManager.POLICY_DISCARD.equalsIgnoreCase(blockPolicy)) {
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ } else if (DefaultThreadPoolManager.POLICY_DISCARD_OLDEST.equalsIgnoreCase(blockPolicy)) {
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ } else if (DefaultThreadPoolManager.POLICY_RUN.equalsIgnoreCase(blockPolicy)) {
+ handler = new ThreadPoolExecutor.AbortPolicy();
+ } else {
+ final StringBuffer msg = new StringBuffer();
+ msg.append("WARNING: Unknown block-policy configuration \"")
+ .append(blockPolicy);
+ msg.append("\". Should be one of \"").append(DefaultThreadPoolManager.POLICY_ABORT);
+ msg.append("\",\"").append(DefaultThreadPoolManager.POLICY_DISCARD);
+ msg.append("\",\"").append(DefaultThreadPoolManager.POLICY_DISCARD_OLDEST);
+ msg.append("\",\"").append(DefaultThreadPoolManager.POLICY_RUN);
+ msg.append("\". Will use \"").append(DefaultThreadPoolManager.DEFAULT_BLOCK_POLICY).append("\"");
+ logger.warn(msg.toString());
+ handler = new ThreadPoolExecutor.CallerRunsPolicy();
+ }
+ this.shutdownGraceful = shutdownGraceful;
+ this.shutdownWaitTimeMs = shutdownWaitTimeMs;
+ this.executor = new ThreadPoolExecutor(minPoolSize,
+ maxPoolSize,
+ keepAliveTime,
+ TimeUnit.MILLISECONDS,
+ queue,
+ threadFactory,
+ handler);
+ this.logger.info("ThreadPool [{}] initialized.", name);
+ }
+
+ /**
+ * @see org.apache.sling.threads.ThreadPool#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.sling.threads.ThreadPool#execute(java.lang.Runnable)
+ */
+ public void execute(Runnable runnable) {
+ if ( this.executor == null ) {
+ throw new IllegalStateException("Thread pool " + this.name + " is already shutdown.");
+ }
+ if ( runnable != null ) {
+ this.logger.debug("Executing runnable: {},pool={}", runnable, this.name);
+
+ this.executor.execute(runnable);
+ }
+ }
+
+ /**
+ * @see org.apache.sling.threads.ThreadPool#shutdown()
+ */
+ public void shutdown() {
+ if ( this.executor != null ) {
+ if (shutdownGraceful) {
+ this.executor.shutdown();
+ } else {
+ this.executor.shutdownNow();
+ }
+
+ try {
+ if (this.shutdownWaitTimeMs > 0) {
+ if (!this.executor.awaitTermination(this.shutdownWaitTimeMs, TimeUnit.MILLISECONDS)) {
+ logger.warn("running commands have not terminated within "
+ + this.shutdownWaitTimeMs
+ + "ms. Will shut them down by interruption");
+ this.executor.shutdownNow();
+ }
+ }
+ } catch (final InterruptedException ie) {
+ this.logger.error("Cannot shutdown ThreadPool", ie);
+ }
+ this.executor = null;
+ }
+ }
+}
diff --git a/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
new file mode 100644
index 0000000..d122cd3
--- /dev/null
+++ b/src/main/java/org/apache/sling/threads/impl/DefaultThreadPoolManager.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.threads.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.threads.ThreadPool;
+import org.apache.sling.threads.ThreadPoolManager;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The DefaultThreadPoolManager implements the {@link ThreadPoolManager} interface
+ * and is responsible to manage {@link ThreadPool}s.
+ *
+ * @scr.component metatype="false"
+ * @scr.service interface="org.apache.sling.threads.ThreadPoolManager"
+ *
+ * @version $Id$
+ */
+public class DefaultThreadPoolManager implements ThreadPoolManager {
+
+ /** The default queue size */
+ protected final static int DEFAULT_QUEUE_SIZE = -1;
+
+ /** The default maximum pool size */
+ protected final static int DEFAULT_MAX_POOL_SIZE = 5;
+
+ /** The default minimum pool size */
+ protected final static int DEFAULT_MIN_POOL_SIZE = 5;
+
+ /** The default thread priority */
+ protected final static int DEFAULT_THREAD_PRIORITY = Thread.NORM_PRIORITY;
+
+ /** The default daemon mode */
+ protected final static boolean DEFAULT_DAEMON_MODE = false;
+
+ /** The default keep alive time */
+ protected final static long DEFAULT_KEEP_ALIVE_TIME = 60000L;
+
+ /** The default way to shutdown gracefully */
+ protected final static boolean DEFAULT_SHUTDOWN_GRACEFUL = false;
+
+ /** The default shutdown waittime time */
+ protected final static int DEFAULT_SHUTDOWN_WAIT_TIME = -1;
+
+ /** The default shutdown waittime time */
+ protected final static String DEFAULT_THREADPOOL_NAME = "default";
+
+ /** ThreadPool block policy ABORT */
+ protected final static String POLICY_ABORT = "ABORT";
+
+ /** ThreadPool block policy DISCARD */
+ protected final static String POLICY_DISCARD = "DISCARD";
+
+ /** ThreadPool block policy DISCARD-OLDEST */
+ protected final static String POLICY_DISCARD_OLDEST = "DISCARDOLDEST";
+
+ /** ThreadPool block policy RUN */
+ protected final static String POLICY_RUN = "RUN";
+
+ /** The default shutdown waittime time */
+ protected final static String DEFAULT_BLOCK_POLICY = POLICY_RUN;
+
+ /** By default we use the logger for this class. */
+ protected Logger logger = LoggerFactory.getLogger(getClass());
+
+ /** The managed thread pools */
+ protected final Map<String, ThreadPool> pools = new HashMap<String, ThreadPool>();
+
+ /**
+ * Activate this component.
+ */
+ protected void activate(ComponentContext context) throws Exception {
+ this.logger.info("Starting thread pool manager.");
+ final ThreadPool defaultPool = new DefaultThreadPool(
+ DEFAULT_THREADPOOL_NAME,
+ DEFAULT_MIN_POOL_SIZE,
+ DEFAULT_MAX_POOL_SIZE,
+ DEFAULT_QUEUE_SIZE,
+ DEFAULT_KEEP_ALIVE_TIME,
+ DEFAULT_BLOCK_POLICY,
+ DEFAULT_SHUTDOWN_GRACEFUL,
+ DEFAULT_SHUTDOWN_WAIT_TIME,
+ null,
+ DEFAULT_THREAD_PRIORITY,
+ DEFAULT_DAEMON_MODE);
+ this.pools.put(defaultPool.getName(), defaultPool);
+ this.logger.info("Thread pool manager startet with default pool.");
+ }
+
+ /**
+ * Deactivate this component.
+ */
+ protected void deactivate(ComponentContext context) throws Exception {
+ this.logger.info("Stopping thread pool manager.");
+ this.logger.debug("Disposing all thread pools");
+
+ for (ThreadPool pool : this.pools.values()) {
+ this.logger.debug("Shutting down thread pool {}", pool.getName());
+
+ pool.shutdown();
+
+ this.logger.debug("Thread pool " + pool.getName() + " is shut down.");
+ }
+ this.pools.clear();
+ this.logger.info("Thread pool manager stopped.");
+ }
+
+ /**
+ * @see org.apache.sling.threads.ThreadPoolManager#add(org.apache.sling.threads.ThreadPool)
+ */
+ public boolean add(ThreadPool pool) {
+ synchronized ( this.pools ) {
+ if (null != pools.get(pool.getName())) {
+ return false;
+ }
+ pools.put(pool.getName(), pool);
+ }
+ return true;
+ }
+
+ /**
+ * @see org.apache.sling.threads.ThreadPoolManager#get(java.lang.String)
+ */
+ public ThreadPool get(String name) {
+ if ( name == null ) {
+ name = DEFAULT_THREADPOOL_NAME;
+ }
+ synchronized (this.pools) {
+ return this.pools.get(name);
+ }
+ }
+}
diff --git a/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java b/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java
new file mode 100644
index 0000000..5ad586f
--- /dev/null
+++ b/src/main/java/org/apache/sling/threads/impl/ExtendedThreadFactory.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.threads.impl;
+
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * This is an extension to the {@link ThreadFactory}.
+ *
+ * @version $Id$
+ */
+public interface ExtendedThreadFactory
+ extends ThreadFactory {
+
+ /**
+ * Set the daemon mode of created <code>Thread</code>s should have
+ *
+ * @param isDaemon Whether new {@link Thread}s should run as daemons.
+ */
+ void setDaemon( boolean isDaemon );
+
+ /**
+ * Get the daemon mode created <code>Thread</code>s will have
+ *
+ * @return Whether new {@link Thread}s should run as daemons.
+ */
+ boolean isDaemon();
+
+ /**
+ * Set the priority newly created <code>Thread</code>s should have
+ *
+ * @param priority One of {@link Thread#MIN_PRIORITY}, {@link
+ * Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY}
+ */
+ void setPriority( int priority );
+
+ /**
+ * Get the priority newly created <code>Thread</code>s will have
+ *
+ * @return One of {@link Thread#MIN_PRIORITY}, {@link
+ * Thread#NORM_PRIORITY}, {@link Thread#MAX_PRIORITY}
+ */
+ int getPriority();
+
+ /**
+ * Create a new Thread for a {@link Runnable} command
+ *
+ * @param command The <code>Runnable</code>
+ *
+ * @return new <code>Thread</code>
+ */
+ Thread newThread( Runnable command );
+}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.