ColdFusion .NET Integration

happylandcannedΛογισμικό & κατασκευή λογ/κού

2 Ιουλ 2012 (πριν από 5 χρόνια και 1 μήνα)

478 εμφανίσεις

1
2006 Adobe Systems Incorporated. All Rights Reserved.
1
ColdFusion .NET
Integration
Rupesh Kumar
Computer Scientist
,
ColdFusion Team
Adobe
2006 Adobe Systems Incorporated. All Rights Reserved.
2
ƒ
Introduction
ƒ
Brief .NET Introduction
ƒ
Interoperability Strategies for .NET
ƒ
.NET Integration Features
ƒ
Syntax
ƒ
Demo
ƒ
Nuts and Bolts
ƒ
Deployment scenarios
ƒ
Limitation
ƒ
Q&A
Agenda
2
2006 Adobe Systems Incorporated. All Rights Reserved.
3
ƒ
Why .NET integration ??
ƒ
Leverage some functionality available in .NET
ƒ
Leverage Microsoft products like Word, Excel, Outlook,
Exchange server etc.
ƒ
Existing investments.
ƒ
Existing components and services
ƒ
Acquired components and services
Introduction
2006 Adobe Systems Incorporated. All Rights Reserved.
4
ƒ
Makes Hard Stuff Easy !!!
ƒ
Makes all the technologies available
ƒ
Keep it simple.
ƒ
Java, COM, corba, any webservice, flex
CF
COM
CORBA
Java
Flex
Web Services
.NET
Application
X
What ColdFusion provides?
3
2006 Adobe Systems Incorporated. All Rights Reserved.
5
ƒ
Microsoft intermediate language (MSIL)
ƒ
CLR (like JVM for Java)
ƒ
Manages memory, threads, execution of MSIL etc
ƒ
.NET versions – 1.x and 2.0
ƒ
Assembly -.dll or .exe (C#, VB, VJ#, managed C++)
ƒ
Global assembly cache (GAC)
Brief .NET introduction
2006 Adobe Systems Incorporated. All Rights Reserved.
6
ƒ
Web Services
ƒ
Messaging
ƒ
Using COM
ƒ
Runtime Unification (NEW !!)
Interoperability Strategies
4
2006 Adobe Systems Incorporated. All Rights Reserved.
7
ƒ
.NET ÆCF (CF components exposed as web service)
<cfcomponent>
<cffunction name='echo' returnType=‘string‘ access='remote'>
<cfargument name='input' type=‘string'>
<cfreturn #arguments.input#>
</cffunction>
</cfcomponent>
ƒ
Access the wsdl using component’s URL
http://localhost/echo.cfc?wsdl
ƒ
CF Æ.NET (.net components exposed as webservice)
<cfobject webservice="http://xyz/TempService.wsdl"
name="obj">
<cfset temp=obj.getTemp("55987")>
Web Services
2006 Adobe Systems Incorporated. All Rights Reserved.
8
ƒ
Messaging (JMS, MQSeries…)
ƒ
Event Gateways
Messaging & COM
ƒ
COM
ƒ
Create COM wrapper for .NET assembly
ƒ
Create Java proxy using some tool
ƒ
Invoke proxy from CF
ColdFusion
Messaging
Provider
.NET
Event
gateways
5
2006 Adobe Systems Incorporated. All Rights Reserved.
9
ƒ
Make .NET components locally available
ƒ
For more fine grained control and invocations
ƒ
Invoke .NET components directly from cfm.
CFM
CF
Server
.NET
Assembly
Direct invocation
Proxy
Runtime Unification – New in Scorpio !
10
2006 Adobe Systems Incorporated. All Rights Reserved.
Web Services Vs Runtime Unification
Web Services
ƒ
Loose Coupling
ƒ
Coarse granular and less
programmatic control (as it is
XML based)
ƒ
Low on performance, reliability
and security
ƒ
Stateless
ƒ
Most useful to use it with
external systems (third party
services like weather/stock price
webservices)
Runtime Unification
ƒ
Tight Coupling
ƒ
Fine granular and more
programmatic control as it is like
invoking local objects
ƒ
High on performance, reliability
and security
ƒ
Stateful
ƒ
Most useful when used with
internal systems of enterprise.
6
2006 Adobe Systems Incorporated. All Rights Reserved.
11
ƒ
Using cfobject and CreateObject
ƒ
Works very much same as cfobject/CreateObject for java
<cfobject type=”.net” class=”com.comp.AccountMgr”
assembly=“act.dll” name=”actMgr”>
<cfset act = actMgr.getAccount(101)>
<cfset bal = act.getBalance()>
Runtime Unification - How does it look?
2006 Adobe Systems Incorporated. All Rights Reserved.
12
ƒ
Seamless. You don’t need to know much about .NET
ƒ
Platform independent.
ƒ
CF on any platform
ƒ
.NET will of course be on a windows
ƒ
Location independent.
ƒ
Can be local or remote
ƒ
Can be even outside the firewall (over the web).
ƒ
Hot deployment of assemblies
ƒ
Communication with multiple .NET side
ƒ
Secure
ƒ
Auto conversion from/to basic CF data types to/from .NET
Features
7
2006 Adobe Systems Incorporated. All Rights Reserved.
13
<cfobject type=".Net"
class=".Net class"
name="Object name"
assembly="list of assemblies"
protocol="tcp|http"
secure="true|false"
server="IPAddress"
port="port">
ƒ
CreateObject(".Net", ".Net class")
ƒ
CreateObject(".Net", ".Net class", "assembly list")
ƒ
CreateObject(".Net", ".Net class", "assembly list", "IP
Address”, “port”)
ƒ
CreateObject(".Net", ".Net class", "assembly list", "IP
Address", "port", "protocol", "secure")
Syntax
2006 Adobe Systems Incorporated. All Rights Reserved.
14
ƒ
Assembly
ƒ
List of dll’s and/or exe’s and/or proxy jars.
ƒ
mscorlib.dll assembly will always be included.
ƒ
Any referenced assembly if present in GAC will automatically be
included.
ƒ
Protocol
ƒ
Binary – default. Better performance
ƒ
HTTP – can be used across firewall
ƒ
Secure CF-.NET communication using SSL
ƒ
ColdFusion acts as SSL client
ƒ
.NET side certificate should be trusted by Coldfusion.
Syntax…
8
2006 Adobe Systems Incorporated. All Rights Reserved.
15
ƒ
Constructors – use init
< cfobject type=”.net” class=”com.comp.Account”
assembly=“act.dll” name=”act”>
<cfset act.init(“Rupesh”, 1000)>
ƒ
Static method
<cfset types = act.getAccountTypes()>
<!--- no need to init() to call static method --->
ƒ
Calling methods
<cfset balance = act.getBalance()>
ƒ
Accessing public fields (using Get_fieldname() and Set_fieldname())
<cfset types = act.Get_name()> <!--- to access ‘name’ --->
ƒ
No setter if the field is final
Invocation
2006 Adobe Systems Incorporated. All Rights Reserved.
16
DEMO
DEMO
9
2006 Adobe Systems Incorporated. All Rights Reserved.
17
Datatypes
ƒ
Automatic conversion of primitive .NET datatypes to CF and CF (java)
datatypes to .NET
ƒ
decimal type not supported
ƒ
use javacast() if required
ƒ
javacast enhanced to support byte, short and char.
18
2006 Adobe Systems Incorporated. All Rights Reserved.
Datatype Mapping
.NET
ƒ
sbyte
ƒ
byte
ƒ
short
ƒ
ushort
ƒ
int
ƒ
uint
ƒ
char
ƒ
long
ƒ
ulong
ƒ
float
ƒ
double
ƒ
bool
ƒ
String
ƒ
decimal
Java
ƒ
byte
ƒ
short
ƒ
short
ƒ
int
ƒ
int
ƒ
long
ƒ
char
ƒ
long
ƒ
float
ƒ
float
ƒ
double
ƒ
boolean
ƒ
String
ƒ
NOT Supported
10
2006 Adobe Systems Incorporated. All Rights Reserved.
19
ƒ
Ambiguous Method Arguments
ƒ
Example 1
public void foo(int param)
public void foo(short param)
foo(12) –
X
foo(javacast( “short”, 12)) -
ƒ
Example 2
public void foo (String arg1)
public void foo (int arg1)
foo(“123”) –
X
foo(javacast(“String”, “123”)) -
When to use Javacast
2006 Adobe Systems Incorporated. All Rights Reserved.
20
CFM /
CFC
CF Server
Proxy
CF Side Agent
.NET
Assembly
.NET side agent
TCP/HTTP
Can be over SSL
What’s going on inside?
11
2006 Adobe Systems Incorporated. All Rights Reserved.
21
ƒ
A proxy is what is used to interface between CF and the .NET runtime
ƒ
Automatically generated by CF if assembly is used
ƒ
To be generated by the user using a CF tool if CF is on non-windows machine.
ƒ
Generate once and use anywhere
ƒ
Proxies generated for 1.x can be used for 1.x as well as 2.0
ƒ
Proxies generated for 2.0 will only be used for 2.0
ƒ
Pass by reference (default)
ƒ
Pass by value
ƒ
Reduced network calls
ƒ
Bigger objects go over network. so can degrade performance
ƒ
User should judge if this is required for a class
ƒ
Ideal for simple data objects
Nuts and Bolts – Proxy generation
2006 Adobe Systems Incorporated. All Rights Reserved.
22
Nuts and Bolts -. NET side agent
ƒ
Agent that runs with .NET
ƒ
Registration of assemblies.
ƒ
Accepts calls from CF side proxy for invocation
ƒ
Delegates the call to the actual assembly
ƒ
Can configure port and protocol to be used
ƒ
Separate installer to install only the agent.
12
2006 Adobe Systems Incorporated. All Rights Reserved.
23
ƒ
CF and .NET on same machine
ƒ
Of course it will be a windows machine ☺
ƒ
No user configuration required
ƒ
.NET side agent will be started by CF
ƒ
Automatic registration of the assembly with the .NET side agent
ƒ
Uses tcp protocol and default port by default
ƒ
Auto generation of proxy if assembly changes
Deployment scenarios - Local
2006 Adobe Systems Incorporated. All Rights Reserved.
24
ƒ
CF and .NET on different machines - Both Windows
ƒ
.NET side agent (shipped with CF) needs to be installed
ƒ
Register the assemblies with .NET side agent
ƒ
Ensure that .NET side agent is running on the remote machine
ƒ
In cfobject/CreateObject, use host and port
Deployment scenarios - Remote
13
2006 Adobe Systems Incorporated. All Rights Reserved.
25
ƒ
CF on non-Windows
ƒ
.NET side agent (shipped with CF) needs to be installed
ƒ
Generate the proxy using CF tool – jnbproxy.exe on .NET machine
ƒ
Register the assembly with the .NET side agent
ƒ
Ensure that .NET side agent is running on the remote machine
ƒ
Copy the generated jar on the CF-machine
ƒ
Use proxy jar in the assembly list.
ƒ
In cfobject/CreateObject, use host and port
Deployment scenarios - Remote…
2006 Adobe Systems Incorporated. All Rights Reserved.
26
ƒ
Enum and Decimal data type
ƒ
methods with out parameters as arguments
ƒ
methods with pointers as arguments or return type
ƒ
.NET UI components
ƒ
Callbacks (events and Delegates) from .NET side
Limitations
14
2006 Adobe Systems Incorporated. All Rights Reserved.
27
Q & A
Q&A
2006 Adobe Systems Incorporated. All Rights Reserved.
28