
1180
DEVELOPING
COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
Las
t
upda
te
d 8/5/2010
Where
cf_root
is the directory where ColdFusion is installed and
directoryName
is the name of the directory that
contains the class files. For the OutlookXP example, enter the following line:
jar -uvf C:\CFusion\lib\msapps.jar outlookXP\*.class
7
Update the
cf_root
/lib/neo-comobjmap.xml file by appending your object definition to the list. The object
definition consists of the following lines:
<var name="progID">
<string>PackageName.mainClass</string>
</var>
Use the following values in these lines:
ProgID
The COM object ProgID, as displayed in the OLE/COM object viewer.
PackageName
The package name you specified in step 3c.
mainClass
The main class of the COM object. The main class contains the methods you invoke. For many
Microsoft applications, this class is Application. In general, the largest class file created in step 4 is the main class.
For example, to add outlookXP to neo-comobjmap.xml, add the lines in bold text above the
</struct>
end tag:
<var name="access.application.9">
<string>coldfusion.runtime.com.com2java.access2k.Application</string>
</var>
<var name="outlook.application.10">
<string>outlookXP.Application</string>
</var>
</struct>
In this example,
outlook.application.10
is the ProgID of the Outlook COM object,
outlookXP
is the package name
you specified in step 3c, and
Application
is the main class of the COM object.
8
Restart the ColdFusion server: Open the Services control panel, select ColdFusion application server, and click
Start.
9
After you have installed the stubs, you can delete the directory you created in step 2., including all its contents.
Using the Application Scope to improve COM performance
The Java call to create a COM object instance can take substantial time. As a result, creating COM objects in
ColdFusion can be substantially slower than in ColdFusion 5. For example, on some systems, creating a Microsoft
Word application object could take over one second using ColdFusion, while on the same system, the overhead of
creating the Word object could be about 200 milliseconds.
Therefore, in ColdFusion, you can improve COM performance substantially if you can share a single COM object in
the Application scope among all pages.
Use this technique only if the following are true:
•
The COM object need not be created for every request or session. (For session-specific objects, consider using the
technique described here with the Session scope in place of the Application scope.)
•
The COM object is designed for sharing.
Because the object can be accessed from multiple pages and sessions simultaneously, also consider the following
threading and locking issues:
•
For best performance, make the object multi-threaded. Otherwise, only one request can access the object at a time.