Skip to Content.
Sympa Menu

notify-dpml - r1069 - in trunk/main/planet/web/server: . src/main/net/dpml/web/server

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1069 - in trunk/main/planet/web/server: . src/main/net/dpml/web/server
  • Date: Sat, 11 Feb 2006 23:42:07 +0100

Author: mcconnell
Date: 2006-02-11 23:42:06 +0100 (Sat, 11 Feb 2006)
New Revision: 1069

Added:

trunk/main/planet/web/server/src/main/net/dpml/web/server/BoundedThreadPool.java
Modified:
trunk/main/planet/web/server/build.xml
trunk/main/planet/web/server/src/main/net/dpml/web/server/Server.java
Log:
add option to override the assigned thread pool

Modified: trunk/main/planet/web/server/build.xml
===================================================================
--- trunk/main/planet/web/server/build.xml 2006-02-11 21:30:34 UTC (rev
1068)
+++ trunk/main/planet/web/server/build.xml 2006-02-11 22:42:06 UTC (rev
1069)
@@ -54,6 +54,12 @@
</services>
</type>

+ <type xmlns="metro" class="net.dpml.web.server.BoundedThreadPool"
threadsafe="true" name="pool">
+ <services>
+ <service class="org.mortbay.thread.ThreadPool"/>
+ </services>
+ </type>
+
<type xmlns="metro" name="server" class="net.dpml.web.server.Server"
threadsafe="true" collection="hard">
<services>
<service class="net.dpml.web.server.Server"/>
@@ -87,6 +93,13 @@
<entry key="extended" value="true"/>
</context>
</component>
+ <component key="threadPool"
+ type="net.dpml.web.server.BoundedThreadPool" collection="hard"
activation="DEMAND">
+ <context>
+ <entry key="min" value="10"/>
+ <entry key="max" value="100"/>
+ </context>
+ </component>
</parts>
</type>


Added:
trunk/main/planet/web/server/src/main/net/dpml/web/server/BoundedThreadPool.java
===================================================================
---
trunk/main/planet/web/server/src/main/net/dpml/web/server/BoundedThreadPool.java
2006-02-11 21:30:34 UTC (rev 1068)
+++
trunk/main/planet/web/server/src/main/net/dpml/web/server/BoundedThreadPool.java
2006-02-11 22:42:06 UTC (rev 1069)
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2006 Stephen McConnell.
+ *
+ * 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.
+ */
+package net.dpml.web.server;
+
+/**
+ * Thread pool implementation.
+ */
+public class BoundedThreadPool extends org.mortbay.thread.BoundedThreadPool
+{
+ /**
+ * HTTP Context handler context defintion.
+ */
+ public interface Context
+ {
+ /**
+ * Get the minimum thread level.
+ *
+ * @return the minimum thread level
+ */
+ int getMin( int min );
+
+ /**
+ * Return maximum thread level.
+ *
+ * @return the maximum thread level
+ */
+ int getMax( int max );
+
+ /**
+ * Return the deamon flag.
+ *
+ * @param flag true if a damon thread
+ * @return the deamon thread policy
+ */
+ boolean getDaemon( boolean flag );
+
+ /**
+ * Get the thread pool name.
+ *
+ * @param name the pool name
+ * @return the name
+ */
+ String getName( String name );
+
+ /**
+ * Get the thread pool priority.
+ *
+ * @param value the thread pool priority
+ * @return the priority
+ */
+ int getPriority( int priority );
+
+ /**
+ * Get the maximum idle time.
+ *
+ * @param the default maximum idle time
+ * @return the maximum idele time in milliseconds
+ */
+ int getIdle( int idle );
+
+ }
+
+ public BoundedThreadPool( Context context ) throws Exception
+ {
+ super();
+
+ int min = context.getMin( 1 );
+ int max = context.getMax( 255 );
+ boolean daemon = context.getDaemon( true );
+ String name = context.getName( "pool" );
+ int priority = context.getPriority( Thread.NORM_PRIORITY );
+ int idle = context.getIdle( 10000 );
+
+ setMinThreads( min );
+ setMaxThreads( max );
+ setDaemon( daemon );
+ setThreadsPriority( priority );
+ setName( name );
+ }
+}

Modified:
trunk/main/planet/web/server/src/main/net/dpml/web/server/Server.java
===================================================================
--- trunk/main/planet/web/server/src/main/net/dpml/web/server/Server.java
2006-02-11 21:30:34 UTC (rev 1068)
+++ trunk/main/planet/web/server/src/main/net/dpml/web/server/Server.java
2006-02-11 22:42:06 UTC (rev 1069)
@@ -62,11 +62,31 @@
* @return the resolved request logger
*/
RequestLog getRequestLog( RequestLog logger );
+
+ /**
+ * Get the assigned thread pool. If no thread pool is
+ * assigned by the deployment scenario a default pool
+ * will be established.
+ *
+ * @param pool the default value
+ * @return the resolved thread pool
+ */
+ ThreadPool getThreadPool( ThreadPool pool );
}

public interface Parts extends PartsManager
{
+ /**
+ * Return the default request log.
+ * @return the default request log.
+ */
RequestLog getRequestLog();
+
+ /**
+ * Return the default thread pool.
+ * @return the default thread pool.
+ */
+ ThreadPool getThreadPool();
}

private final Logger m_logger;
@@ -97,6 +117,20 @@
}

//
+ // setup the thread pool
+ //
+
+ ThreadPool pool = context.getThreadPool( null );
+ if( null != pool )
+ {
+ super.setThreadPool( pool );
+ }
+ else
+ {
+ super.setThreadPool( parts.getThreadPool() );
+ }
+
+ //
// setup the request log
//

@@ -110,7 +144,9 @@
super.setRequestLog( parts.getRequestLog() );
}

+ //
// add realms and context handlers
+ //

addUserRealms( parts );
addContextHandlers( parts );




  • r1069 - in trunk/main/planet/web/server: . src/main/net/dpml/web/server, mcconnell at BerliOS, 02/11/2006

Archive powered by MHonArc 2.6.24.

Top of Page