Your SlideShare is downloading. ×
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Spring AOP @ DevClub.eu
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Spring AOP @ DevClub.eu

1,116

Published on

General introduction into Aspect-Oriented programming and small overview to its implementation in Spring. This presentation was made at DevClub.eu gathering in Tallinn.

General introduction into Aspect-Oriented programming and small overview to its implementation in Spring. This presentation was made at DevClub.eu gathering in Tallinn.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,116
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
25
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • -- Разделение ответсвенности ( Tangling – переплетение) -- Scattering – рассеивание, ведёт к дупликации
  • -- Tangling – переплетение -- Scattering – рассеивание, ведёт к дупликации
  • Transcript

    • 1. A spect O riented P rogramming using Spring Framework Arseni Grigorjev arsenikum[gmail.com]
    • 2. Me
      • Server side Java (~5y)
      • Aqris Software
      • Online gambling
    • 3. Simple service method
      • public class SimpleService {
      • public List getCustomerOrders( long operatorId, long customerId) {
      • List result;
      • long start = System. currentTimeMillis();
      • if (!hasPermissions(operatorId)) {
      • throw new NotAuthorizedException();
      • }
      • try {
        • ordersCache.getOrders(customerId);
        • if (result == null ) {
        • logger.info( "going to fetch orders for " + customerId);
        • result = customerDao.getOrders(customerId);
        • logger.info( "fetched orders for " + customerId + ": " + result);
        • ordersCache.putOrders(customerId, result);
        • }
      • } catch (CusstomerNotFoundException e) {
      • logger.error( "Customer " + customerId + " not found" , e);
      • result = null ;
      • }
      • long end = System. currentTimeMillis();
      • logger.debug( "method took " + (end - start) + " ms" );
      • return result;
      • }
      • }
      + authorization + error handling + performance monitoring + caching + logging
    • 4.  
    • 5. Aspect Oriented Programming
      • A spect O riented P rogramming (AOP) enables modularization of cross-cutting concerns
        • Separation of Concerns principle – no code tangling
        • 1:1 principle – no code scattering
    • 6. Cross-Cutting Concerns Examples
      • Logging and Tracing
      • Transaction Management
      • Security
      • Caching
      • Error Handling
      • Performance Monitoring
      • Custom Business Rules
    • 7. System Evolution: Conventional
    • 8. How AOP Works
      • Write your mainline application logic
      • Write aspects to implement cross-cutting concerns
      • Bind it all together
    • 9. System Evolution: AOP Based
    • 10. Leading AOP Technologies
      • AspectJ
        • 1995, original AOP technology
        • Offers a full Aspect Oriented Programming language
        • Modifies byte code to add aspects into your application!
    • 11. Leading AOP Technologies (2)
      • Spring AOP
        • Uses dynamic proxies to add aspects into your application
        • Only spring beans can be advised
        • Uses some of AspectJ expression syntax
    • 12. Core AOP Concepts
      • Join Point
        • A point of execution of a program such as method call or field assignment
      • Pointcut
        • An expression that selects one or more Join Points
      • Advice
        • Code to be executed at a Join Point that has been selected by a Pointcut
      • Aspect
        • A module that encapsulates Pointcuts and Advice
    • 13. Spring AOP Example
      • Business logic:
      public class SimpleService { … public List getCustomerOrders( long operatorId, long customerId) { return customerDao.getOrders(customerId); } … }
    • 14. Spring AOP Example (2)
      • Performance tracing aspect:
    • 15. Spring AOP Example (3)
      • Configure the Aspect as a Bean:
      <beans> <aop:aspectj-autoproxy> <aop:include name=“performanceTracer” /> </aop:aspectj-autoproxy> <bean id=“performanceTracer” class=“ com.foo.bar. PerformanceTracer ” /> </beans>
    • 16. Advice Types
      • @Around
      • @Before
      • @After
      • @AfterReturning
      • @AfterThrowing
    • 17. SpringSource Tool Suite AOP Support
    • 18. SpringSource Tools Suite AOP Support (2)
    • 19. Useful Links
      • Aspect Oriented Programming with Spring
        • http://static.springsource.org/spring/docs/2.5.x/reference/aop.html
        • Lots of examples
        • Highlights on AspectJ syntax
      • SpringSource Tool Suite:
        • http://www.springsource.com/products/sts
        • Eclipse IDE with Spring (and Spring AOP) support
    • 20. Thank You!
      • Questions?

    ×