KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > connector > grizzly > Task


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.web.connector.grizzly;
24
25 import java.io.IOException JavaDoc;
26 import java.nio.channels.SelectionKey JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.concurrent.Callable JavaDoc;
29 import org.apache.coyote.RequestGroupInfo;
30
31 /**
32  * Wrapper object used by the WorkerThread
33  *
34  * @author Jean-Francois Arcand
35  */

36 public interface Task extends Runnable JavaDoc, Callable JavaDoc{
37       
38     // Simple flag to avoid calling instanceof
39
public static int ACCEPT_TASK = 0;
40     public static int READ_TASK = 1;
41     public static int PROCESSOR_TASK = 2;
42
43     /**
44      * Return this <code>Tash</code> type.
45      */

46     public int getType();
47     
48     /**
49      * Execute the task.
50      */

51     public void doTask() throws IOException JavaDoc;
52
53
54     /**
55      * Cancel the task.
56      */

57     public void cancelTask(String JavaDoc message, String JavaDoc httpCode);
58
59
60     /**
61      * Set the <code>SelectionKey</code>
62      */

63     public void setSelectionKey(SelectionKey JavaDoc key);
64     
65     
66     /**
67      * Return the <code>SelectionKey</code> associated with this tasks.
68      */

69     public SelectionKey JavaDoc getSelectionKey();
70
71     
72     /**
73      * Set the <code>SelectorThread</code> used by this task.
74      */

75     public void setSelectorThread(SelectorThread selectorThread);
76     
77     
78     /**
79      * Returns the <code>SelectorThread</code> used by this task.
80      */

81     public SelectorThread getSelectorThread();
82
83
84     /**
85      * Gets the <code>RequestGroupInfo</code> from this task.
86      */

87     public RequestGroupInfo getRequestGroupInfo();
88
89
90     /**
91      * Returns <code>true</code> if monitoring has been enabled, false
92      * otherwise.
93      */

94     public boolean isMonitoringEnabled();
95
96
97     /**
98      * Gets the <code>KeepAliveStats</code> associated with this task.
99      */

100     public KeepAliveStats getKeepAliveStats();
101
102     
103     /**
104      * Add a <code>Task</code> to this class.
105      */

106     public void addTaskListener(TaskListener task);
107
108     
109     /**
110      * Remove a <code>Task</code> to this class.
111      */

112     public void removeTaskListener(TaskListener task);
113     
114     
115     /**
116      * Execute this task by using the associated <code>Pipeline</code>.
117      * If the <code>Pipeline</code> is null, the task's <code>doTask()</code>
118      * method will be invoked.
119      */

120     public void execute();
121     
122     
123     /**
124      * Recycle this task.
125      */

126     public void recycle();
127     
128     
129     /**
130      * Return the <code>ArrauList</code> containing the listeners.
131      */

132     public ArrayList JavaDoc getTaskListeners();
133
134
135     /**
136      * Remove all listeners
137      */

138     public void clearTaskListeners();
139
140
141     /**
142      * Recycle the Task after every doTask invokation.
143      */

144     public void setRecycle(boolean recycle);
145
146
147     /**
148      * Return <code>true</code> if this <code>Task</code> will be recycled.
149      */

150     public boolean getRecycle();
151
152    
153 }
154
Popular Tags