Presentation is loading. Please wait.

Presentation is loading. Please wait.

Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems.

Similar presentations


Presentation on theme: "Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems."— Presentation transcript:

1 Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems

2 June 27 th - 30 th 2007www.cfunited.com About me… Enterprise Applications Consultant for Cynergy Systems Developing with ColdFusion since 1996 Coauthor of ColdSpring Framework Creator of ColdSpring's AOP Framework Author of Model-Glue for Java Currently working in CF, Java, Flex

3 June 27 th - 30 th 2007www.cfunited.com GoalsGoals Introduce AOP concepts Discuss benefits of SOA Introduce ColdSpring Remoting Show examples

4 June 27 th - 30 th 2007www.cfunited.com What is AOP? Aspect Oriented Programming Relatively new programming methodology that complements OOP Goal to assist in handling ‘far reaching’ or ‘cross- cutting’ concerns in your application AOP aims to significantly reduce code duplication Helps your primary business objects become more ‘cohesive’ and ‘loosely coupled’ Insert confusing terminology…

5 June 27 th - 30 th 2007www.cfunited.com What did that mean? AOP is new, new technologies come with new terminology and new ways of thinking. Some of the terminology is just damn confusing. Don’t get bogged down! It’s far less confusing that it sounds! Let’s focus on Why we should use AOP and How it works

6 June 27 th - 30 th 2007www.cfunited.com Why AOP? OOP is all about describing your application in terms of real world objects and their behavior Some objects are the people, places and things that your application deals with, our Domain Objects Others are services that these domain objects need to get their jobs done These are the concrete objects in our applications, they represent primary business needs The more focused on primary business objectives these objects are the better. We often strive for what is called more ‘cohesive’ domain objects

7 June 27 th - 30 th 2007www.cfunited.com Why AOP? However, objects often need to take part in more abstract systems in your application Transactions Security policies Caching systems Of course, the poster child for AOP, logging These are abstract behaviors you would like many of your model objects to have.

8 June 27 th - 30 th 2007www.cfunited.com Why AOP? Abstract systems that are broadly needed in many parts of your application are called ‘Cross Cutting Concerns’ AOP gives you a way to apply these systems broadly to existing objects. With ColdSpring AOP gives you apply behavior ‘declaratively’ in your configuration file, instead of programmatically

9 June 27 th - 30 th 2007www.cfunited.com How AOP Works Two central concepts to understanding AOP Interception Introduction Most of ColdSpring’s AOP framework is there to provide you the mechanisms to perform these two central tasks

10 June 27 th - 30 th 2007www.cfunited.com Interception Basically all AOP frameworks allow you to intercept specific method calls on objects. ColdSpring and Spring ONLY let you work with Method Interception. AspectJ lets you intercept changes in variables as well as basic programming constructs like loops. Don’t think you are limited by Method Interception. ColdSpring adheres to the AOP Alliance’s interfaces for Method Interception

11 June 27 th - 30 th 2007www.cfunited.com Interception Identifying the methods is a primary functions of an AOP framework. Here comes terminology… We call these ‘Join Points’, points in your model components where you want to add functionality. As far as ColdSpring AOP is concerned, Join Points == Methods

12 June 27 th - 30 th 2007www.cfunited.com Introduction ColdSpring allows you to introduce new functionality at specific times during a method’s execution You can introduce code before, after, during an exception, or around the method (before and after, with a little more complexity…) More ugly terminology… We call this ‘Advising’ the method. ColdSpring provides special classes for you to extend that allow you to define Advice, meaning functionality you want to introduce at specific times. These classes are called Advice Types

13 June 27 th - 30 th 2007www.cfunited.com ColdSpring’s Advice types BeforeAdvice AfterReturningAdvice AfterThrowingAdvice MethodInterceptor (say what? That’s like AroundAdvice) Blame MethodInterceptor on that AOP Alliance I told you about. MethodInterceptor sounds powerful and complicated, that’s probably a good thing…

14 June 27 th - 30 th 2007www.cfunited.com AOP Proxies Objects that hold a reference to another object and delegate method calls to that object. AOP Proxies are generated at runtime, through a Factory called ProxyFactoryBean ProxyFactoryBean knows how to add in the functionality in your Advice classes. This process is called Weaving It uses class called an Advisor, which we configure to tell ColdSpring how to introduce in our new functionality.

15 June 27 th - 30 th 2007www.cfunited.com AOP Proxy Creation

16 June 27 th - 30 th 2007www.cfunited.com AOP Proxy Creation

17 June 27 th - 30 th 2007www.cfunited.com AOP Proxy Creation

18 June 27 th - 30 th 2007www.cfunited.com AOP Proxy Creation

19 June 27 th - 30 th 2007www.cfunited.com AOP Proxy Creation

20 June 27 th - 30 th 2007www.cfunited.com Three Tiered architecture

21 June 27 th - 30 th 2007www.cfunited.com Three Tiered architecture Traditional object oriented approach Clear separation of Presentation, Business, and Data Tiers Client code interacts directly with domain model Increases coupling between presentation and business objects Increases dependencies between business objects

22 June 27 th - 30 th 2007www.cfunited.com Service Oriented Architecture

23 June 27 th - 30 th 2007www.cfunited.com Service Oriented Architecture Services abstract the complexities of business layer Provide public api for logical units of work Clients always interact through services Decouples the presentation layer from business layer

24 June 27 th - 30 th 2007www.cfunited.com Service Oriented Architecture Through interfaces or abstract classes we can decouple implementation Remote Services are extended from the service layer Represents a shift from Domain Modeling to Feature Driven development

25 June 27 th - 30 th 2007www.cfunited.com ColdSpring Remoting Automatically exposes Services as Remote Services Leverages ColdSpring AOP, allowing powerful integration through method interception Can provide type conversion from CF to AS for Flex 1.5 apps

26 June 27 th - 30 th 2007www.cfunited.com ColdSpring Remoting Configure RemoteProxyFactoryBean Provide a ServiceName Target will be an existing service Add any existing Interceptors we would like

27 June 27 th - 30 th 2007www.cfunited.com Directory Example – UI

28 June 27 th - 30 th 2007www.cfunited.com Code Review…

29 June 27 th - 30 th 2007www.cfunited.com Common Pitfalls Ensuring ColdSpring Bean Factory is created before Flex app access it can be confusing Leverage application.cfc to load ColdSpring AS/CF Conversion relies on medatata in CF and AS classes  ‘alias’ attribute in tag  [RemoteClass] metadata tag in AS Objects Accessing session inside body of remote methods can be problematic

30 June 27 th - 30 th 2007www.cfunited.com Common Pitfalls If we want a remote service method to accept a Struct we need to wrap it in an object in Flex  Arguments is already a struct Flex Dates are Calendar objects, with timezone information. Careful about using dates as Strings in CF Be careful about setting default properties in CF Domain Objects  May want to take advantage of ‘static initializer’, code outside cffunction tags

31 June 27 th - 30 th 2007www.cfunited.com Questions… Questions…


Download ppt "Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems."

Similar presentations


Ads by Google