Methods Summary |
---|
public void | addTaskListener(TaskListener task)Add the given TaskListener to this Task .
initListener();
listeners.add(task);
|
public java.lang.Object | call()By default, do nothing when a Callable is invoked.
return null;
|
public void | cancelTask(java.lang.String message, java.lang.String code)Cancel the task.
SocketChannel channel = getChannel();
if (code != null) {
SelectorThread.logger().log(Level.WARNING,message);
try {
ByteBuffer byteBuffer = HtmlHelper.getErrorPage(message, code);
OutputWriter.flushChannel(channel,byteBuffer);
} catch (IOException ex){
SelectorThread.logger().log(Level.FINE,"CancelTask failed", ex);
}
}
if ( selectorThread.isEnableNioLogging() ){
SelectorThread.logger().log(Level.INFO, "Cancelling SocketChannel "
+ getChannel());
}
if ( key != null){
selectorThread.cancelKey(key);
} else if ( getSocket() != null ){
try{
getSocket().close();
} catch (IOException ex){
;
}
}
|
public void | clearTaskListeners()Clean all the listeners of this Task
if (listeners == null) return;
listeners.clear();
|
public void | execute()Execute the task based on its Pipeline . If the
Pipeline is null, then execute the task on using the
calling thread.
if (pipeline != null){
pipeline.addTask(this);
} else {
run();
}
|
protected void | fireTaskEvent(TaskEvent event)Notify listeners.
if (listeners == null) return;
for (int i=0; i < listeners.size(); i++){
listeners.get(i).taskEvent(event);
}
|
private java.nio.channels.SocketChannel | getChannel()Return the underlying Channel , independent of the NIO
mode we are using.
if ( key == null ) {
return getSocket().getChannel();
} else {
return (SocketChannel)key.channel();
}
|
public KeepAliveStats | getKeepAliveStats()Gets the KeepAliveStats associated with this task.
return (selectorThread != null?
selectorThread.getKeepAliveStats() : null);
|
public Pipeline | getPipeline()Return the pipeline used by this object.
return pipeline;
|
public boolean | getRecycle()Return true if this Task is recyclable.
return recycle;
|
public org.apache.coyote.RequestGroupInfo | getRequestGroupInfo()Gets the RequestGroupInfo from this task.
return (selectorThread != null?
selectorThread.getRequestGroupInfo() : null);
|
public java.nio.channels.SelectionKey | getSelectionKey()Return the SelectionKey associated with this task.
return key;
|
public SelectorThread | getSelectorThread()Return the SelectorThread
return selectorThread;
|
public java.net.Socket | getSocket()Return the current Socket used by this instance
return null;
|
public java.util.ArrayList | getTaskListeners()Return all listeners of this Task .
initListener();
return listeners;
|
public int | getType()
// ------------------------------------------------------------------//
return type;
|
private void | initListener()
if ( listeners == null ){
listeners = new ArrayList<TaskListener>();
}
|
public boolean | isMonitoringEnabled()Returns true if monitoring has been enabled, false
otherwise.
return (selectorThread != null ?
selectorThread.isMonitoringEnabled() : false);
|
public void | recycle()Recycle internal state.
;
|
public void | removeTaskListener(TaskListener task)Remove the given TaskListener/code> from this
Task .
if (listeners == null) return;
listeners.remove(task);
|
public void | run()Some Pipeline implementation requires a instance of
Runnable instance.
try{
doTask();
} catch (IOException ex){
throw new RuntimeException(ex);
}
|
public void | setPipeline(Pipeline pipeline)Set the pipeline on which Worker Threads will synchronize.
this.pipeline = pipeline;
|
public void | setRecycle(boolean recycle)Declare whether this Task is recyclable. If so, this
Task will be recycled after every invocation of
doTask() .
this.recycle = recycle;
|
public void | setSelectionKey(java.nio.channels.SelectionKey key)Set the SelectionKey
this.key = key;
|
public void | setSelectorThread(SelectorThread selectorThread)Set the SelectorThread object.
this.selectorThread = selectorThread;
|
public void | taskEvent(TaskEvent event)
// Do nothing
|