|
ColdFusion 9.0 Resources |
Accessing .NET assembliesColdFusion provides two methods for accessing .NET assemblies:
For both methods, install the ColdFusion .NET extension and run the ColdFusion .NET service on the system that hosts the assemblies. You need not install the extension or run the service on a ColdFusion system that accesses only remote assemblies. For information on installing the ColdFusion .NET extension, see Installing ColdFusion guide. Accessing local assembliesFor local access, ColdFusion automatically generates and uses proxies for the required .NET assemblies when you first use the cfobject tag or CreateObject function. ColdFusion caches the proxies for future use, so it does not generate assembly proxies each time. Usually when you are accessing local .NET assemblies, you do not have to override the default communication configuration settings. Sometimes you could have to specify these settings, however. If other software on your system uses the default 6086 port, for example, change the port number specification in the jnbridge\DotNetSide.exe.config file, and specify the changed port number in your cfobject tag or CreateObject tag. For information on changing the port number specification, see Configuring the .NET-side system, To use the local access method, use the cfobject tag or CreateObject function to create and access the proxy. You can use the resulting ColdFusion object to construct the .NET object, call the .NET object’s methods, and access its fields. For detailed information on using .NET classes, see Using .NET classes. Accessing remote assembliesThe remote access technique accesses .NET assemblies by using TCP or HTTP to communicate with a .NET-side agent on a remote system. You create proxy instances and call assembly methods as you do in the Local access method, but first configure the remote .NET-side agent and, in most cases, the proxy classes that represent the remote .NET classes. Configure remote .NET access
Generating the Java proxy classesThe Java proxy generation code requires direct access to the .NET assemblies to generate the proxy classes. Therefore, if the system that runs your ColdFusion application does not have the assemblies installed, run a tool on the .NET-side system to create the Java proxies. ColdFusion installs two proxy generation programs, jnbproxyGui.exe and jnbproxy.exe in the jnbridge directory when you install the .NET services. The jnbproxyGui.exe program is a Windows user interface application, and the jnbproxy.exe program is a command line application. Both programs have identical capabilities. Note: If the system running the ColdFusion application
has the assemblies installed, but must access remote versions of
the assemblies (for example, because of configuration differences),
you need not manually generate the proxy classes, and you can skip
this step. Instead, specify the paths to the local .exe or .dll
files in the assembly attribute of the cfobject tag
(or CreateObject function) and specify the remote
server in the server attribute. Configure the remote
system for access, however.
On a ColdFusion system, the jnbproxyGui and jnbproxy programs are located in the cfroot\jnbridge directory. When you use the stand-alone installer, the programs are located in the installDir\jnbridge directory. This document provides the basic information necessary to generate a proxy JAR file using the jnbproxyGui tool. Additional information is available in the following locations:
Note: The JNBridge documentation includes information
on features that are not supported in ColdFusion. ColdFusion, for
example, does not support access from .NET assemblies to ColdFusion
or memory-only communication.
Generate and install a proxy JAR
Supporting classesJNBProxy can generate proxies not only for the .NET classes that are explicitly listed, but also for supporting classes. A supporting class for a given .NET class is any class that could be needed as a direct or indirect result of using that .NET class. For a given .NET class, supporting classes include all of the following:
Unlike Java, where supporting classes include exceptions that methods throw, .NET supporting classes don’t include thrown exceptions, because they are not declared in advance. The number of supporting classes depends on the classes explicitly listed, but it often can be 200-250 classes. Usually you generate all supporting classes. However, to save time or space, you can generate only those classes explicitly specified, without supporting classes. If a proxy for a supporting class has not been generated, and a proxy for such a class is later needed when the proxies are used, the proxy for the nearest superclass to the required class is used instead. If that proxy hasn’t been generated, the proxy for the superclass of that superclass is used if it has been generated, and so forth, until the proxy for System.Object (which is always generated) is encountered. Thus, even with an incomplete set of proxies, code executes, although functionality and other information could be lost. In the jnbproxyGui tool, when you click the Add button, the list includes only the explicitly listed classes. When you click the Add+ button, the list also includes the supporting classes. In the jnbproxy command line program, the default command generates proxies for the supporting classes; use the /ns option to override this default. Configuring the .NET-side systemTo configure the .NET-side system, you edit the jnbridge\JNBDotNetSide.exe.config configuration file in the following ways:
Edit the configuration file
The following example is a bare-bones JNBDotNetSide.exe.config file that specifies a .NET-side TCP server configuration. The server communicates by using TCP binary mode and listens on port 6086. Java clients can access \\x <?xml version="1.0" encoding="utf-8"?>
<configuration>
<sectionGroup name="jnbridge">
<section name="dotNetToJavaConfig"
type="System.Configuration.SingleTagSectionHandler"/>
<section name="javaToDotNetConfig"
type="System.Configuration.SingleTagSectionHandler"/>
<section name="tcpNoDelay"
type="System.Configuration.SingleTagSectionHandler"/>
<section name="javaSideDeclarations"
type="System.Configuration.NameValueSectionHandler"/>
<section name="assemblyList"
type="com.jnbridge.jnbcore.AssemblyListHandler, JNBShare"/>
</sectionGroup>
<jnbridge>
<javaToDotNetConfig scheme="jtcp" port="6086"/>
<assemblyList>
\\x
<assembly file="System.Windows.Forms, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblyList>
</jnbridge>
</configuration>
|