KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > ara > TaskWrapper


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.ara;
24
25 import com.sun.enterprise.web.connector.grizzly.KeepAliveStats;
26 import com.sun.enterprise.web.connector.grizzly.SelectorThread;
27 import com.sun.enterprise.web.connector.grizzly.Task;
28 import com.sun.enterprise.web.connector.grizzly.TaskListener;
29
30 import org.apache.coyote.RequestGroupInfo;
31
32 /**
33  * Wrap an instance of a <code>Task</code>
34  *
35  * @author Jeanfrancois Arcand
36  */

37 public abstract class TaskWrapper implements Task {
38        
39     /**
40      * The wrapped <code>Task</code> instance.
41      */

42     protected Task wrappedTask;
43     
44        
45     public TaskWrapper(){}
46
47     
48     // ---------------------------------------------------- Abstract method --//
49

50     
51     /**
52      * Execute the <code>Task</code>
53      */

54     public abstract void doTask() throws java.io.IOException JavaDoc;
55    
56     
57     /**
58      * Wrap an instance of a <code>Task</code>
59      */

60     public abstract Task wrap(Task task);
61     
62     
63     /**
64      * Execute the <code>Task<</code> using this thread or a <code>Pipeline</code>.
65      */

66     public abstract void execute();
67
68     
69     /**
70      * Execute the <code>Task<</code> using this thread or a <code>Pipeline</code>.
71      */

72     public abstract void run();
73       
74     
75     /**
76      * Return the wrapped <code>Task</code>
77      */

78     public Task getWrappedTask(){
79         return wrappedTask;
80     }
81     // -------------------------------------------------- Wrapped methods ---//
82

83     
84     public void addTaskListener(TaskListener task) {
85         wrappedTask.addTaskListener(task);
86     }
87
88     public Object JavaDoc call() throws Exception JavaDoc{
89         return wrappedTask.call();
90     }
91
92     public void cancelTask(String JavaDoc message, String JavaDoc httpCode) {
93         wrappedTask.cancelTask(message,httpCode);
94     }
95
96     public void clearTaskListeners() {
97         wrappedTask.clearTaskListeners();
98     }
99
100
101     public KeepAliveStats getKeepAliveStats() {
102         return wrappedTask.getKeepAliveStats();
103     }
104
105     public boolean getRecycle() {
106         return wrappedTask.getRecycle();
107     }
108
109     public RequestGroupInfo getRequestGroupInfo() {
110         return wrappedTask.getRequestGroupInfo();
111     }
112
113     public java.nio.channels.SelectionKey JavaDoc getSelectionKey() {
114         return wrappedTask.getSelectionKey();
115     }
116
117     public SelectorThread getSelectorThread() {
118         return wrappedTask.getSelectorThread();
119     }
120
121     public java.util.ArrayList JavaDoc getTaskListeners() {
122         return wrappedTask.getTaskListeners();
123     }
124
125     public int getType() {
126         return wrappedTask.getType();
127     }
128
129     public boolean isMonitoringEnabled() {
130         return wrappedTask.isMonitoringEnabled();
131     }
132
133     public void recycle() {
134         wrappedTask.recycle();
135     }
136
137     public void removeTaskListener(TaskListener task) {
138         wrappedTask.removeTaskListener(task);
139     }
140
141
142     public void setRecycle(boolean recycle) {
143         wrappedTask.setRecycle(recycle);
144     }
145
146     public void setSelectionKey(java.nio.channels.SelectionKey JavaDoc key) {
147         wrappedTask.setSelectionKey(key);
148     }
149
150     public void setSelectorThread(SelectorThread selectorThread) {
151         wrappedTask.setSelectorThread(selectorThread);
152     }
153     
154 }
155
Popular Tags