User Guide
Calling Java Objects 385
To disable automatic class loading, put all classes in the normal Java class path.
Classes located on the Java class path are loaded once per server lifetime and can
only be reloaded by stopping and restarting ColdFusion Server.
A more complex Java example
The following code provides a more complete example of using Java with cfobject.
The Example class manipulates integer, float, array, Boolean, and Example object
types.
The Example class
The following Java code defines the Example class. The Java class Example has one
public integer member,
mPublicInt. Its constructor initializes mPublicInt to 0 or an
integer argument. The class has the following public methods:
public class Example {
public int mPublicInt;
public Example() {
mPublicInt = 0;
}
public Example(int IntVal) {
mPublicInt = IntVal;
}
public String ReverseString(String s) {
StringBuffer buffer = new StringBuffer(s);
return new String(buffer.reverse());
}
public String[] ReverseStringArray(String [] arr) {
Method Description
ReverseString Reverses the order of a string.
ReverseStringArray Reverses the order of elements in an array of strings.
Add Overloaded: Adds and returns two integers or floats or
adds the
mPublicInt members of two Example class
objects and returns an Example class object.
SumArray Returns the sum of the elements in an integer array.
SumObjArray Adds the values of the
mPublicInt members of an array of
Example class objects and returns an Example class
object.
ReverseArray Reverses the order of an array of integers.
Flip Switches a boolean value.