<classes>
New in Fusebox 4.1, the classes element allows you to map aliases to component objects. Generally, these will be ColdFusion component (CFC) files. However, any type of object that can be created with the createObject function is valid here, including Java classes, COM, CORBA, and web services.
Within the classes tag set you specify individual objects with the class tag.
<class>
The class tag has attributes for alias, classpath, type, and constructor. Let's look at each of these attributes in more detail.
Attribute | Description |
alias | Allows you to specify the alias for the class that you will use later from your circuit.xml files via the instantiate and invoke verbs. |
type | Defines the type of object for the class. Valid values are "component" (for CFCs), "java" for Java classes, "webservice" for web services, "com" for COM objects, and "corba" for CORBA objects. |
classpath | Defines the path to the class. When used with CFCs, this path is the full dot-separated path to the CFC either from the web root, from a ColdFusion mapping, or a custom tag path. When used with Java classes, this is the Java class path. When aliasing a web service, this is the URL to use to call the WSDL file for the web service. |
constructor | Specifies the method within the object that defines its constructor. A constructor is a method that is called at the time the object is instantiated, usually to set up internal properties and get the object into a state where it can be used effectively. This attribute is optional. Note that even if your CFC has an init() method, it will not be called unless you specify the constructor attribute for the class. If you're defining a reference to a Java class, you won't need to specify a constructor. ColdFusion will automatically call the class's constructor just before the first method call to that object - or when you explicitly call init() with or without arguments. That's not the case with ColdFusion components, so for CFCs you must specify a constructor if you want one to be called. |
Here are some examples of class elements:
type="component" constructor="init" />
<class alias="Address" classpath="myApp.com.Address
type="java" constructor="init" />
<class alias="xMethodsWebService"
classpath="http://www.xmethods.net/interfaces/query.wsdl"
type="webservice" />
It's a good common practice to use init as the method name of a constructor.