Most Read This Week
The Truth About Coldfusion and DCOM
The Truth About Coldfusion and DCOM
Jan. 27, 2000 12:00 AM
Extending ColdFusion to incorporate Microsoft's Distributed Component Object Model (DCOM) is a powerful way to expand the capabilities of the application server on the Microsoft platform.
We'll view DCOM through ColdFusion and cover some of the features and pitfalls of using these technologies together. The examples here are made in conjunction with Visual Basic's support of the distributed interface. By the end of this article you should be able to start planning the framework for your DCOM-enabled ColdFusion applications.
DCOM is a derivative of COM, Microsoft's interface definition standard. COM provides a medium for developers to create interoperable interfaces and a means to connect to any COM-compliant service, regardless of implementation language or process space. DCOM extends COM functionality by providing distributed services such as transport, security and directory services that allow component interfaces to be accessed anywhere across a network.
How ColdFusion Accesses DCOM Services
<CFOBJECT type="COM" class="" action="create" name="xxx"> Keep in mind that COM components are designated with a unique ID, known as their GUID, each time they're compiled. Components are registered when the GUID is incorporated into the Windows registry. The same GUID version must be registered on the calling and receiving machine for the DCOM services to be properly located.
Building DCOM Components with Visual Basic
When the time comes to deploy your compiled DCOM object, it's recommended you use Microsoft's Package & Deployment Wizard to create an installation program for the object. This wizard provides a simple means for placing and registering your new DCOM component. Remember to install the new component on any client and server machines that will be using this object. The last step in setting up your DCOM component is to configure its registered settings through the utility DCOMCNFG.exe provided with Microsoft's Visual Studio 6.
In using Microsoft's DCOM configuration utility (DCOMCNFG.EXE), configuring your newly registered DCOM objects is as simple as a few clicks of the mouse. Launch the "dcomcnfg" utility through your Windows command prompt and find your registered object in the list of registered components. Select the new component and click the Properties button for it. The utility must be used to configure the client and server machines where the component is installed. The following are recommendations for how to initially set your DCOM configurations on each machine.
On the client machine:
On the server machine:
Passing Variables from ColdFusion to DCOM
In DCOM components, functions accept two types of variables: primitive and object references. Primitive data types refer to variables that are string, integers, booleans and real number. When passing primitive data types to a COM interface, that interface must be defined to accept the value with the "ByVal" attribute. When passing nonprimitive variables or object variables through COM, the reference of the variable is passed and no additional attribute needs to be set. For example, the following code snippet shows how to declare a Visual Basic function that's able to accept the Integer primitive data type.
Function TestFunction(By Val Parameter1 As Integer) ... End Function
Managing DCOM Objects in Multiuser Scenarios
In ColdFusion you can implement a resource pool manager by following this example: enable application-level variables through the Application.cfm file, then add the following two application variables.
These variables are used to hold the resources and define how many are to be pooled. The maximum number of resources should be defined in terms of how resource-intensive the components are and how robust the server is that will be running them.
Listing 1 is the algorithm for actually implementing an example pooling mechanism. As you'll notice, this algorithm assumes that the DCOM component is defined with the "isAvailable" and "setAvailability" functions. Use this snippet to create a custom tag to manage your resource pools.
The algorithm will loop through the pool until a resource becomes available. It's important that requesters for pool resources set them to available once they're done. The resource pool paradigm is good for handling resources that are used quickly and then returned. It doesn't work well when they're used for an extended period of time, in which case circumstances of deadlock can occur. The resource pool also solves any concurrency issues because it ensures that no more than one user request accesses any given resource at the same time.
Using ColdFusion and DCOM together opens new windows of possibility for your Web applications. However, the many intricacies involved can create hours of trial and error. With this framework of knowledge, we hope that using DCOM can be a viable and painless solution for expanding your Web application.
Reader Feedback: Page 1 of 1
Subscribe to the World's Most Powerful Newsletters
Today's Top Reads