The CreateObject
function can create a Java object, and, by extension, an EJB object.
CreateObject(type, class)
Parameter | Description |
---|---|
type |
Type of object to create.
|
class |
A Java class name |
Any Java class available in the class path that is specified in the ColdFusion Administrator can be loaded and used from ColdFusion with the CreateObject
function.
To access Java methods and fields:
CreateObject
function or the cfobject
tag to load the class.
init
method, with appropriate arguments, to call an instance of the class. For example:<cfset ret = myObj.init(arg1, arg2)>
Calling a public method on the object without first calling the "init" method invokes a static method. Arguments and return values can be any Java type (simple, array, object). If strings are passed as arguments, ColdFusion does the conversions; if strings are received as return values, ColdFusion does no conversion.
Overloaded methods are supported if the number of arguments is different. Future enhancements will let you use cast functions that allow method signatures to be built more accurately.