Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
ColdFusion Internals 
Paul Nibin K J 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Introduction 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
2 
Client 
Web Server
Agenda 
 Life of a CFM request 
 Classloading in ColdFusion 
 How does RESTful web service work? 
© 2014 Adobe Systems ...
Life of a request 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 4
Life of request in ColdFusion 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
5
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
Template Classloader 
In filter chain 
6 
1. ...
1. Request Validation 
 You are part of request validation too. 
 You can configure the following validations through se...
2. Path Resolution 
http://localhost/employee/addEmployee.cfm 
/employee/addEmployee.cfm 
C:inetpubwwwrootemployeeaddEmplo...
3. Application Resolution 
 Finds the Application.cfc 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Conf...
3. Application Resolution 
 Finds the Application.cfc 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Conf...
Unnamed applications 
http://localhost/axis1Test/basic.cfc?wsdl 
© 2014 Adobe Systems Incorporated. All Rights Reserved. A...
4. Parsing 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
12 
<cfscript> 
function hello() ...
4. Parsing 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
13 
<cfscript> 
function hello() ...
Template Reader 
 Reads the CFM and creates a stream. 
Encoding? 
© 2014 Adobe Systems Incorporated. All Rights Reserved....
Automatic encoding identification 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
15 
Start ...
5. Byte code generation 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
AST 
<cfusion_Root>w...
Template Classloader 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
17 
Start 
Is 
class 
i...
Summary 
 ColdFusion filter chain has 5 main phases 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confid...
Classloading 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 19
Class Loading 
 -Dcoldfusion.classPath = {application.home}/lib/updates, 
{application.home}/lib,{application.home}/lib/a...
Prior to CF10 
Create a folder in cfusionlib. 
Copy your jars to the new folder. 
Edit jvm.config to add the new folder to...
CF10 and afterwards 
 CF10 introduced enhanced java integration. 
 Application setting available to specify custom class...
RESTful web services 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 23
RESTful web services 
 The W3C defines a Web service as: 
a software system designed to support interoperable 
machine-to...
How does RESTful web service work? 
 Two logical sections 
Registratio 
n 
© 2014 Adobe Systems Incorporated. All Rights ...
Why? 
Traditional web service 
POST /students/StudentsService HTTP/1.1 
Host: http://localhost:8500 
Content-Type: soap/xm...
Registration Workflow 
 Registration is the process of making your service ready for use. 
© 2014 Adobe Systems Incorpora...
Settings 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
28 
Register 
application 
Scanning...
Usage Workflow 
 Inputs: HTTP request 
 The URL of the request 
 HTTP Headers 
 Body of the request 
 Query params, C...
Explaning the URL 
 http:// + localhost:8500 + /rest + /examples + /helloworld 
© 2014 Adobe Systems Incorporated. All Ri...
Request Workflow 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
31 
Identify 
REST 
request...
Settings 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 
32 
Identify 
REST 
request 
• Chan...
Summary 
 RESTful web services introduction 
 Why RESTful web service needs to be registered first? 
© 2014 Adobe System...
Q & A 
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 34 
pnibinkj@adobe.com 
http://blogs.co...
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Upcoming SlideShare
Loading in …5
×

ColdFusion Internals

2,119 views

Published on

Look under the covers at the ColdFusion Internals, given by Adobe engineer Paul Nibin

Published in: Software
  • Be the first to comment

  • Be the first to like this

ColdFusion Internals

  1. 1. ColdFusion Internals Paul Nibin K J © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  2. 2. Introduction © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 2 Client Web Server
  3. 3. Agenda  Life of a CFM request  Classloading in ColdFusion  How does RESTful web service work? © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 3
  4. 4. Life of a request © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 4
  5. 5. Life of request in ColdFusion © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 5
  6. 6. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Template Classloader In filter chain 6 1. Request Validation • Validates the request. 2. Path Resolution • Resolve s absolute CFM Path 3.Application Resolution • Locates Applicati -on. • Creates Applicati -on scope. • Invokes life cycle method 4. Parse • Parse the CFM file . • Generat e AST using the grammar . 5.Bytecod e Generatio n • Translat e the AST to java byte code
  7. 7. 1. Request Validation  You are part of request validation too.  You can configure the following validations through settings. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 7  Request Size Limits  Request Limits
  8. 8. 2. Path Resolution http://localhost/employee/addEmployee.cfm /employee/addEmployee.cfm C:inetpubwwwrootemployeeaddEmployee.cfm Request URL Virtual Path © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 8 Absolute Path Connector You can cache the web server path using an admin setting.
  9. 9. 3. Application Resolution  Finds the Application.cfc © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 9  Creates Application Scope  Invokes Life cycle methods  OnApplicationStart()  OnRequestStart()  OnError()
  10. 10. 3. Application Resolution  Finds the Application.cfc © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 10  Creates Application Scope  Invokes Life cycle methods  OnApplicationStart()  OnRequestStart()  OnError() Start Check for the Application.cfc in current directory. Found Application.cf c? Found Application Check for the Application.cfc in parent directory. Yes No Setting to specify till what level ColdFusion should search for Application.cfc
  11. 11. Unnamed applications http://localhost/axis1Test/basic.cfc?wsdl © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. axis1Test 11 Application.cfc <cfcomponent> <cfset this.wssettings.version.publish=“1”> </cfcomponent> basic.cfc axis2Test Application.cfc <cfcomponent> <cfset this.wssettings.version.publish=“2”> </cfcomponent> basic.cfc http://localhost/axis2Test/basic.cfc?wsdl ColdFusion disables the creation of un named applications using an admin setting.
  12. 12. 4. Parsing © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 12 <cfscript> function hello() { writeOutput("hello"); } hello(); </cfscript> Template Reader Abstract Syntax Tree (AST)
  13. 13. 4. Parsing © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 13 <cfscript> function hello() { writeOutput("hello"); } hello(); </cfscript> Template Reader Abstract Syntax Tree (AST)
  14. 14. Template Reader  Reads the CFM and creates a stream. Encoding? © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 14
  15. 15. Automatic encoding identification © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 15 Start Use encoding Is BOM present? Guess encoding (icu4j) Is guess probability 100%? End Yes Yes No Save the file with BOM <cfprocessingdirective ..> Use system encoding End No -Dfile.encoding=“”
  16. 16. 5. Byte code generation © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. AST <cfusion_Root>wwwrootWEB-INF 16 Byte Code Engineering Library (BCEL) cfclasses Byte Code
  17. 17. Template Classloader © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 17 Start Is class in cache ? Check Last Modified Date of CFM Is Modifie d? Parse Generate byte code Load byte code End Use cached Class No Yes No Yes Clear template cache Enable trusted cache
  18. 18. Summary  ColdFusion filter chain has 5 main phases © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 18 1. Request Validation o Settings in administrator 2. Path Resolution o Cache web server path setting 3. Application Resolution o Finding Application.cfc o Unnamed applications 4. Parsing o File encoding 5. Bytecode generation o Template Classloader
  19. 19. Classloading © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 19
  20. 20. Class Loading  -Dcoldfusion.classPath = {application.home}/lib/updates, {application.home}/lib,{application.home}/lib/axis2,{application.home}/gat eway/lib/,… © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 20  In jvm.config ClassLoader cfusion/lib cfusion/lib/update s cfusion/lib/axis 2
  21. 21. Prior to CF10 Create a folder in cfusionlib. Copy your jars to the new folder. Edit jvm.config to add the new folder to the end of coldfusion.classPath property © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 21 Cons  Conflicts  May hamper normal server functioning.  Any changes in jar files need server restart to take effect.
  22. 22. CF10 and afterwards  CF10 introduced enhanced java integration.  Application setting available to specify custom classpath.  <cfset this.javaSettings = {LoadPaths = [".java_lib",".javamyjar.jar"], reloadOnChange = false}> © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 22 Pros  Complete isolation  Will not affect server functioning  Allows reloading
  23. 23. RESTful web services © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 23
  24. 24. RESTful web services  The W3C defines a Web service as: a software system designed to support interoperable machine-to-machine interaction over a network.  A webservice becomes RESTful when the following 4 constraints are satisfied. 1. Addressability 2. Multiple Representations 3. Uniform and constrained interfaces 4. Stateless communication © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  25. 25. How does RESTful web service work?  Two logical sections Registratio n © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Usage
  26. 26. Why? Traditional web service POST /students/StudentsService HTTP/1.1 Host: http://localhost:8500 Content-Type: soap/xml <Envelope> <Header></Header> <Body> <GetStudent> <Id>112</Id> </GetStudent> </Body> <Envelope> RESTful web service GET /students/112 HTTP/1.1 Host: http://localhost:8500 Accepts: text/html © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  27. 27. Registration Workflow  Registration is the process of making your service ready for use. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 27 Register application Scanning for REST CFC Generate skeleton Annotate skeleton Register with Jersey  Inputs: Application Root Path and Service Name
  28. 28. Settings © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 28 Register application Scanning for REST CFC • restsettings.cfclocatio n Generate skeleton • restsettings.skipCFCWithE rror Annotate skeleton Register with Jersey
  29. 29. Usage Workflow  Inputs: HTTP request  The URL of the request  HTTP Headers  Body of the request  Query params, Cookies, Matrix params etc.. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 29
  30. 30. Explaning the URL  http:// + localhost:8500 + /rest + /examples + /helloworld © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 30 http • The protocol localhost:8500 • Server address and port • Context path used to identify the request as a REST request rest examples • The application name used during registration helloworld • restPath defined in the CFC
  31. 31. Request Workflow © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 31 Identify REST request Identifies application Identifies CFC Identifies function Invokes Function
  32. 32. Settings © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 32 Identify REST request • Change context path in web.xml Identifies application • Can make application default if needed Identifies CFC Identifies function Invokes Function • use custom serializer to modify response
  33. 33. Summary  RESTful web services introduction  Why RESTful web service needs to be registered first? © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 33  Registration workflow o Settings  Request Workflow  Settings
  34. 34. Q & A © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 34 pnibinkj@adobe.com http://blogs.coldfusion.com/
  35. 35. © 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

×