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.

Introdução a AOP + SpringAOP

1,182 views

Published on

Published in: Technology
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Introdução a AOP + SpringAOP

  1. 1. Introdução a AOP + SpringAOP Jobson Ronan {jrjs@cin.ufpe.br}
  2. 2. Motivação <ul><li>Atualmente OOP é o paradigma de desenvolvimento de software mais adequado </li></ul><ul><li>Por que? </li></ul><ul><ul><li>Emcapsulamento </li></ul></ul><ul><ul><li>Herança </li></ul></ul><ul><ul><li>Polimorfismo </li></ul></ul><ul><li>Porém, OOP não trata adequadamente de comportamentos que aparecem sobre muitos módulos </li></ul>
  3. 3. Um sistema como um conjunto de interesses <ul><li>Um complexo sistema de software pode ser visto como uma implementação combinada de múltiplos interesses </li></ul><ul><ul><li>Lógica de negócios </li></ul></ul><ul><ul><li>Performance </li></ul></ul><ul><ul><li>Persistência </li></ul></ul><ul><ul><li>Logging </li></ul></ul><ul><ul><li>Debugging </li></ul></ul><ul><ul><li>Autenticação </li></ul></ul><ul><ul><li>Segurança </li></ul></ul><ul><ul><li>Etc. </li></ul></ul>
  4. 4. Um sistema como um conjunto de interesses <ul><li>Dado um conjunto de requisitos, pode-se identificar uma série de interesses </li></ul>
  5. 5. Interesses atravessadores <ul><li>Sistemas são criados em resposta a requisitos </li></ul><ul><ul><li>Core module-level requirements </li></ul></ul><ul><ul><li>System-level requirements </li></ul></ul><ul><li>Muitos requisitos do sistema tendem a ser ortogonais (mutuamente dependentes) de outros e de requisitos de módulos. </li></ul><ul><li>Requisitos do Sistema tendem a atravessar muitos modulos </li></ul>
  6. 6. Interesses atravessadores <ul><li>Exemplo </li></ul><ul><li>//... </li></ul><ul><li>public class AccountService { </li></ul><ul><ul><li>public void updateAccount(updateAccount acount) throws Exception { </li></ul></ul><ul><ul><li>SecurityManager.requireUserRole(“admin”); </li></ul></ul><ul><ul><li>TransactionManager.beginTransaction(); </li></ul></ul><ul><ul><li>try { </li></ul></ul><ul><ul><li>//...código de negócio </li></ul></ul><ul><ul><li>TransactionManager.commit(); </li></ul></ul><ul><ul><li>log.info(“acount updated”); </li></ul></ul><ul><ul><li>} catch (Exception e) { </li></ul></ul><ul><ul><li>TransactionManager.rollback(); </li></ul></ul><ul><ul><li>log.warning(“exception throw”, e); </li></ul></ul><ul><ul><li>throw e; </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><li>///... </li></ul>Segurança Transações Logging
  7. 7. Problemas <ul><li>O espaço de requisitos é multidimensional, enquanto o de implementação é unidimensional </li></ul><ul><li>Sintomas </li></ul><ul><ul><li>Código misturado </li></ul></ul><ul><ul><li>Código espalhado </li></ul></ul><ul><li>Afeta o desenvolvimento do software </li></ul>
  8. 8. Problemas <ul><li>Pobre delineabilidade </li></ul><ul><li>Diminuição da produtividade </li></ul><ul><li>Menor reuso de código </li></ul><ul><li>Baixa qualidade de código </li></ul><ul><li>Evolução mais dificultada </li></ul>
  9. 9. Soluções <ul><li>Mix-in Classes </li></ul><ul><li>Design Patterns </li></ul><ul><ul><li>Visitor e Tamplate Method </li></ul></ul><ul><li>Específico de domínio </li></ul><ul><ul><li>EJBs </li></ul></ul>
  10. 10. Separação de Interesses e AOP <ul><li>AOP permite implementar individuais interesses de maneira fracamente acoplada e combinar essas implementações no sistema final. </li></ul><ul><ul><li>Permite uma implementação modularizada de interesses atravessadores ( crosscuting concerns ) </li></ul></ul><ul><ul><li>Essa unidade de modularização é chamada de Aspecto </li></ul></ul><ul><li>Estágios de desenvolvimento </li></ul><ul><ul><li>Decomposição aspectual </li></ul></ul><ul><ul><li>Implementação do interesse </li></ul></ul><ul><ul><li>Recomposição aspectual </li></ul></ul>
  11. 11. Estágios de desenvolvimento
  12. 12. Benefícios <ul><li>Implementação modularizada de interesses atravessadores </li></ul><ul><li>Sistemas fáceis de evoluir </li></ul><ul><li>Decisões de modelagem atrasadas </li></ul><ul><li>Maior reuso do código </li></ul>
  13. 13. SpringAOP <ul><li>Uma das chaves do Spring e seu framework de AOP </li></ul><ul><li>Apesar do container IoC do Spring não depender de AOP, este completa o Spring oferecendo soluções interessantes </li></ul><ul><ul><li>Disponibilizar serviços declarativos coorporativos, como gerenciamento de transações e autenticação </li></ul></ul><ul><ul><li>Possibilitar a implementação de aspectos customizados </li></ul></ul>
  14. 14. Conceitos <ul><li>Aspecto: </li></ul><ul><ul><li>Implementado no Spring como Advisors ou Interceptors </li></ul></ul><ul><li>Joinpoint: </li></ul><ul><ul><li>Ponto de execução de um programa. No SpringAOP é sempre referente a uma invocação de método </li></ul></ul><ul><li>Advice : </li></ul><ul><ul><li>Ação tomada pelo framework AOP em algum Joinpoint </li></ul></ul><ul><li>Pointcut : </li></ul><ul><ul><li>Um conjunto de Joinpoints para os quais um advice deve ser disparado </li></ul></ul><ul><li>Objeto Alvo: </li></ul><ul><ul><li>Objeto contendo joinpoints. Também chamado de advised ou proxied </li></ul></ul>
  15. 15. Conceitos <ul><li>Introduction: </li></ul><ul><ul><li>Adicionar métodos e atributos em uma classe advised . Spring permite introduzir novas interfaces para objetos advised . </li></ul></ul><ul><li>Proxy AOP: </li></ul><ul><ul><li>Um objeto criado pelo framework de AOP, contendo um advice. </li></ul></ul><ul><li>Weaving: </li></ul><ul><ul><li>Aplicação de aspectos para criar objetos advised . </li></ul></ul>
  16. 16. Tipos de Advices <ul><li>Around advice </li></ul><ul><li>Before advice </li></ul><ul><li>Throws advice </li></ul><ul><li>After Returning advice </li></ul>
  17. 17. Tipos de Weaver <ul><li>Estático </li></ul><ul><ul><li>Aspectos são tipicamente introduzidos ao byte code em tempo de compilação ou através de classloaders customizados em tempo de execução </li></ul></ul><ul><ul><ul><li>AspectJ (byte code) </li></ul></ul></ul><ul><ul><ul><li>JBoss AOP, AspectWerkz (classloader) </li></ul></ul></ul><ul><li>Dinâmico </li></ul><ul><ul><li>Cria proxies para todos os objetos interessados </li></ul></ul><ul><ul><li>Leve perda de performance </li></ul></ul><ul><ul><li>Fácil de configurar </li></ul></ul><ul><ul><li>Spring </li></ul></ul>
  18. 18. Em prática public interface IBusinessLogic { public void foo(); } public class BusinessLogic implements IBusinessLogic { public void foo() { System.out.println( “Inside BusinessLogic.foo()” ); } }
  19. 19. Em prática import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; public class MainApplication { public static void main(String [] args) { // Read the configuration file ApplicationContext ctx = new FileSystemXmlApplicationContext( &quot;springconfig.xml&quot; ); //Instantiate an object IBusinessLogic testObject = (IBusinessLogic) ctx.getBean( &quot;businesslogicbean&quot; ); // Execute the public // method of the bean testObject.foo(); } }
  20. 20. Entendendo <ul><li>Uma vez que nossa MainApplication chama o método ctx.getBean() ela abre mão da instanciação e gerênciamento do Bean para o Spring </li></ul><ul><li>Controlando a inicialização do nosso objeto, o Spring todas as tarefas de gerenciamentos requeridas por aplicações J2EE </li></ul><ul><li>Isso, claro, antes que nosso objeto seja utilizado pela aplicação </li></ul>
  21. 21. Em prática <ul><li>springconfig.xml </li></ul><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;> <beans> <!-- Bean configuration --> <bean id=&quot;businesslogicbean&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot; > <property name=&quot;proxyInterfaces&quot; > <value> IBusinessLogic </value> </property> <property name=&quot;target&quot; > <ref local=&quot;beanTarget&quot; /> </property> </bean> <!-- Bean Classes --> <bean id=&quot;beanTarget&quot; class=&quot;BusinessLogic&quot; /> </beans>
  22. 22. Em prática <ul><li>Diagrama de seqüência </li></ul>
  23. 23. Em prática <ul><li>Implementando um Advice </li></ul>import java.lang.reflect.Method; import org.springframework.aop.MethodBeforeAdvice; public class TracingBeforeAdvice implements MethodBeforeAdvice { public void before(Method m, Object[] args, Object target) throws Throwable { System.out.println( &quot;Hello world! (by &quot; + this .getClass().getName() + &quot;)&quot; ); } }
  24. 24. Em prática <ul><li>Para acoplar o Advice a determinados joinpoints de nossa aplicação prescisamos acrescentar algumas declarações no springconfig.xml </li></ul>... <!-- Advisor pointcut definition for before advice --> <bean id=&quot;theTracingBeforeAdvisor&quot; class=&quot;org.springframework.aop.support.RegexpMethodPointcutAdvisor&quot; > <property name=&quot;advice&quot; > <ref local=&quot;theTracingBeforeAdvice&quot; /> </property> <property name=&quot;pattern&quot; > <value> .* </value> </property> </bean> <!-- Advice classes --> <bean id=&quot;theTracingBeforeAdvice&quot; class=&quot;TracingBeforeAdvice&quot; /> ... Aplicado por expressões regulares!
  25. 25. Em prática <ul><li>springconfig.xml (cont.) </li></ul><!-- Bean configuration --> <bean id=&quot;businesslogicbean&quot; class=&quot;org.springframework.aop.framework.ProxyFactoryBean&quot; > <property name=&quot;proxyInterfaces&quot; > <value> IBusinessLogic </value> </property> <property name=&quot;target&quot; > <ref local=&quot;beanTarget&quot; /> </property> <property name=&quot;interceptorNames&quot; > <list> <value> theTracingBeforeAdvisor </value> </list> </property> </bean>
  26. 26. Em prática <ul><li>springconfig.xml (cont.) </li></ul>Chamada transparente ao Advice do aspecto
  27. 27. E ainda <ul><li>Existem ainda outras formas de aplicar aspectos com o Spring </li></ul><ul><ul><li>AutoProxy: </li></ul></ul><ul><ul><ul><li>BeanNameAutoProxyCreator </li></ul></ul></ul><ul><ul><ul><li>DefaultAdvisorAutoProxyCreator </li></ul></ul></ul>
  28. 28. Conclusões <ul><li>AOP com o Spring tem sido aplicado a vários projetos </li></ul><ul><li>AOP melhora consideravelmente a qualidade de um sistema, aumentando a simplicidade do modelo </li></ul><ul><li>AOP está pegando  </li></ul>
  29. 29. Exercícios <ul><li>Rode o exemplo mostrado </li></ul><ul><li>Implemente um log para nosso sistema com AOP </li></ul>
  30. 30. Introdução a AOP + SpringAOP Jobson Ronan {jrjs@cin.ufpe.br}

×