001: //========================================================================
002: // Parts Copyright 2006 Mort Bay Consulting Pty. Ltd.
003: //------------------------------------------------------------------------
004: // Licensed under the Apache License, Version 2.0 (the "License");
005: // you may not use this file except in compliance with the License.
006: // You may obtain a copy of the License at
007: // http://www.apache.org/licenses/LICENSE-2.0
008: // Unless required by applicable law or agreed to in writing, software
009: // distributed under the License is distributed on an "AS IS" BASIS,
010: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011: // See the License for the specific language governing permissions and
012: // limitations under the License.
013: //========================================================================
014:
015: package org.mortbay.jetty.grizzly;
016:
017: import com.sun.enterprise.web.connector.grizzly.Pipeline;
018: import com.sun.enterprise.web.connector.grizzly.PipelineStatistic;
019: import com.sun.enterprise.web.connector.grizzly.Task;
020: import org.mortbay.thread.BoundedThreadPool;
021: import org.mortbay.thread.ThreadPool;
022:
023: /**
024: * Wrapper around Jetty's BoundedThreadPool Pool.
025: * TODO: Support ThreadPool directly.
026: *
027: * @author Jeanfrancois Arcand
028: */
029: public class JettyPipeline implements Pipeline {
030: private PipelineStatistic pipelineStat;
031:
032: private BoundedThreadPool _threadPool;
033:
034: public JettyPipeline() {
035: }
036:
037: public void setThreadPool(BoundedThreadPool threadPool) {
038: _threadPool = threadPool;
039: }
040:
041: public void addTask(Task task) {
042: _threadPool.dispatch(task);
043: }
044:
045: public Task getTask() {
046: // Not used.
047: return null;
048: }
049:
050: public int getWaitingThread() {
051: return _threadPool.getIdleThreads();
052: }
053:
054: public int getMaxThreads() {
055: return _threadPool.getMaxThreads();
056: }
057:
058: public int getCurrentThreadCount() {
059: return _threadPool.getThreads();
060: }
061:
062: public int getCurrentThreadsBusy() {
063: return getMaxThreads() - getWaitingThread();
064: }
065:
066: public void initPipeline() {
067: }
068:
069: public String getName() {
070: return "JettyPipeline";
071: }
072:
073: public void startPipeline() {
074: }
075:
076: public void stopPipeline() {
077: }
078:
079: public void setPriority(int i) {
080: }
081:
082: public void setMaxThreads(int i) {
083: }
084:
085: public void setMinThreads(int i) {
086: }
087:
088: public void setPort(int i) {
089: }
090:
091: public void setName(String string) {
092: }
093:
094: public void setQueueSizeInBytes(int i) {
095: }
096:
097: public void setThreadsIncrement(int i) {
098: }
099:
100: public void setThreadsTimeout(int i) {
101: }
102:
103: public void setPipelineStatistic(PipelineStatistic pipelineStatistic) {
104: }
105:
106: public PipelineStatistic getPipelineStatistic() {
107: return pipelineStat;
108: }
109:
110: public int size() {
111: return _threadPool.getThreads();
112: }
113:
114: public int getMaxSpareThreads() {
115: return -1;
116: }
117:
118: public int getMinSpareThreads() {
119: return -1;
120: }
121:
122: public void setMinSpareThreads(int i) {
123: }
124:
125: public boolean interruptThread(long l) {
126: return false;
127: }
128:
129: }
|