User Guide
Writing a Java CFX 395
For detailed reference information on each of these interfaces, see the CFML
Reference.
Loading Java CFX classes
Each Java CFX class has its own associated ClassLoader that loads it and any
dependent classes also located in the
classes directory. When Java CFXs are
reloaded after a change, a new
ClassLoader is associated with the freshly loaded
class. This special behavior is similar to the way Java servlets are handled by the Java
Web server and other servlet engines, and is required in order to implement
automatic class reloading.
However, this behavior can cause subtle problems when you are attempting to
perform casts on instances of classes loaded from a different
ClassLoader. The cast
fails even though the objects are apparently of the same type. This is because the
object was created from a different ClassLoader and is therefore technically not the
same type.
To solve this problem, only perform casts to class or interface types that are loaded
using the standard Java class path, that is, classes not located in the
classes
directory. This works because classes loaded from outside the
classes directory are
always loaded using the system
ClassLoader, and therefore, have a consistent
runtime type.
Automatic class reloading
You can determine how the server treats changed Java CFX class files by specifying
the
reload attribute when you use a CFX tag in your CFML page. The following table
describes the allowable values for the
reload attribute:
addRows
Adds a new row to the query.
setData
Sets a data element within the query.
Method Description
Value Description
Auto
Automatically reload Java CFX and dependent classes within the
classes directory whenever the CFX class file changes. Does not
reload if a dependent class file changes but the CFX class file does not
change.
Always
Always reload Java CFX and dependent classes within the classes
directory. Ensures a reload even if a dependent class changes, but the
CFX class file does not change.
Never
Never reload Java CFX classes. Load them once per server lifetime.