KCDevCore ColdBox 3, WireBox 1.0 preso

Comments

There aren't any comments for this presentation.

Add Comment

Comments have been closed.

Transcript

no image

Slide Text

Slide Notes


ColdBox 30 Presentation Framework Toolkit


ColdBox 3.0 Presentation
Framework + Toolkit
KCDevCore
Brad Wood
February 22nd 2011

no notes exist for this slide

What is ColdBox


What is ColdBox
Proven MVC event-driven ColdFusion Framework
Follows OO principles and best practices
Based on Code Controllers and not XML dialects
Convention-Based Framework
A great software foundation and tool set
Provides application aspects like: bug reports, logging, caching, debugging tools, i18N and much more.
The first framework in which you can Unit Test your entire application

no notes exist for this slide

How Did ColdBox Start


How Did ColdBox Start?
Luis Majano built as a closed-source, in-house framework in 2005.
Eventually released as an open source project in 2006.
Current Released Build: 2.6.4
Next release: 3.0 currently at RC2

no notes exist for this slide

ColdBox At A Glance


ColdBox At A Glance

no notes exist for this slide

Documentation


Documentation
Tons of it!
Tutorials
Installation Guides
Compatibility Guides
ColdBox book for 2.6.3
CFEclipse, Builder and Dreamweaver language dictionaries
CFEclipse and Builder snippets

no notes exist for this slide

Code Controllers


Code Controllers
No XML dialects
Uses conventions
Flexibility and re-usability
Easier to Unit Test

no notes exist for this slide

Custom Conventions


Custom Conventions
Config
Handlers
Views
Layouts
Models
Modules
External Locations

no notes exist for this slide

Debugging Tools


Debugging Tools
Shows under the hood
Times your events and code
Debugging monitors
Look into cache
Trace request collection through event execution

no notes exist for this slide

Software Aspects


Software Aspects
Multi-Threaded Logging facilities (LogBox)
Multi-Threaded Caching (CacheBox)
IoC/DI Integrations (WireBox)
Built-in Mocking Framework (MockBox)
Custom E-mail bug reports
Interceptors
Plugins

no notes exist for this slide

Performance


Performance
ColdBox is designed for high-availability sites
Has been tuned for very fast performance
ColdFusion 8, 9 and BlueDragon use threads
White-space control

no notes exist for this slide

FlexibleExtendable


Flexible/Extendable
Create your own plugins
Create your own interceptors
Request context decorator
buildLink()
paramValue()
Public repository for developer code sharing (ForgeBox)
ColdBox uses GitHub for collaborative development/pull requests

no notes exist for this slide

Why Use A Framework


Why Use A Framework?
Common vocabulary
Team-oriented development
Common structure
Fosters code re-use
A worldwide tested and solid core
Flexibility & extensibility

no notes exist for this slide

What Is MVC


What Is MVC?

no notes exist for this slide

MVC is a design pattern that separates an application into three layers


MVC is a design pattern that separates an application into three layers
MODEL: (The most important layer)
This layer handles all the business objects, business rules and interaction with storage mechanisms such as databases, xml, etc.
VIEW:
The presentation layer, in our case HTML/JS/XML
CONTROLLER:
Manages events and interacts with the model to prepare the views for rendering. They are in charge of directing the flow of the application.

no notes exist for this slide

What Is The Request Context


What Is The Request Context?
Models a user request
Merges form and URL
Get and set values into it
Lives in the request scope
Every part of the framework has access to it
Set layouts, views, events, etc
Get request metadata: current event, handler, action, view, layout, etc
Request collection persistence on relocations via setNextEvent()

no notes exist for this slide

Anatomy Of An Event Handler


Anatomy Of An Event Handler
ColdFusion component that extends a coldbox event handler
ColdBox events = public/remote methods
Event caching via cffunction metadata
Can create packages (directories)
Events & handlers register via conventions
Use metadata for caching the handler
Implicit execution points: applicationStart, requestStart, requestEnd, preHandler, postHandler.
External locations for handlers

no notes exist for this slide

Anatomy Of A ColdBox Plugin


Anatomy Of A ColdBox Plugin
ColdFusion Components
extend core framework functionality of application functionality
Custom plugins by convention
Programmatic or visual
Use smart caching
Can be used as helpers
You can use an external location for plugins
Included Plugins
Application/session/cookie storage
I18n (internationalization)
Helper Classes (Zip, query helpers, java utils, file utils)
JavaLoader (Mark Mandel)
Feed Reader
AntiSammy (XSS prevention)

no notes exist for this slide

Anatomy Of An Interceptor


Anatomy Of An Interceptor
Follows Publisher/Subscriber Model
Executed by the framework at various execution points
afterConfigurationLoad, afterAspectsLoad, sessionStart, preProcess, preEvent
Also sends in a structure of intercepted metadata
Included Interceptors
SES based on ColdCourse
Security
Autowire
Write your own interceptor
SSL (preProcess)
JavaScript Defer (preRender)
Custom Interception Points
By conventions, create more interception points in your config file
Announce via the API
You can also send in a structure of intercepted data

no notes exist for this slide

ColdBox Proxy


ColdBox Proxy
Flex/Air/Ajax Remote Integration
Event Driven Model, enhanced service layer
Easily create application dashboards
Monitor your application externally, Announce Interception
CFC data binding

no notes exist for this slide

Layouts amp Views Layout Manager


Layouts & Views (Layout Manager)
Helps you define implicit view-folder-layout combinations
When a view is rendered, it knows in which layout to render it
Views can be rendered separately or as content variables
Views can be rendered with no layout and return anything you like
A layout can be declared for an entire folder structure
Views can be cached
Data marshalling
WDDX
JSON
XML

no notes exist for this slide

ColdBox 300 5Point Framework


ColdBox 3.0.0!
5-Point Framework

no notes exist for this slide

Modules


Modules
Stand-alone applications that can be combined together.
Module API
Override parts of the Module
Activate, de-activate, reload the module
RELAX module for RESTful applications

no notes exist for this slide

LogBox


LogBox
Inspired by Log4J
Choose from appenders to send your log messages to
Files
Asynch Files
Emails
Databases
Java sockets
Twitter
Web Services
Customize Log Levels
Off
Debug
Info
Warn
Error
Log different levels of messages to different appenders in different parts of your application.

no notes exist for this slide

MXUnit testing


MXUnit testing
Unit testing and Integration testing built into the framework.
Plugins
Interceptors
Handlers
Model objects
Ability to simulate queries
Ability to mock dependencies

no notes exist for this slide

MockBox


MockBox
When unit testing a specific component, you mock all the dependencies of the component being tested.
Mock methods and behaviors of your mocked objects

no notes exist for this slide

CacheBox


CacheBox
Put Anything you want in the cache
Objects
Data
Events
Views
Highly customizable
Max object limits
Life span
Last accessed timeouts
JVM memory limits
Eviction policies
LRU
LFU
FIFO
Create your own!
Interceptors for cache events
Mulit-threaded on CF8 and BD7

no notes exist for this slide

Slide 27


CacheBox
Cache aggregator (Create multiple named caches using different providers)
One cache agnostic API regardless of implementation of actual cache
Java soft-reference (default)
EHCache
JDBC store
Write your own!
Cache manager
Statistics/reporting
See what's in cache
View cache items
Graphs
Delete cache items

no notes exist for this slide

Caching Examples


Caching Examples
Event Caching
<cffunction name=“blogEntry" cache="true" cacheTimeOut="40" cacheLastAccessTimeout="15">
...
</cffunction>

no notes exist for this slide

Slide 29


Caching Examples
View Caching
<cfset event.setView(name="widget",cache="true",cacheTimeout="15")>
<cfoutput>
   #renderView(view="viewlet/userDetail",cache="true",cacheTimeout="30")#
</cfoutput>

no notes exist for this slide

Slide 30


Caching Examples
Model Caching
<cfcomponent name="TransientObject">
<cfcomponent name="UserService" singleton="true">
<cfcomponent name="BlogEntry" cache="true" cacheTimeout="10">

no notes exist for this slide

Slide 31


Caching Examples
Data Caching
<cfset myCache = getCacheBox().getCache("myCache")>
<cfif NOT myCache.lookup("stateList")>
   <cfquery name="qryGetStates">
   ...
   </cfquery>
   <cfset myCache.set("stateList",qryGetStates,60)>
</cfif>
<cfset qryStates = myCache.get("stateList")>

no notes exist for this slide

WireBox


WireBox
Model Integration/ Dependency Injection
Use as object factory for CFCs, Java objects, Web Services, or RSS Feeds
Scan locations to find your objects
XML is possible, but not required
ColdFusion configuration to define models
Provide aliases
Singletons/transients
Storage scopes
No scope
Application
Session
Request
Cache (in CacheBox)

no notes exist for this slide

Slide 33


WireBox
Autowiring by conventions and notations
Constructor injection
Setter injection
Metadata mixin injection
Inject references to anything you need into your objects
Other models
Settings
Plugins
Data sources
Objects from cache
ColdBox controller
Providers to avoid scope widening
Integrated logging with LogBox
Built-in adapters for ColdSpring and Lightwire
Easily populate model objects: populateModel()
AOP (Aspect Oriented Programming)

no notes exist for this slide

WireBox Defining Where Your CFCs Are


WireBox
Defining Where Your CFCs Are
Implicit
Scan locations so WireBox can find your models automatically.
// Nothing! (Defaults to "model")
wirebox.scanLocations = ["model","transfer.com","org.majano"];
mapDirectory("myapp.iLikeToHideMyModelsHere");

no notes exist for this slide

Slide 35


WireBox
Defining Where Your CFCs Are
Explicit
You tell WireBox where your objects are and how you wish to reference and handle them.
// CFC
map("FunkyObject").to("myapp.model.service.FunkyService");
mapPath("myapp.model.service.FunkyService");
// Java
map("buffer").toJava("java.lang.StringBuffer");
// RSS feed
map("googleNews").toRSS("http://news.google.com/news?output=rss");
// Webservice
map("myWS").toWebservice("http://myapp.com/app.cfc?wsdl");
// Provider
map("Espresso").toProvider("FunkyEspressoProvider");
// DSL
map("Logger").toDSL("logbox:root");

no notes exist for this slide

WireBox Controlling The Scope Of Objects


WireBox
Controlling The Scope Of Objects
Component Metadata Annotations
<cfcomponent name="TransientObject">
<cfcomponent name="UserService" singleton="true">
<cfcomponent name="BlogEntry" cache="true" cacheTimeout="10">

no notes exist for this slide

Slide 37


WireBox
Controlling The Scope Of Objects
Programmatic WireBox Configuration
// map with shorthand or full scope notation
mapPath("model.CoffeeShop").asSingleton();
mapPath("model.CoffeeShop").into(this.SCOPES.SESSION);
// cache some tea
map("GreenTea")
   .to("model.Tea")
   .inCacheBox(timeout=20,provider="ehCache");

no notes exist for this slide

WireBox Declare Dependencies


WireBox
Declare Dependencies
Component Metadata Annotations
<cfcomponent name="myComponent“ autowire="true">
   <cfproperty name="UserGateway" type="model" scope="instance">
   <cfproperty name="DataSource" type="coldbox:datasource:myDSN" scope="variables">
   <cfproperty name="MailTo" type="coldbox:Setting:MailTo" scope="this">
   <cfproperty name="Logger" type="coldbox:plugin:logger" scope="instance.foo.bar">
   <cfproperty name="binaryHeap" type="javaLoader:org.apache.commons.collections.BinaryHeap">
...
</cfcomponent>

no notes exist for this slide

Slide 39


WireBox
Declare Dependencies
Programmatic WireBox Configuration
// Constructor injection
map("transferConfig")
   .to("transfer.com.config.Configuration")
   .initWith(getProperty('datasourcePath'),
          getProperty('configPath'),
          getProperty('definitionPath'));

// Setter injection
map("transferConfig")
   .to("transfer.com.config.Configuration")
   .setter(name="datasourcePath", value=getProperty("datasourcePath"))
   .setter(name="configPath", dsl="property:configPath")
   .setter(name="definitionPath", value=getProperty("definitionPath") );

no notes exist for this slide

Examples


Examples
Let’s dive into some real code!

no notes exist for this slide