• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
IOC and AOP presentation

IOC and AOP presentation






Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment
  • SEO considers how search engines work, what people search for, the actual search terms typed into search engines and which search engines are preferred by their targeted audience. SEM: Search engine marketing, (SEM), is a form of Internet marketing that seeks to promote websites by increasing their visibility in search engine result pages (SERPs) through the use of paid placement, contextual advertising, and paid inclusion. The acronym "SEOs" can refer to "search engine optimizers," a term adopted by an industry of consultants who carry out optimization projects on behalf of clients, and by employees who perform SEO services in-house

IOC and AOP presentation IOC and AOP presentation Presentation Transcript

  • A O P & IO C V u Co n g T h a n h V i Qu o c Ha n h Social team www.exoplatform.com Copyright 2011 eXo Platform
  • Agenda W h a t is IO C ? IO C – Tim e o f In je c t o r IO C – P r o s & C o n s IO C - S c o p e De mo www.exoplatform.com 2 Copyright 2011 eXo Platform
  • In v e r s io n O fC o n t r o l ( IO C ) www.exoplatform.com Copyright 2011 eXo Platform
  • WHAT IS “DEPENDENCY”? www.exoplatform.com 4 Copyright 2011 eXo Platform
  • Implementation with NOT IOC» Construction by Hand.» Factory Pattern. www.exoplatform.com 5 Copyright 2011 eXo Platform
  • Dependencies Problems» Code is tightly coupled» Difficult to isolate when testing» Difficult to maintain. www.exoplatform.com 6 Copyright 2011 eXo Platform
  • What is IOC?» Hollywood principle “Dont call us, well call you.”» Creating, Assembling and Wiring the dependencies into Object graph.» Type of Dependency Injector: – Constructor – Setter – Method – Field(Guice) www.exoplatform.com 7 Copyright 2011 eXo Platform
  • IOC: Pros and Cons» Pros: – Loosely Coupled – Increases Tesability – Separates component clearly. – Allows for use of Inversion of Control Container.» Cons: – Increases code complexity – Difficult to understand at First – Complicate Debugging at First – Complicates following Code Flow. www.exoplatform.com 8 Copyright 2011 eXo Platform
  • Time for Injector - BoorStrapping the Injector» Constructed and prepared before it can be used. – In the init lifecycle stage of a web application. – On startup of a desktop program www.exoplatform.com 9 Copyright 2011 eXo Platform
  • IOC - Metadata and Injector Configuration» XML configuration file.» Annotations(@Injector, @Singleton, …)» Invoking into a programmatic API. www.exoplatform.com 10 Copyright 2011 eXo Platform
  • Boorstrapping the Injector(Cont)» Constructed and prepared before it can be used. – On demand, every time it is needed – Lazily, when it is first needed www.exoplatform.com 11 Copyright 2011 eXo Platform
  • IOC - What is Scope?Fixed duration of time or method calls in which an object exist. General-purpose scopes: Singleton and No-scope.» Web Application: – Request, Session and Conversation scope – Transaction scope www.exoplatform.com 12 Copyright 2011 eXo Platform
  • IOC - Benefit of Scope» Lets injector manage the latent state of your objects» Ensures that your services get new instances of dependencies as needed» Implicitly separates state by context. www.exoplatform.com 13 Copyright 2011 eXo Platform
  • DEMO www.exoplatform.com Copyright 2011 eXo Platform
  • Wha t? www.exoplatform.com Copyright 2011 eXo Platform
  • What? www.exoplatform.com 16 Copyright 2011 eXo Platform
  • What?AOP - Enables encapsulation of functionality that affects multipleclasses in separate units - Complements object oriented programming - Is not about “patching” pieces of code. About performing anaction systematically upon recognition of a behavior in the code. www.exoplatform.com 17 Copyright 2011 eXo Platform
  • Why? Benefits: - Separates persistence and specific functionality (logging, security...) - Promotes code reuse and modularization - Decouples codes (the LogFactory from the DAO impl’s) www.exoplatform.com 18 Copyright 2011 eXo Platform
  • AOP vs OOP Object Oriented Aspect Oriented Class – code unit that Aspect – code unit that encapsulates methods and encapsulates pointcuts, advice, attributes. and attributes. Method signatures – define Pointcut – define the set of the entry points for the entry points (triggers) in which execution of method bodies. advice is executed. Method bodies – Advice – implementations of the implementations of the cross cutting concerns. primary concerns. Compiler – converts source Weaver – instruments code code into object code. (source or object) with advice. www.exoplatform.com 19 Copyright 2011 eXo Platform
  • Concepts- Crosscutting Concerns- Aspect: The merger of advice and pointcuts. All information about where, when and what job is to be done.- Advice: The job of an aspect. Defines the what and when of an aspect.- Pointcut: Pointcuts help narrow down the joinpoints advised by an aspect. Define the where of an aspect.- Joinpoint: A point in the execution of an application where an aspect can be plugged in. All the opportunities for advice to be applied. www.exoplatform.com 20 Copyright 2011 eXo Platform
  • Concepts- Target: Object being advised.- Proxy: The object created after applying advice to the target object. To the clientmaking use of the target object the proxy looks the same.- Weaving: Process of applying aspects to a target object to create a new, proxiedobject. www.exoplatform.com 21 Copyright 2011 eXo Platform
  • How it works? www.exoplatform.com 22 Copyright 2011 eXo Platform
  • www.exoplatform.com23 Copyright 2011 eXo Platform
  • Th a n k yo u ! www.exoplatform.com Copyright 2011 eXo Platform