770
Chapter 34: Integrating COM and CORBA Objects in CFML Applications
Ensuring correct threading
Improper threading can cause serious problems when using a COM object in ColdFusion. Make
sure that the object is
thread-safe
. An object is thread-safe if it can be called from many
programming threads simultaneously, without causing errors.
Visual Basic ActiveX DLLs are typically not thread-safe. If you use such a DLL in ColdFusion,
you can make it thread-safe by using the OLE/COM Object Viewer to change the object’s
threading model to the Apartment model.
If you are planning to store a reference to the COM object in the Application, Session, or Server
scope, do not use the Apartment threading model. This threading model is intended to service
only a single request. If your application requires you to store the object in any of these scopes,
keep the object in the Both threading model, and lock all code that accesses the object, as
described in
Chapter 15, “Locking code with cflock,” on page 333
.
To change the threading model of a COM Object:
1
Open the OLE/COM Object Viewer.
2
Select All Objects under Object Classes in the left pane.
3
Locate your COM object. The left pane lists these by name.
4
Select your object.
5
Select the Implementation tab in the right pane.
6
Select the Inproc Server tab, below the App ID field.
7
Select the Threading Model drop down menu and select Apartment or Both, as appropriate.
Using input and output arguments
COM object method in arguments are passed by value. The COM object gets a copy of the
variable value, so you can specify a ColdFusion variable without surrounding it with quotation
marks.
COM object out method arguments are passed by reference. The COM object modifies the
contents of the variable on the calling page, so the calling page can use the resulting value. To pass
a variable by reference, surround the name of an existing ColdFusion variable with quotation
marks. If the argument is a numeric type, assign the variable a valid number before you make the
call. For example:
<cfset inStringArg="Hello Object">
<cfset outNumericArg=0>
<cfset result=myCOMObject.calculate(inStringArg, "outNumericArg")>
The string "Hello Object" is passed to the object's calculate method as an input argument. The
value of outNumericArg is set by the method to a numeric value.
Summary of Contents for COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Page 1: ...Developing ColdFusion MX Applications...
Page 22: ...22 Contents...
Page 38: ......
Page 52: ...52 Chapter 2 Elements of CFML...
Page 162: ......
Page 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Page 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Page 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Page 266: ......
Page 314: ...314 Chapter 14 Handling Errors...
Page 344: ...344 Chapter 15 Using Persistent Data and Locking...
Page 349: ...About user security 349...
Page 357: ...Security scenarios 357...
Page 370: ...370 Chapter 16 Securing Applications...
Page 388: ...388 Chapter 17 Developing Globalized Applications...
Page 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Page 410: ......
Page 426: ...426 Chapter 19 Introduction to Databases and SQL...
Page 476: ...476 Chapter 22 Using Query of Queries...
Page 534: ...534 Chapter 24 Building a Search Interface...
Page 556: ...556 Chapter 25 Using Verity Search Expressions...
Page 558: ......
Page 582: ...582 Chapter 26 Retrieving and Formatting Data...
Page 668: ......
Page 734: ...734 Chapter 32 Using Web Services...
Page 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Page 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Page 788: ......