com.cometway.util
Class KMethod

java.lang.Object
  extended by com.cometway.util.KMethod
Direct Known Subclasses:
ConnectionKMethod, ExecuteCommand, HTTPCheckKMethod, InputStreamReaderKMethod

public class KMethod
extends java.lang.Object

KMethod is a wrapper for java.lang.reflect.Method. This object allows Threads to easily pass code to be executed (a Method or a Runnable) around with each other. PooledThreads execute KMethods in order to maximize their efficiency by quickly determining what Threads will execute the code at Runtime. KMethods can also wrap classes that implement Runnable. Special instances of execution which may require state information or other specific runtime information can extend this class so that PooledThreads and ThreadPools can be utilized.

See Also:
ThreadPool, PooledThread

Field Summary
protected  java.lang.Object[] args
           
protected  java.lang.String debugName
           
protected  java.lang.reflect.Method method
           
protected  java.lang.Object obj
           
protected  boolean print_errors
           
protected  java.lang.Runnable run
           
protected  boolean verbose
           
 
Constructor Summary
KMethod()
          Creates an empty KMethod.
KMethod(java.lang.reflect.Method m, java.lang.Object obj, java.lang.Object[] args)
          Create a KMethod around a java.lang.reflect.Method.
KMethod(java.lang.Runnable run)
          Create a KMethod around a Runnable.
 
Method Summary
protected  void error(java.lang.String s)
           
protected  void error(java.lang.String s, java.lang.Exception e)
           
 void execute()
          Calling this will execute this KMethod, which executes what the KMethod wraps.
protected  void print(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debugName

protected java.lang.String debugName

print_errors

protected boolean print_errors

verbose

protected boolean verbose

obj

protected java.lang.Object obj

method

protected java.lang.reflect.Method method

args

protected java.lang.Object[] args

run

protected java.lang.Runnable run
Constructor Detail

KMethod

public KMethod(java.lang.Runnable run)
Create a KMethod around a Runnable. Runnable.run() will be the Method executed.

Parameters:
run - This is the Runnable which will be executed.

KMethod

public KMethod(java.lang.reflect.Method m,
               java.lang.Object obj,
               java.lang.Object[] args)
Create a KMethod around a java.lang.reflect.Method. When this KMethod is executed this Method will be invoked.

Parameters:
m - This is the java.lang.reflect.Method to invoke.
obj - This is passed to the Method when invoked.
args - These are the arguments to pass to the Method when invoked.

KMethod

public KMethod()
Creates an empty KMethod.

Method Detail

execute

public void execute()
Calling this will execute this KMethod, which executes what the KMethod wraps.


error

protected void error(java.lang.String s,
                     java.lang.Exception e)

error

protected void error(java.lang.String s)

print

protected void print(java.lang.String s)