Chengyu Sun California State University, Los Angeles

Slides:



Advertisements
Similar presentations
Spring Transaction & Spring AOP
Advertisements

AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
1 JAC : Aspect Oriented Programming in Java An article review by Yuval Nir and Limor Lahiani.
Aspect Oriented Programming - AspectJ Radhika Rajput.
Secure Systems Research Group - FAU Aspect Oriented Programming Carlos Oviedo Secure Systems Research Group.
Spring AOP Aspect Oriented Programming
Aspect-Oriented Programming In Eclipse ® Aspect-Oriented Programming in Eclipse with AspectJ Dr Helen Hawkins and Sian January.
Review Amit Shabtay. March 3rd, 2004 Object Oriented Design Course 2 Review What have we done during the course? Where to learn more? What is for the.
Review David Rabinowitz. March 3rd, 2004 Object Oriented Design Course 2 Review What have we done during the course? Which topics we have not discussed?
Spring Roo CS476 Aleksey Bukin Peter Lew. What is Roo? Productivity tool Allows for easy creation of Enterprise Java applications Runs alongside existing.
Copyright 2006, Codeguild, Inc Spring Framework Fundamentals March, 2006 Larry Hamel Codeguild, Inc.
Introduction to the Spring Framework Rajesh. Spring Mission Statement J2EE should be easier to use OO design is more important than any implementation.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Aspect Oriented Programming (AOP) in.NET Brent Krueger 12/20/13.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
Anti Orgla, Nortal AS Spring Framework
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development 1.
Modularizing Web Services Management with AOP María Agustina Cibrán, Bart Verheecke { Maria.Cibran, System and Software Engineering.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Spring Training 17/09/ Dependency Injection.
A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits.
A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
© Keren Kalif Advanced Java Topics Written by Keren Kalif, Edited by Liron Blecher.
Does not implement clone() method! public class Bar { … public Object clone() { … } Does not implement Cloneable interface!
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
Chapter 8: Aspect Oriented Programming Omar Meqdadi SE 3860 Lecture 8 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
Spring 프레임워크의 이해 4. Spring AOP 이해 및 활용 Grow up to be NHN 人 Spring – AOP 요구사항 !! 비즈니스 계층과 퍼시스턴스 계층의 모든 메써드 시작과 종료시 “ 메써드 시작 ”, “ 메써드 종료 ” 라는 Logging.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
AOP 개념 및 Spring 의 AOP 기능. Spring Framework – AOP 절차적 프로그래밍 OOP AOP.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring AOP – Part 2 Advanced Aspect-Oriented.
Aspect Oriented Programming Adlux Consultancy Services Pvt Ltd
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
Comparison of Different AOP Approaches Presented by: Xiaojing Wang.
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
Introduction to Yan Cui Aspect Oriented Programming by
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
Spring Framework BT Team 25/02/ Spring A lightweight framework that addresses each tier in a Web application. Presentation layer – An MVC framework.
Aspect-Oriented Software Development (AOSD)
L’origine dei mali: le dipendenze tra componenti Stefano Leli 14° Workshop DotNetMarche Venerdì 16 aprile
PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)
CS422 Principles of Database Systems JDBC and Embedded SQL Chengyu Sun California State University, Los Angeles.
Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Spring – Inversion of Control Chengyu Sun California State University, Los Angeles.
Callbacks and Interceptors. Contents  Session Beans Life Cycle  Interceptors.
AspectJ for Spring Developers
Aspect-Oriented Generation of the API Documentation for AspectJ
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
By Ru Shen Department of Computer Science UAlbany, 2008
Aspect-Oriented Programming
Chapter 12 Exception Handling and Text IO
Chengyu Sun California State University, Los Angeles
CS5220 Advanced Topics in Web Programming Spring – Web MVC
AOP in .NET Business Rules + Plumbing = Enterprise Software
JAsCo an Aspect-Oriented approach tailored for
CS5220 Advanced Topics in Web Programming Spring – Web MVC
Chengyu Sun California State University, Los Angeles
CS5220 Advanced Topics in Web Programming Angular – TypeScript
CS5220 Advanced Topics in Web Programming Angular – Services
CS520 Web Programming Spring – Aspect Oriented Programming
Leveraging ColdSpring To Make Better Applications
CS5220 Advanced Topics in Web Programming Angular – TypeScript
Aspect Oriented Programming
Chengyu Sun California State University, Los Angeles
CS4540 Special Topics in Web Development Introduction to .NET
Presentation transcript:

Chengyu Sun California State University, Los Angeles CS5220 Advanced Topics in Web Programming Spring – Aspect Oriented Programming Chengyu Sun California State University, Los Angeles

Spring Framework

Concerns User Management Product Management Order Management

Cross-Cutting Concerns Logging Transaction Management Security User Management Product Management Order Management

An Example of Transaction Rollback catch( SQLException e ) { System.err.println( e.getMessage() ); if( c != null ) { try { c.rollback(); } catch( SQLException ex ) { System.err.println( ex.getMessage() ); }

Aspect Oriented Programming Separate out cross-cutting concern code into their own classes or modules, called aspects.

Example: Logging LoggedTask1 and LoggedTask2 Both implement LoggedTask interface LoggedTask1 – mixes application code and logging code LoggedTask2 – only has application code

How Does it Work? class Foo { Object bar() {...} } run some code before bar() is called run some code after bar() is called

Proxy – Subclass class Foo1 extends Foo { Object bar() { // some code before super.bar() ... O o = super.bar(); // some code after super.bar(); return o; }

Proxy – Wrapper Class class Foo2 { private Foo foo; Object bar() { // some code before super.bar() ... Object o = foo.bar(); // some code after super.bar(); return o; }

Some AOP Terminology Target Proxy Proxy Interface Advice

Create Proxies Automatically -ProxyFactoryBean <bean id="loggedTask2" class=“cs520.spring.aop.LoggedTask2" /> <bean id="loggedTask2WithAdvice" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <list> <value>cs520.spring.log.LoggedTask</value> </list> </property> <property name="target" ref="loggedTask2" /> <property name="interceptorNames"> <value>loggingAdvice</value> </bean>

More AOP Terminology Join point: a point in the execution of the application where the advice can be plugged in Pointcut: A predicate that determines join points Introduction: adding new methods and/or fields to existing classes Weaving Compile time, class load time, or runtime

Spring AOP Advices are written in Java Pointcuts are defined in XML or annotation Supports only method join points Aspects are woven in at runtime Advisor = Advice + Pointcuts

Advice Types Type Interface Around org.aopalliance.intercept.MethodInterceptor Before org.springframework.aop.BeforeAdvice After org.springframework.aop.AfterReturningAdvice Throws org.springframework.aop.ThrowsAdvice

Use Interceptor public class LoggingInterceptor implements MethodInterceptor { public Object invoke( MethodInvocation invocation ) throws Throwable { // do something before method invocation … Object result = invocation.proceed(); // do something after method invocation return result; }

Configure Pointcuts NameMatchMethodPointcutAdvisor RegExpPointcutAdvisor <bean id="loggingAdvisor“ class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor"> <property name="mappedName" value="doSomething*" /> <property name="advice" ref="loggingInterceptor" /> </bean>

AOP Annotations Spring Framework Reference Documentation, Chapter 11.2

About AOP Good?? Bad??