Approaches to Debugging Java CFXsJava CFXs are not standalone applications that run in their own process like typical Java applications. Rather, they are created and invoked from an existing process - ColdFusion Server. This makes debugging Java CFXs more difficult because you cannot use an interactive debugger to debug Java classes that have been loaded by another process. To overcome this limitation, you can use one of two techniques:
Outputting debug informationBefore using interactive debuggers became the norm, programmers typically debugged their programs by inserting output statements in their programs to indicate information such as variable values and control paths taken. Often, when a new platform emerges, this technique comes back into vogue while programmers wait for more sophisticated debugging technology to develop for the platform.
If you need to debug a Java CFX while running against a live production server, this is the technique you must use. In addition to outputting debug text using the
To determine whether a CFX is invoked with the Using the debugging classes
To develop and debug Java CFXs in isolation from the ColdFusion Server, you use three special debugging classes that are included in the
To use the debugging classes:
After you implement a Debugging classes exampleThe following example demonstrates the use of the debugging classes: import java.util.Hashtable ; import com.allaire.cfx.* ;
public class OutputQuery implements CustomTag
{
// debugger testbed for OutputQuery
public static void main(String[] argv)
{
try
{
// initialize attributes
Hashtable attributes = new Hashtable() ;
attributes.put( "HEADER", "Yes" ) ;
attributes.put( "BORDER", "3" ) ;
// initialize query
String[] columns =
{ "FIRSTNAME", "LASTNAME", "TITLE" } ;
String[][] data = {
{ "Stephen", "Cheng", "Vice President" },
{ "Joe", "Berrey", "Intern" },
{ "Adam", "Lipinski", "Director" },
{ "Lynne", "Teague", "Developer" } } ;
DebugQuery query =
new DebugQuery( "Employees", columns, data ) ;
// create tag, process debug request, and print results
OutputQuery tag = new OutputQuery() ;
DebugRequest request = new DebugRequest( attributes, query ) ;
DebugResponse response = new DebugResponse() ;
tag.processRequest( request, response ) ;
response.printResults() ;
}
catch( Throwable e )
{
e.printStackTrace() ;
}
}
public void processRequest( Request request ) throws Exception
{
// ...code for processing the request...
}
}
|