24
2006 Adobe Systems Incorporated. All Rights Reserved. 1 Language Enhancements Rupesh Kumar Computer Scientist June 27, 2007

Language enhancement in ColdFusion 8

Embed Size (px)

Citation preview

2006 Adobe Systems Incorporated. All Rights Reserved.1

Language Enhancements

Rupesh KumarComputer ScientistJune 27, 2007

2006 Adobe Systems Incorporated. All Rights Reserved.2

Agenda

Syntax enhancements

CFC Enhancements

Multi-Threading

New File I/O

Application.cfc

cfdump enhancement

Secure ftp

Misc cfzip

Cffeed

cfobject changes

cfdbinfo

2006 Adobe Systems Incorporated. All Rights Reserved.3

Syntax Enhancement

cfscript operators Now ++, --, +=, -=, /=, *=, ==, >=, <=, <>, &= available in cfscript

Implicit struct and array creation <cfset a={key1="value1", key2=expression}>

<cfset a=[expression1, innerstruct1, innerarray1, literal]>

Nested array and struct not yet supported

2006 Adobe Systems Incorporated. All Rights Reserved.4

attributeCollection

Instead of passing tag attributes, pass a struct to tags

Conditional tag attributes

Example TBD

2006 Adobe Systems Incorporated. All Rights Reserved.5

New File I/O

Reading large files cfloop tag

FileReadXXX functions

<cfloop file="temp.txt" from=5 to=10 index="myline"> <cfoutput>#myline#</cfoutput>

</cfloop>

<cfscript>     myfile = FileOpen("c:\temp\

myfile.txt","read");   while(NOT isEOF(myfile))       x = FileReadLine(myfile); // read line

FileClose(myfile); </cfscript>

2006 Adobe Systems Incorporated. All Rights Reserved.6

FileXXX functions

2006 Adobe Systems Incorporated. All Rights Reserved.7

CFTHREAD

Allow cf page to launch threads for example fetch result of a web service

Create, join, sleep, terminate

Thread local scope Any variable with var or with no scope inside cfthread tag

THREAD scope Contains thread-specific variables and metadata about the thread

Owner can write, anyone can read

Attributes scope Passed to the thread by value

Server, Session, Request, and Client scopes shared with the launching page

2006 Adobe Systems Incorporated. All Rights Reserved.8

CFTHREAD – Example

<cfloop query="dir">

<cfset threadname = "thread_" & #i#>

<cfset i=i+1>

<cfthread name="#threadname#" filename="#dir.name#">

<!--- Declare local variable--->

<cfset localVar = “Only for thread”>

<cffile action="COPY" source="#src#\#filename#"

destination="#dest#\#filename#\">

<!--- Set variable in THREAD scope --->

<cfset THREAD.readOutside = “sure”>

</cfthread>

</cfloop>

<!--- Access THREAD scope outside --->

<cfset reading=thread_1.readOutside>

2006 Adobe Systems Incorporated. All Rights Reserved.9

CFC Enhancements

Interface

Serialization

Duplicate

onMissingMethod

Metadata

2006 Adobe Systems Incorporated. All Rights Reserved.10

CFC Interfaces

<!--- EventListener interface --->

<cfinterface>

<cffunction name=“handleEvent”><cfargument name=“event” type=“struct”

required=“true”></cffunction>

</cfinterface>

<!--- EventHandler component --->

<cfcomponent implements=“EventListener”>

<cffunction name=“handleEvent”><cfargument name=“event” type=“struct”

required=“true><!--- implementation code here --->

</cffunction>

</cfcomponent>

2006 Adobe Systems Incorporated. All Rights Reserved.11

CFC serialization

CFC stored in the session can be retrieved back from the session

when a session failover happens in a ColdFusion cluster

Struct & arrays in session scope also supported

CFC referencing a CFC also supported

2006 Adobe Systems Incorporated. All Rights Reserved.12

CFC Duplicate

Also used in cfthread when cfc is passed

TBD

2006 Adobe Systems Incorporated. All Rights Reserved.13

OnMissingMethod

2006 Adobe Systems Incorporated. All Rights Reserved.14

Metadata

getComponentMetadata

TBD

2006 Adobe Systems Incorporated. All Rights Reserved.15

Application.cfc changed

onMissingTemplate

Per app settings

2006 Adobe Systems Incorporated. All Rights Reserved.16

onMissingTemplate

This function is invoked on file not found condition

No other handlers are invoked

Rules TBD, lot of discussion on forums

2006 Adobe Systems Incorporated. All Rights Reserved.17

Per app settings

Mappings

Custom tag paths

Via THIS scope in Application.cfc

Overrides server wide settings in Administrator

<cfset THIS.mappings["MyMap"]="c:\inetpub\myStuff">

<cfset THIS.customtagpaths = "c:\mapped1,c:\mapped2">

2006 Adobe Systems Incorporated. All Rights Reserved.18

DB Features

Support for DataDirect v3.6 drivers

Auto-generated key retrieval

Transaction savepoints <cftransaction action="setsavepoint" savepoint="pointA" />

Split neo-query.xml into neo-drivers.xml, neo-datasources.xml

CFDBINFO tag Fetch tables, database names, stored procedures in a data source

Columns, indexes, primary keys, foreign keys in a table

<cfdbinfo type="tables“ datasource=“dsn“ dbname="databasename“ pattern="pattern“ username="username1“ password="password1“

name="resultname">

2006 Adobe Systems Incorporated. All Rights Reserved.19

CFDUMP

Show the first 'n' keys of a structure

Show or hide query colums or structure keys

Include SQL and other metadata when dumping query objects

<cfdump var = "#variable#" expand = "yes" or "no" label = "text" top = "number of rows or levels" show = "columns or keys" hide = "columns or keys" keys = "number of keys to display for structures" output = "browser or console or file" showUDFs = "yes or no">

2006 Adobe Systems Incorporated. All Rights Reserved.20

Secure CFFTP

Supports FTP over SSH2 protocol

<cfftp action = "action"username = "name"password = "password" fingerprint = "hh:hh:hh:hh:hh:hh:hh:hh" key = "absolute path of the private key" paraphrase = "paraphrase of the private key"server = "server"timeout = "timeout in seconds"port = "port"connection = "name"proxyServer = "proxy server"retryCount = "number"stopOnError = "yes" or "no" secure = "yes"result = "result_name“

>

2006 Adobe Systems Incorporated. All Rights Reserved.21

PrecisionEvaluate

Uses BigDecimal arithmetic

TBD

2006 Adobe Systems Incorporated. All Rights Reserved.22

CFZIP

Support manipulation of ZIP & JAR files

Create, extract, delete, list and update action on the zip entries

<cfzip file="E:\work\abc.zip" source="c:\temp" />

<cfzip file="E:\work\test.zip" action="zip">

<cfzipparam source="c:\temp\abc.txt" prefix="com\abc">

<cfzipparam source="c:\src\classes" recurse="true" filter="*.class,*.properties"

prefix="classes">

<cfzipparam source="c:\src\Manifest.MF" entrypath="META-INF\MANIFEST">

</cfzip>

2006 Adobe Systems Incorporated. All Rights Reserved.23

CFFEED

Read all flavours of RSS and Atom feeds.

Create RSS 2.0 and Atom 1.0 feeds.

Support for enclosures

Support for iTunes & Dublin Core

Convert feed from/to RSS and ATOM

Demo

2006 Adobe Systems Incorporated. All Rights Reserved.24