Spring & AOP. Margus Jäger Lauri Tulmin

Size: px
Start display at page:

Download "Spring & AOP. Margus Jäger Lauri Tulmin"

Transcription

1 Spring & AOP Margus Jäger Lauri Tulmin 1

2 Sissejuhatus 3. peatükk raamatus Spring in Action 4. peatükk raamatus Professional Java Development with the Spring Framework Spring Spring AOP Võrdlus AspectJ ga 2

3 Spring 3

4 Spring Kergekaaluline (Lightweight) Kontrolli ümberpööramine (Inversion of control) Aspektidele orienteeritud (Aspect-oriented) Konteiner Raamistik (Framework) 4

5 Hello World näide 1 public interface IHello { public void sayhello(); public class Hello implements IHello { private IGreeting greeting; public void setgreeting(igreeting greeting) { this.greeting = greeting; public void sayhello() { System.out.println(greeting.getGreeting()); 5

6 Hello World näide 2 public interface IGreeting { public String getgreeting(); public class Greeting implements IGreeting { private String greeting; public String getgreeting() { return greeting; public void setgreeting(string greeting) { this.greeting = greeting; 6

7 Hello World näide 3 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" " <beans> <bean id="hello" class="hello"> <property name="greeting"> <ref local="greeting" /> </property> </bean> <bean id="greeting" class="greeting"> <property name="greeting"> <value>hello world</value> </property> </bean> </beans> 7

8 Hello World näide 4 public class Main { public static void main(string[] args) { Resource res = new FileSystemResource("beans.xml"); XmlBeanFactory factory = new XmlBeanFactory(res); IHello hello = (IHello)factory.getBean("hello"); hello.sayhello(); 8

9 Spring & AOP 9

10 Spring AOP Aspektid kirjutatakse javas Ühendpunktideks on meetodid Aspektide rakendamine programselt või deklaratiivselt Springi konfiguratsioonifailis 10

11 AOP Alliance Kõik Springis kasutatavad juhised realiseerivad AOP Alliance i spetsifitseeritud või neist päritud liideseid 11

12 Juhised Before After returning Around Throws Introduction 12

13 Around juhis public interface MethodInterceptor extends Interceptor { Object invoke(methodinvocation invocation) throws Throwable; 13

14 public class PerformanceInterceptor implements MethodInterceptor { { public Object invoke(methodinvocation method) throws Throwable long start = System.currentTimeMillis(); try { finally { Object result = method.proceed(); return result; long end = System.currentTimeMillis(); long timems = end - start; System.out.println("Method: " + method.tostring() + " took: " + timems +"ms."); 14

15 Before juhis public interface MethodBeforeAdvice extends BeforeAdvice { void before(method m, Object[] args, Object target) throws Throwable; 15

16 Before juhise näide public class CountingBeforeAdvice implements MethodBeforeAdvice { private int count; public void before(method m, Object[] args, Object target) { ++count; public int getcount() { return count; 16

17 After Returning juhis public interface AfterReturningAdvice extends Advice { void afterreturning(object returnvalue, Method m, Object[] args, Object target) throws Throwable; 17

18 After Returning juhise näide public class CountingAfterReturningAdvice implements AfterReturningAdvice { private int count; public void afterreturning (Object returnvalue, Method m, Object[] args, Object target) { ++count; public int getcount() { return count; 18

19 Throws juhis org.springframework.aop.throwsadvice afterthrowing ([Method, args, target,] Throwable) 19

20 Throws juhise näide public static class ServletThrowsAdviceWithArguments implements ThrowsAdvice { public void afterthrowing (Method m, Object[] args, Object target, ServletException ex) { // Do something with all arguments public void afterthrowing(remoteexception ex) throws Throwable { // Do something with remote exception 20

21 Lõikepunktid Ühendpunktid (JoinPoints) on Springis alati meetodid Lõikepunktid (Pointcuts) defineerivad, millistele meetoditele juhiseid rakendatakse 21

22 Lõikepunktid Springis org.springframework.aop.support.namematchmethodpointcut org.springframework.aop.support.dynamicmethodmatcherpointcut org.springframework.aop.staticmethodmatcherpointcut org.springframework.aop.support.jdkregexpmethodpointcut org.springframework.aop.support.perl5regexpmethodpointcut org.springframework.aop.support.controlflowpointcut org.springframework.aop.support.composablepointcut 22

23 NameMatchMethodPointcut klass NameMatchMethodPointcut addmethodname(string methodname) void setmappedname(string methodname) void setmappednames(string methodname) 23

24 NameMatchMethodPointcuti kasutamise näide Javas Pointcut pc = new NameMatchMethodPointcut().addMethodName("setAge").addMethodName("setName"); 24

25 Regulaaravaldistega lõikepunktid <bean id="settersandabsquatulatepointcut" class="org.springframework.aop.support.jdkregexpmethodpointcut"> <property name="patterns"> </bean> <list> <value>.*get.*</value> <value>.*absquatulate</value> </list> </property> 25

26 Staatiline (ei sõltu argumentidest) public class MyBeanPointcut extends StaticMethodMatcherPointcut { public boolean matches(method themethod, Class theclass) { return (MyBean.class.isAssignableFrom(theClass) && themethod.equals(...)); 26

27 Dünaamiline (arvestab argumente) public class MyBeanPointcut extends DynamicMethodMatcherPointcut { public boolean matches(method themethod, Class theclass, Object[] arguments) { boolean matches = false; if (MyBean.class.isAssignableFrom(theClass) && themethod.equals(...)) { if (arguments[0].equals("joe Smith")) { matches = true; return matches; 27

28 ControlFlowPointcut <bean id="servletpointcut" class="org.springframework.aop.support. ControlFlowPointcut"> <constructor-arg> <value>javax.servlet.http.httpservlet</value> </constructor-arg> </bean> 28

29 Tehted lõikepunktidega public static Pointcut union(pointcut a, Pointcut b) kas a või b public static Pointcut intersection(pointcut a, Pointcut b) nii a kui b 29

30 Juhtpunktid - Advisors (pakkuge hea tõlge) Ühendavad Springis lõikepunktid ja juhised aspektiks Võivad sisaldada lõikepunktide defineerimiseks vajalikke meetodeid (pole vaja lõikepunktide jaoks eraldi klasse defineerida) 30

31 DefaultPointcutAdvisor public class DefaultPointcutAdvisor { private Pointcut pointcut; private Advice advice; public Pointcut getpointcut() { return pointcut; public Advice getadvice() { return advice; public void setpointcut(pointcut pc) { pointcut = pc; public void setadvice(advice a) { advice = a; 31

32 DefaultPointcutAdvisor (2) <bean name ="myadvisor class="org.springframework.aop.support.default PointcutAdvisor"> <property name="pointcut"> <ref local="mypointcut"/> </property> <property name="advice"> <ref local="myadvice"/> </property> </bean> 32

33 NameMatchMethodPointcutAdvisor <bean name="advisor1" class="org.springframework.aop.support.namematchmethodpointcutadvisor"> <property name="advice" ref="beforeadvicea"/> <property name="mappedname" value= mymethod"/> </bean> 33

34 RegexpMethodPointcutAdvisor <bean id= advisor2" class="org.springframework.aop.support.regexpmethodpointcutadvisor"> <property name="advice"> <ref local="myadvice"/> </property> <property name="patterns"> <list> </list> </property> <value>.*set.*</value> <value>.*getname</value> </bean> 34

35 AOP realiseerimine Kompileerimisel (AspectJ) Klassi laadimisel Programmi käimisel (Spring) 35

36 Staatiline vs dünaamiline Statiline AOP - Kompileerimisel põimitakse aspektid java klassidesse - AspectJ Dünaamiline AOP - Aspektid põimitakse programmi töö ajal - Klasse pole vaja uuesti kompileerida - Aspektide jaoks vahendaja (proxy) - Spring 36

37 Vahendajad (Proxy) JDK Dynamic Proxy - Rakendatav objektidele, mille klassid realiseerivad liideseid CGLIB Proxy - Lennult genereeritakse antud klassi laiendav klass 37

38 ProxyFactoryBean Loob vahendaja-objeti, millele rakendatakse aspekte Saab siduda objektiga nii juhiseid (advice) kui juhtpunkte (advisor) 38

39 <bean id="mydependency1" class="org.springframework.aop.framework.proxyfactorybe an"> <property name="target"> <ref local="mydependencytarget"/> </property> <property name="interceptornames"> <list> <value>myadvice</value> <value>myadvisor</value> </list> </property> </bean> 39

40 Automaatsed vahendajad BeanNameAutoProxyCreator DefaultAdvisorAutoProxyCreator 40

41 <bean id="proxycreator" class="org.springframework.aop.framework.autoproxy.beannameautoproxycreator"> <property name="beannames"> <list> <value>foo*</value> <value>barbean</value> </list> </property> <property name="interceptornames"> <list> <value>advice</value> </list> </property> </bean> 41

42 DefaultAdvisorAutoProxyCreator Juhtpunkte rakendatakse kõikidele objektidele <bean id="aapc" class="org.springframework.aop.framework.autoproxy.defaultadvisorautoproxycreator"/ > 42

43 Spring AOP vs AspectJ 43

44 Spring ja AspectJ võrdlus Spring AOP Lihtne seadistada Käimise ajal AOP Alliance i liidesed Vähem võimalusi AspectJ Väheke keerulisem Kompileerimisel Eraldi programmeerimiskeel Rohkem võimalusi 44

45 Süntaks - Spring AOP (AOP Alliance) public class SimpleMethodInterceptor implements MethodInterceptor { public Object invoke(methodinvocation invocation) throws Throwable {... return invocation.proceed(); - AspectJ public aspect SimpleServiceAroundAspect { pointcut serviceexecution(): execution(public * ee.bus.*service.*(..)); Object around(): serviceexecution() {... return proceed(); 45

46 Spring AOP piirangud Ühenduspunktideks ainult meetodid Ilma CgLibita aspektid ainult liideste meetoditel private, final, static meetoditele ei saa aspekte panna Aspektid rakendatakse ainult konteineri poolt loodud objektidele 46

47 Valmis aspektid Transaktsioonid Puulimine ACEGI security 47

48 Jõudlus 48

49 Spring AOP ja AspectJ jõudlus 1 Million Method Invocations (Adding Numbers) Invocation Time [ms] Number of Aspects AspectJ (Before/After) AspcetJ (Around) Spring AOP autor: Rein Raudjärv 49

50 Küsimused 50

A short introduction to INF329. Spring AOP

A short introduction to INF329. Spring AOP A short introduction to INF329 Spring AOP Introduction to AOP AOP is an abbreviation for aspectoriented programming Aspect-oriented programming is a new paradigm in programming, seperating functionality

More information

AOP 101: Intro to Aspect Oriented Programming. Ernest Hill

AOP 101: Intro to Aspect Oriented Programming. Ernest Hill AOP 101: Intro to Aspect Oriented Programming ernesthill@earthlink.net AOP 101-1 AOP 101: Aspect Oriented Programming Goal of Software History of Programming Methodology Remaining Problem AOP to the Rescue

More information

DYNAMIC PROXY AND CLASSIC SPRING AOP

DYNAMIC PROXY AND CLASSIC SPRING AOP Module 8 DYNAMIC PROXY AND CLASSIC SPRING AOP Aspect-oriented programming (AOP) > Aspect-oriented programming (AOP) is a new methodology to complement traditional object-oriented programming (OOP). > The

More information

Information systems modeling. Tomasz Kubik

Information systems modeling. Tomasz Kubik Information systems modeling Tomasz Kubik Aspect-oriented programming, AOP Systems are composed of several components, each responsible for a specific piece of functionality. But often these components

More information

Enterprise AOP With the Spring Framework

Enterprise AOP With the Spring Framework Enterprise AOP With the Spring Framework Jürgen Höller VP & Distinguished Engineer, Interface21 Agenda Spring Core Container Spring AOP Framework AOP in Spring 2.0 Example: Transaction Advice What's Coming

More information

Spring. Paul Jensen Principal, Object Computing Inc.

Spring. Paul Jensen Principal, Object Computing Inc. Spring Paul Jensen Principal, Object Computing Inc. Spring Overview Lightweight Container Very loosely coupled Components widely reusable and separately packaged Created by Rod Johnson Based on Expert

More information

No Fluff, Just Stuff Anthology

No Fluff, Just Stuff Anthology Extracted from: No Fluff, Just Stuff Anthology The 2006 Edition This PDF file contains pages extracted from No Fluff, Just Stuff Anthology, published by the Pragmatic Bookshelf. For more information or

More information

Advanced Web Systems 10- Spring and AOP Transactions Ajax Introduction. A. Venturini

Advanced Web Systems 10- Spring and AOP Transactions Ajax Introduction. A. Venturini Advanced Web Systems 10- Spring and AOP Transactions Ajax Introduction A. Venturini Spring Architecture The seven modules of the Spring framework 2 Intro to Spring AOP In Spring, aspects are woven into

More information

XML SCHEMA BASED AOP WITH SPRING

XML SCHEMA BASED AOP WITH SPRING XML SCHEMA BASED AOP WITH SPRING http://www.tutorialspoint.com/spring/schema_based_aop_appoach.htm Copyright tutorialspoint.com To use the aop namespace tags described in this section, you need to import

More information

Seasar2.3. Yasuo Higa Seasar Foundation/Chief Committer Translated by:h.ozawa

Seasar2.3. Yasuo Higa Seasar Foundation/Chief Committer   Translated by:h.ozawa Seasar2.3 Yasuo Higa Seasar Foundation/Chief Committer http://www.seasar.org/en 1 I want to ask this question to every developer in the world, DO YOU REALLY WANT TO WRITE CONFIGURATION FILES? Seasar2 saves

More information

Aspect-Oriented Programming

Aspect-Oriented Programming Aspect-Oriented Programming Based on the Example of AspectJ Prof. Harald Gall University of Zurich, Switzerland software evolution & architecture lab AOP is kind of a complicated one for me ( ) the idea

More information

Java AOP in Spring 2.0 Rob Harrop, Interface21 Ltd.

Java AOP in Spring 2.0 Rob Harrop, Interface21 Ltd. Java AOP in Spring 2.0 Rob Harrop, Interface21 Ltd. Agenda What's new in Spring 2.0 Simplifying transaction configuration @AspectJ Aspects Writing pointcuts with AspectJ Using AspectJ aspects Aspects and

More information

JBoss AOP Reference Documentation

JBoss AOP Reference Documentation JBoss AOP - Aspect-Oriented Framework for Java JBoss AOP Reference Documentation ISBN: Publication date: JBoss AOP - Aspect-Oriented F... JBoss AOP - Aspect-Oriented Framework for Java: JBoss AOP Reference

More information

G l a r i m y Training on. Spring Framework

G l a r i m y Training on. Spring Framework http://www.glarimy.com Training on Spring Framework Krishna Mohan Koyya Technology Consultant & Corporate Trainer krishna@glarimy.com www.glarimy.com 091-9731 4231 66 [Visit the portal for latest version

More information

Introducing the Spring framework

Introducing the Spring framework Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Introducing the Spring framework Marco Piccioni Yet another framework? It addresses areas that other frameworks

More information

Motivation. Ability is what you're capable of doing. Motivation determines what you do. Attitude determines how well you do it.

Motivation. Ability is what you're capable of doing. Motivation determines what you do. Attitude determines how well you do it. Aspects in AspectJ Motivation Aspect Oriented Programming: a brief introduction to terminology Installation Experimentation AspectJ some details AspectJ things you should know about but we dont have time

More information

Spring Soup with OC4J and MBeans

Spring Soup with OC4J and MBeans Spring Soup with OC4J and MBeans Steve Button 4/27/2007 The Spring Framework includes support for dynamically exposing Spring Beans as managed resources (MBeans) in a JMX environment. Exposing Spring Beans

More information

Spring Framework. Christoph Pickl

Spring Framework. Christoph Pickl Spring Framework Christoph Pickl agenda 1. short introduction 2. basic declaration 3. medieval times 4. advanced features 5. demo short introduction common tool stack Log4j Maven Spring Code Checkstyle

More information

Your required reading begins below...

Your required reading begins below... March 2006-- Issue 9.2 This month's articles: Developing Spring applications for WebSphere Application Server: Part 1: An introduction to Spring Locking strategies for database access Web services security

More information

Take Control with AspectJ

Take Control with AspectJ Hermod Opstvedt Chief Architect DnB NOR ITUD Common components Hermod Opstvedt Slide 1 What is AspectJ? Aspect-oriented programming (AOP) is a technique for improving separation of concerns. Crosscutting

More information

Chapitre 6 Programmation orientée aspect (AOP)

Chapitre 6 Programmation orientée aspect (AOP) 6 Programmation orientée aspect (AOP) 2I1AC3 : Génie logiciel et Patrons de conception Régis Clouard, ENSICAEN - GREYC «L'homme est le meilleur ordinateur que l'on puisse embarquer dans un engin spatial...

More information

Spring Interview Questions

Spring Interview Questions Spring Interview Questions By Srinivas Short description: Spring Interview Questions for the Developers. @2016 Attune World Wide All right reserved. www.attuneww.com Contents Contents 1. Preface 1.1. About

More information

@ASPECTJ BASED AOP WITH SPRING

@ASPECTJ BASED AOP WITH SPRING @ASPECTJ BASED AOP WITH SPRING http://www.tutorialspoint.com/spring/aspectj_based_aop_appoach.htm Copyright tutorialspoint.com @AspectJ refers to a style of declaring aspects as regular Java classes annotated

More information

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum Copyright Descriptor Systems, 2001-2010. Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum Copyright Descriptor Systems, 2001-2010. Course materials

More information

Fast Track to Spring 3 and Spring MVC / Web Flow

Fast Track to Spring 3 and Spring MVC / Web Flow Duration: 5 days Fast Track to Spring 3 and Spring MVC / Web Flow Description Spring is a lightweight Java framework for building enterprise applications. Its Core module allows you to manage the lifecycle

More information

S AMPLE CHAPTER SPRING IN ACTION. Craig Walls Ryan Breidenbach MANNING

S AMPLE CHAPTER SPRING IN ACTION. Craig Walls Ryan Breidenbach MANNING S AMPLE CHAPTER SPRING IN ACTION Craig Walls Ryan Breidenbach MANNING Spring in Action by Craig Walls and Ryan Breidenbach Sample Chapter 1 Copyright 2005 Manning Publications PART 1 SPRING ESSENTIALS...1

More information

Dan Hayes. October 27, 2005

Dan Hayes. October 27, 2005 Spring Introduction and Dependency Injection Dan Hayes October 27, 2005 Agenda Introduction to Spring The BeanFactory The Application Context Inversion of Control Bean Lifecyle and Callbacks Introduction

More information

Spring & Hibernate. Knowledge of database. And basic Knowledge of web application development. Module 1: Spring Basics

Spring & Hibernate. Knowledge of database. And basic Knowledge of web application development. Module 1: Spring Basics Spring & Hibernate Overview: The spring framework is an application framework that provides a lightweight container that supports the creation of simple-to-complex components in a non-invasive fashion.

More information

Advances in Aspect-oriented Programming

Advances in Aspect-oriented Programming Advances in Aspect-oriented Programming Ramnivas Laddad Principal, Interface21 Author, AspectJ in Action ramnivas.laddad@interface21.com About Speaker Principal at Interface21 Specializing in aspect-oriented

More information

SPRING MOCK TEST SPRING MOCK TEST I

SPRING MOCK TEST SPRING MOCK TEST I http://www.tutorialspoint.com SPRING MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Spring Framework. You can download these sample mock tests at

More information

Chapter 4. Defining Classes I

Chapter 4. Defining Classes I Chapter 4 Defining Classes I Introduction Classes are the most important language feature that make object-oriented programming (OOP) possible Programming in Java consists of defining a number of classes

More information

Objekt-orienteeritud programmeerimine MTAT (6 EAP) 5. Loeng. H e l l e H e i n h e l l e. h e i e e

Objekt-orienteeritud programmeerimine MTAT (6 EAP) 5. Loeng. H e l l e H e i n h e l l e. h e i e e Objekt-orienteeritud programmeerimine MTAT.03.130 (6 EAP) 5. Loeng H e l l e H e i n h e l l e. h e i n @ut. e e Täna loengus: Abstraktsed klassid Liidesed Mähisklassid 2 Abstraktsed klassid Meetodit nimetatakse

More information

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP 2013 Empowering Innovation DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP contact@dninfotech.com www.dninfotech.com 1 JAVA 500: Core JAVA Java Programming Overview Applications Compiler Class Libraries

More information

com Spring + Spring-MVC + Spring-Boot + Design Pattern + XML + JMS Hibernate + Struts + Web Services = 8000/-

com Spring + Spring-MVC + Spring-Boot + Design Pattern + XML + JMS Hibernate + Struts + Web Services = 8000/- www.javabykiran. com 8888809416 8888558802 Spring + Spring-MVC + Spring-Boot + Design Pattern + XML + JMS Hibernate + Struts + Web Services = 8000/- Java by Kiran J2EE SYLLABUS Servlet JSP XML Servlet

More information

Class, Variable, Constructor, Object, Method Questions

Class, Variable, Constructor, Object, Method Questions Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx

More information

So, What is an Aspect?

So, What is an Aspect? Introduction to AspectJ Aspect-oriented paradigm AspectJ constructs Types of Join Points Primitive Lexical designators Type designators Control flow Types of Advice Before After Around Receptions Join

More information

JBoss AOP - Aspect-Oriented Framework for Java

JBoss AOP - Aspect-Oriented Framework for Java JBoss AOP - Aspect-Oriented Framework for Java JBoss AOP Reference Documentation 1.5 Table of Contents Preface...v 1. Terms...1 1.1. Overview...1 2. Implementing Aspects...2 2.1. Overview...2 2.2. Invocation

More information

Chapter 5 Methods. public class FirstMethod { public static void main(string[] args) { double x= -2.0, y; for (int i = 1; i <= 5; i++ ) { y = f( x );

Chapter 5 Methods. public class FirstMethod { public static void main(string[] args) { double x= -2.0, y; for (int i = 1; i <= 5; i++ ) { y = f( x ); Chapter 5 Methods Sections Pages Review Questions Programming Exercises 5.1 5.11 142 166 1 18 2 22 (evens), 30 Method Example 1. This is of a main() method using a another method, f. public class FirstMethod

More information

Dependency Injection. Kenneth M. Anderson University of Colorado, Boulder Lecture 30 CSCI 4448/ /08/11

Dependency Injection. Kenneth M. Anderson University of Colorado, Boulder Lecture 30 CSCI 4448/ /08/11 Dependency Injection Kenneth M. Anderson University of Colorado, Boulder Lecture 30 CSCI 4448/5448 12/08/11 1 Goals of the Lecture Introduce the topic of dependency injection See examples using the Spring

More information

Aspects in AspectJ. October 2013 CSC5021: AspectJ (J P Gibson) 1

Aspects in AspectJ. October 2013 CSC5021: AspectJ (J P Gibson) 1 Aspects in AspectJ Motivation Aspect Oriented Programming: a brief introduction to terminology Installation Experimentation AspectJ some details AspectJ thingsyoushouldknow about but wedont have time to

More information

SCALA AND ASPECTJ. Approaching Modularizing of Crosscutting. Ramnivas Laddad. Concerns. ramnivas

SCALA AND ASPECTJ. Approaching Modularizing of Crosscutting. Ramnivas Laddad. Concerns. ramnivas SCALA AND ASPECTJ Approaching Modularizing of Crosscutting Concerns Ramnivas Laddad ramnivas ramnivas!com @ramnivas Copyright Ramnivas Laddad. All rights reserved. @ramnivas Spring framework committer

More information

Course 7 25 November Adrian Iftene

Course 7 25 November Adrian Iftene Course 7 25 November 2013 Adrian Iftene adiftene@info.uaic.ro 1 Recapitulation course 6 AOP AOP Profiler Tracing Pooling PostSharp Spring Framework Runtime Verification Model Checking MOP Java MOP 2 Concern

More information

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: reflection

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: reflection Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: reflection Outline Introductory detour: quines Basic reflection Built-in features Introspection Reflective method invocation

More information

CS505: Distributed Systems

CS505: Distributed Systems Department of Computer Science CS505: Distributed Systems Lecture 8: Programming Support Introduction Issues Data interoperability Big vs. little endian Types more generally Failures Non-masking/handling:

More information

Milleks tüübid? Mida teeb järgmine programmijupp? x 1 := "Pii siinus on : "; x 2 := ; printx 2 ; print(sin(x 1 ));

Milleks tüübid? Mida teeb järgmine programmijupp? x 1 := Pii siinus on : ; x 2 := ; printx 2 ; print(sin(x 1 )); Milleks tüübid? Mida teeb järgmine programmijupp? x 1 := "Pii siinus on : "; x 2 := 3.1415926;... printx 2 ; print(sin(x 1 )); Ei tea (loodetavasti siiski mitte midagi väga hullu :-) VARMO VENE 1 Milleks

More information

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question) CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers

More information

Agenda: Discussion Week 7. May 11, 2009

Agenda: Discussion Week 7. May 11, 2009 Agenda: Discussion Week 7 Method signatures Static vs. instance compareto Exceptions Interfaces 2 D arrays Recursion varargs enum Suggestions? May 11, 2009 Method signatures [protection] [static] [return

More information

Spring and Coherence Recipes

Spring and Coherence Recipes Spring and Coherence Recipes David Whitmarsh, Phil Wheeler December 4, 2013 Outline 1 IoC Frameworks 2 Problems with Spring and Coherence 3 ApplicationContexts 4 LifeCycle 5 Bean Definition and Injection

More information

AOP Tutorial. Written By: Muhammad Asif. Department of Computer Science, Virtual University of Pakistan

AOP Tutorial. Written By: Muhammad Asif. Department of Computer Science, Virtual University of Pakistan AOP Tutorial Written By: Muhammad Asif. Department of Computer Science, Virtual University of Pakistan Table of Contents 1.0 INTRODUCTION... 3 2.0 SCOPE AND OBJECTIVE... 4 3.0 MOTIVATION... 5 4.0 HISTORY...

More information

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003 1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to

More information

Le L c e t c ur u e e 5 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Exception Handling

Le L c e t c ur u e e 5 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Exception Handling Course Name: Advanced Java Lecture 5 Topics to be covered Exception Handling Exception HandlingHandlingIntroduction An exception is an abnormal condition that arises in a code sequence at run time A Java

More information

Desarrollo de Aplicaciones Web Empresariales con Spring 4

Desarrollo de Aplicaciones Web Empresariales con Spring 4 Desarrollo de Aplicaciones Web Empresariales con Spring 4 Referencia JJD 296 Duración (horas) 30 Última actualización 8 marzo 2018 Modalidades Presencial, OpenClass, a medida Introducción Over the years,

More information

Dependency Injection and Spring. INF5750/ Lecture 2 (Part II)

Dependency Injection and Spring. INF5750/ Lecture 2 (Part II) Dependency Injection and Spring INF5750/9750 - Lecture 2 (Part II) Problem area Large software contains huge number of classes that work together How to wire classes together? With a kind of loose coupling,

More information

Support for Distributed Adaptations in Aspect-Oriented Middleware

Support for Distributed Adaptations in Aspect-Oriented Middleware Support for Distributed Adaptations in Aspect-Oriented Middleware Eddy Truyen Nico Janssens Frans Sanen Wouter Joosen DistriNet, Dept. of Computer Science, K.U.Leuven Celestijnenlaan 200A B-3001 Leuven,

More information

Administration. Exceptions. Leftovers. Agenda. When Things Go Wrong. Handling Errors. CS 99 Summer 2000 Michael Clarkson Lecture 11

Administration. Exceptions. Leftovers. Agenda. When Things Go Wrong. Handling Errors. CS 99 Summer 2000 Michael Clarkson Lecture 11 Administration Exceptions CS 99 Summer 2000 Michael Clarkson Lecture 11 Lab 10 due tomorrow No lab tomorrow Work on final projects Remaining office hours Rick: today 2-3 Michael: Thursday 10-noon, Monday

More information

Aspect Oriented Programming with AspectJ. Ted Leung Sauria Associates, LLC

Aspect Oriented Programming with AspectJ. Ted Leung Sauria Associates, LLC Aspect Oriented Programming with AspectJ Ted Leung Sauria Associates, LLC twl@sauria.com Overview Why do we need AOP? What is AOP AspectJ Why do we need AOP? Modular designs are not cut and dried Responsibilities

More information

APTE: Automated Pointcut Testing for AspectJ Programs

APTE: Automated Pointcut Testing for AspectJ Programs APTE: Automated Pointcut Testing for AspectJ Programs Prasanth Anbalagan Department of Computer Science North Carolina State University Raleigh, NC 27695 panbala@ncsu.edu Tao Xie Department of Computer

More information

Lecture 1: Object Oriented Programming. Muhammad Hafeez Javed

Lecture 1: Object Oriented Programming. Muhammad Hafeez Javed Lecture 1: Object Oriented Programming Muhammad Hafeez Javed www.rmhjaved.com Procedural vs. Object-Oriented Programming The unit in procedural programming is function, and unit in object-oriented programming

More information

This tutorial will take you through simple and practical approaches while learning AOP framework provided by Spring.

This tutorial will take you through simple and practical approaches while learning AOP framework provided by Spring. About the Tutorial One of the key components of Spring Framework is the Aspect Oriented Programming (AOP) framework. Aspect Oriented Programming entails breaking down program logic into distinct parts

More information

Java and C# in Depth

Java and C# in Depth Chair of Software Engineering Java and C# in Depth Carlo A. Furia, Marco Piccioni, Bertrand Meyer Exercise Session Week 4 Chair of Software Engineering Don t forget to form project groups by tomorrow (March

More information

The Spring Framework for J2EE

The Spring Framework for J2EE The Spring Framework for J2EE Dan Hayes Chariot Solutions March 22, 2005 Agenda Introduction to the Spring Framework Inversion of Control and AOP* Concepts The Spring Bean Container Spring in the Business

More information

Program Transformation with Reflective and Aspect-Oriented Programming

Program Transformation with Reflective and Aspect-Oriented Programming Program Transformation with Reflective and Aspect-Oriented Programming Shigeru Chiba Dept. of Mathematical and Computing Sciences Tokyo Institute of Technology, Japan Abstract. A meta-programming technique

More information

Course 6 7 November Adrian Iftene

Course 6 7 November Adrian Iftene Course 6 7 November 2016 Adrian Iftene adiftene@info.uaic.ro 1 Recapitulation course 5 BPMN AOP AOP Cross cutting concerns pointcuts advice AspectJ Examples In C#: NKalore 2 BPMN Elements Examples AOP

More information

Comp 248 Introduction to Programming Chapter 4 - Defining Classes Part A

Comp 248 Introduction to Programming Chapter 4 - Defining Classes Part A Comp 248 Introduction to Programming Chapter 4 - Defining Classes Part A Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia University, Montreal, Canada These slides has been

More information

Call: JSP Spring Hibernate Webservice Course Content:35-40hours Course Outline

Call: JSP Spring Hibernate Webservice Course Content:35-40hours Course Outline JSP Spring Hibernate Webservice Course Content:35-40hours Course Outline Advanced Java Database Programming JDBC overview SQL- Structured Query Language JDBC Programming Concepts Query Execution Scrollable

More information

CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

Programming Dynamic Features and Monitoring Distributed Software Systems

Programming Dynamic Features and Monitoring Distributed Software Systems DST Summer 2018, Lecture 3 Programming Dynamic Features and Monitoring Distributed Software Systems Hong-Linh Truong Faculty of Informatics, TU Wien hong-linh.truong@tuwien.ac.at http://www.infosys.tuwien.ac.at/staff/truong

More information

Aspect-Oriented Programming and AspectJ

Aspect-Oriented Programming and AspectJ What is Aspect-Oriented Programming? Many possible answers: a fad Aspect-Oriented Programming and AspectJ Aspect-oriented programming is a common buzzword lately Papers from ECOOP 1997 (early overview

More information

Variables and Java vs C++

Variables and Java vs C++ Variables and Java vs C++ 1 What can be improved? (variables) public void godirection(string directionname) { boolean wenttoroom = false; for (Direction direction : currentroom.getdirections()) { if (direction.getdirectionname().equalsignorecase(directionname))

More information

Assertions, pre/postconditions

Assertions, pre/postconditions Programming as a contract Assertions, pre/postconditions Assertions: Section 4.2 in Savitch (p. 239) Specifying what each method does q Specify it in a comment before method's header Precondition q What

More information

Introduction to Programming (Java) 4/12

Introduction to Programming (Java) 4/12 Introduction to Programming (Java) 4/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

More information

Making Java more dynamic: runtime code generation for the JVM

Making Java more dynamic: runtime code generation for the JVM Making Java more dynamic: runtime code generation for the JVM The talk was way too high-level. I wish the speaker would have explained more technical details! This was way too low-level. I did not understand

More information

What is AOP? Business Logic Requirements Concern Identifier Security Logging (Laddad, 2003, p. 9) What is AOP? Non-AOP implementation of crosscutting

What is AOP? Business Logic Requirements Concern Identifier Security Logging (Laddad, 2003, p. 9) What is AOP? Non-AOP implementation of crosscutting Aspect Oriented Programming Todd A. Whittaker Franklin University whittakt@franklin.edu What is AOP? Addresses crosscutting concerns Requirements analysis leads to identification of concerns in a software

More information

PASS4TEST IT 인증시험덤프전문사이트

PASS4TEST IT 인증시험덤프전문사이트 PASS4TEST IT 인증시험덤프전문사이트 http://www.pass4test.net 일년동안무료업데이트 Exam : 1z0-809 Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z0-809 Exam's Question and Answers 1 from

More information

Introduction to Aspect-Oriented Programming

Introduction to Aspect-Oriented Programming Introduction to Aspect-Oriented Programming Martin Giese Chalmers University of Technology Göteborg, Sweden AOP Course 2003 p.1/33 AspectJ Idioms and Patterns AOP Course 2003 p.2/33 Sources These idioms

More information

ADVANCED JAVA TRAINING IN BANGALORE

ADVANCED JAVA TRAINING IN BANGALORE ADVANCED JAVA TRAINING IN BANGALORE TIB ACADEMY #5/3 BEML LAYOUT, VARATHUR MAIN ROAD KUNDALAHALLI GATE, BANGALORE 560066 PH: +91-9513332301/2302 www.traininginbangalore.com 2EE Training Syllabus Java EE

More information

Flexible Calling Context Reification for Aspect-Oriented Programming

Flexible Calling Context Reification for Aspect-Oriented Programming Flexible Calling Context Reification for Aspect-Oriented Programming Alex Villazón Faculty of Informatics University of Lugano Switzerland alex.villazon@lu.unisi.ch Walter Binder Faculty of Informatics

More information

JML and Aspects: The Benefits of

JML and Aspects: The Benefits of JML and Aspects: The Benefits of Instrumenting JML Features with AspectJ Henrique Rebêlo Sérgio Soares Ricardo Lima Paulo Borba Márcio Cornélio Java Modeling Language Formal specification language for

More information

COURSE DETAILS: CORE AND ADVANCE JAVA Core Java

COURSE DETAILS: CORE AND ADVANCE JAVA Core Java COURSE DETAILS: CORE AND ADVANCE JAVA Core Java 1. Object Oriented Concept Object Oriented Programming & its Concepts Classes and Objects Aggregation and Composition Static and Dynamic Binding Abstract

More information

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods

More information

CS193k, Stanford Handout #12. Threads 4 / RMI

CS193k, Stanford Handout #12. Threads 4 / RMI CS193k, Stanford Handout #12 Spring, 99-00 Nick Parlante Threads 4 / RMI Semaphore1 Semaphore1 from last time uses the count in a precise way to know exactly how many threads are waiting. In this way,

More information

Object Oriented Programming 2015/16. Final Exam June 28, 2016

Object Oriented Programming 2015/16. Final Exam June 28, 2016 Object Oriented Programming 2015/16 Final Exam June 28, 2016 Directions (read carefully): CLEARLY print your name and ID on every page. The exam contains 8 pages divided into 4 parts. Make sure you have

More information

Selected Java Topics

Selected Java Topics Selected Java Topics Introduction Basic Types, Objects and Pointers Modifiers Abstract Classes and Interfaces Exceptions and Runtime Exceptions Static Variables and Static Methods Type Safe Constants Swings

More information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University 9/5/6 CS Introduction to Computing II Wayne Snyder Department Boston University Today: Arrays (D and D) Methods Program structure Fields vs local variables Next time: Program structure continued: Classes

More information

XmlHttpRequest asemel võib olla vajalik objekt XDomainRequest

XmlHttpRequest asemel võib olla vajalik objekt XDomainRequest 1 2 3 XmlHttpRequest asemel võib olla vajalik objekt XDomainRequest 4 5 6 7 8 https://www.trustwave.com/global-security-report http://redmondmag.com/articles/2012/03/12/user-password-not-sophisticated.aspx

More information

JBossCache: an In-Memory Replicated Transactional Cache

JBossCache: an In-Memory Replicated Transactional Cache JBossCache: an In-Memory Replicated Transactional Cache Bela Ban (bela@jboss.org) - Lead JGroups / JBossCache Ben Wang (bwang@jboss.org) - Lead JBossCacheAOP JBoss Inc http://www.jboss.org 09/22/04 1 Goal

More information

COE318 Lecture Notes Week 10 (Nov 7, 2011)

COE318 Lecture Notes Week 10 (Nov 7, 2011) COE318 Software Systems Lecture Notes: Week 10 1 of 5 COE318 Lecture Notes Week 10 (Nov 7, 2011) Topics More about exceptions References Head First Java: Chapter 11 (Risky Behavior) The Java Tutorial:

More information

Puudub protseduur. Protseduuri nimi võib olla valesti kirjutatud. Protseduuri (või funktsiooni) poole pöördumisel on vähem argumente kui vaja.

Puudub protseduur. Protseduuri nimi võib olla valesti kirjutatud. Protseduuri (või funktsiooni) poole pöördumisel on vähem argumente kui vaja. Puudub protseduur. Protseduuri nimi võib olla valesti kirjutatud. Sub prog1() Msgox "Tere" Sub prog2() a = si(1) Protseduuri (või funktsiooni) poole pöördumisel on vähem argumente kui vaja. a = Sin() Protseduuri

More information

Introduction to Spring Framework: Hibernate, Web MVC & REST

Introduction to Spring Framework: Hibernate, Web MVC & REST Introduction to Spring Framework: Hibernate, Web MVC & REST Course domain: Software Engineering Number of modules: 1 Duration of the course: 50 hours Sofia, 2017 Copyright 2003-2017 IPT Intellectual Products

More information

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018 Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment

More information

University of Palestine. Mid Exam Total Grade: 100

University of Palestine. Mid Exam Total Grade: 100 First Question No. of Branches (5) A) Choose the correct answer: 1. If we type: system.out.println( a ); in the main() method, what will be the result? int a=12; //in the global space... void f() { int

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

Struts: Struts 1.x. Introduction. Enterprise Application

Struts: Struts 1.x. Introduction. Enterprise Application Struts: Introduction Enterprise Application System logical layers a) Presentation layer b) Business processing layer c) Data Storage and access layer System Architecture a) 1-tier Architecture b) 2-tier

More information

JAVA Programming Language Homework I - OO concept

JAVA Programming Language Homework I - OO concept JAVA Programming Language Homework I - OO concept Student ID: Name: 1. Which of the following techniques can be used to prevent the instantiation of a class by any code outside of the class? A. Declare

More information

3 GluonJ. 1 GluonJ Web. {rei, DAO. GluonJ Web. GluonJ. glue DAO. glue 1 DAO DAO. ( AOP) AspectJ [6] [7] DAO.

3 GluonJ. 1 GluonJ Web. {rei, DAO. GluonJ Web. GluonJ. glue DAO. glue 1 DAO DAO. ( AOP) AspectJ [6] [7] DAO. GluonJ {rei, chiba@csg.is.titech.ac.jp GluonJ GluonJ AOP GluonJ GluonJ AspectJ GluonJ 1 GluonJ Web AOP GluonJ Web glue GluonJ ( DAO) DAO glue 1 DAO DAO ( AOP) AspectJ [6] [7] DAO Web 2 AOP DAO 1 DAO AOP

More information

Aspect Oriented Programming

Aspect Oriented Programming 1 Aspect Oriented Programming Programming Languages Seminar Presenter: Barış Aktemur University of Illinois 18 Feb. 2004 Mostly taken from Bedir Tekinerdogan s slides Outline Introduction Problems Terminology

More information

Lecture 10 Declarations and Scope

Lecture 10 Declarations and Scope Lecture 10 Declarations and Scope Declarations and Scope We have seen numerous qualifiers when defining methods and variables public private static final (we'll talk about protected when formally addressing

More information

Computer Science II (20082) Week 1: Review and Inheritance

Computer Science II (20082) Week 1: Review and Inheritance Computer Science II 4003-232-08 (20082) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Syntax and Semantics of Formal (e.g. Programming) Languages Syntax

More information

Lec 3. Compilers, Debugging, Hello World, and Variables

Lec 3. Compilers, Debugging, Hello World, and Variables Lec 3 Compilers, Debugging, Hello World, and Variables Announcements First book reading due tonight at midnight Complete 80% of all activities to get 100% HW1 due Saturday at midnight Lab hours posted

More information