Aspect oriented programming (AOP) allows encapsulation of cross-cutting concerns in separate units called aspects. This modularizes functionality that spans multiple classes. Spring provides AOP support through @AspectJ annotations or XML configuration. Advice like before, after returning, and around intercept method invocations defined by pointcut expressions. This separates concerns and promotes loosely coupled and reusable code.
The document discusses elementary sorting algorithms including selection sort, insertion sort, and shellsort. It provides examples of how sorting can be used to sort various data types like numbers, strings, and files by implementing callbacks that allow the sorting routines to compare objects. The key point is that sorting routines do not need specific information about the types of objects being sorted since clients can pass a compare method through an interface like Comparable.
Important java programs(collection+file)Alok Kumar
The document contains 6 Java programming questions and solutions:
1. A program to find unique and duplicate items in an array.
2. A Product class with properties and methods to sort objects.
3. A program to merge contents of two text files into a third file.
4. A program to count the occurrences of specific words in a file.
5. A program to read a file, add contents to an ArrayList, and write to a new file.
6. A program to print consecutive characters in a string and their frequency.
Static analysis: Around Java in 60 minutesAndrey Karpov
Theory
Code quality (bugs, vulnerabilities)
Methodologies of code protection against defects
Code Review
Static analysis and everything related to it
Tools
Existing tools of static analysis
SonarQube
PVS-Studio for Java what is it?
Several detected examples of code with defects
More about static analysis
Conclusions
The PPTs from one of the event of iWillStudy.com - a leading start-up in the education space in India. This PPT is being used at an event where they taught iPhone programming and applications development.
This document provides an overview of iOS programming using Xcode and Objective-C. It discusses Xcode development tools like Interface Builder and iOS Simulator. It covers the Xcode IDE, navigation, and running apps on the simulator or a device. It introduces Objective-C concepts like classes, objects, methods, and message passing. It discusses core Objective-C classes like NSString, NSNumber, NSArray, and NSDictionary. It also covers view controllers, the model-view-controller design pattern, and view controller lifecycle methods. Sample code projects are provided to demonstrate concepts like handling user interfaces and responding to user interactions.
Networking and Security provided by java.
With the help of java.security and java.net Packages.
It also provide brief information about the Permission and Policy Classes of java.securty Packages.
This document provides an introduction to Java programming through a series of Java 101 tutorials. It discusses setting up a Java development environment, provides an overview of the Java language, and demonstrates how to write a first Java program. It also covers built-in Java data types like String, int, double, and boolean, and control structures like conditionals and loops. The document concludes with exercises for readers to practice working with command line arguments, operators, arrays, and random number generation in Java.
The document discusses elementary sorting algorithms including selection sort, insertion sort, and shellsort. It provides examples of how sorting can be used to sort various data types like numbers, strings, and files by implementing callbacks that allow the sorting routines to compare objects. The key point is that sorting routines do not need specific information about the types of objects being sorted since clients can pass a compare method through an interface like Comparable.
Important java programs(collection+file)Alok Kumar
The document contains 6 Java programming questions and solutions:
1. A program to find unique and duplicate items in an array.
2. A Product class with properties and methods to sort objects.
3. A program to merge contents of two text files into a third file.
4. A program to count the occurrences of specific words in a file.
5. A program to read a file, add contents to an ArrayList, and write to a new file.
6. A program to print consecutive characters in a string and their frequency.
Static analysis: Around Java in 60 minutesAndrey Karpov
Theory
Code quality (bugs, vulnerabilities)
Methodologies of code protection against defects
Code Review
Static analysis and everything related to it
Tools
Existing tools of static analysis
SonarQube
PVS-Studio for Java what is it?
Several detected examples of code with defects
More about static analysis
Conclusions
The PPTs from one of the event of iWillStudy.com - a leading start-up in the education space in India. This PPT is being used at an event where they taught iPhone programming and applications development.
This document provides an overview of iOS programming using Xcode and Objective-C. It discusses Xcode development tools like Interface Builder and iOS Simulator. It covers the Xcode IDE, navigation, and running apps on the simulator or a device. It introduces Objective-C concepts like classes, objects, methods, and message passing. It discusses core Objective-C classes like NSString, NSNumber, NSArray, and NSDictionary. It also covers view controllers, the model-view-controller design pattern, and view controller lifecycle methods. Sample code projects are provided to demonstrate concepts like handling user interfaces and responding to user interactions.
Networking and Security provided by java.
With the help of java.security and java.net Packages.
It also provide brief information about the Permission and Policy Classes of java.securty Packages.
This document provides an introduction to Java programming through a series of Java 101 tutorials. It discusses setting up a Java development environment, provides an overview of the Java language, and demonstrates how to write a first Java program. It also covers built-in Java data types like String, int, double, and boolean, and control structures like conditionals and loops. The document concludes with exercises for readers to practice working with command line arguments, operators, arrays, and random number generation in Java.
This document discusses exceptions and errors in Java. It provides examples of different types of exceptions like ArrayIndexOutOfBoundsException, NullPointerException, and ClassCastException. It explains exception handling using try-catch blocks and the finally block. It also covers multi-catch, try-with-resources, exception propagation, checked vs unchecked exceptions, and creating custom exceptions. The key aspects of exception handling in Java are to not swallow exceptions, use checked exceptions for recoverable conditions, and use runtime exceptions to indicate programming errors.
Java pre-processing and annotations talk. How to do it? How it works? Why to do it?
Github code: https://github.com/luanpotter/annotation-preprocessing
https://github.com/luanpotter/reflection-utils
This document provides an overview of Java collections APIs, including:
- A history of collections interfaces added in different JDK versions from 1.0 to 1.7.
- Descriptions of common collection interfaces like List, Set, Map and their implementations.
- Comparisons of performance and characteristics of different collection implementations.
- Explanations of common collection algorithms and concurrency utilities.
- References for further reading on collections and concurrency.
This document discusses software design principles and patterns, including:
1) Generic programming allows code to work with different data types through interfaces and abstract base classes. Reflection allows examining and manipulating objects at runtime.
2) The document discusses separation of concerns, loose coupling, and high cohesion as important design principles. It gives an example of dividing an application by feature and concern.
3) The document uses a duck simulation example to illustrate issues that can arise from rigid class hierarchies and inheritance. It proposes using the strategy pattern by defining behavior interfaces and swapping concrete strategy classes to vary behavior while keeping classes loosely coupled and extensible.
Java Annotation is quite a handy tool and has the ample potential to make developer's life a lot easier(and exciting!). Learning and using custom Java Annotation Processor takes the power of Annotation even a class higher. This slide goes over a few fundamental things of an Annotation Processor to get someone started to write his/her own Annotation Processor in Java.
Key topics are,
- Java Annotation
- Usage of Annotation
- Custom Java Annotation
- Java Annotation Processor
- Usefulness of Annotation Processor
- Dive into the core of Annotation Processor
- Solve a validation problem with Custom Annotation Processor
- Get to know some exciting Annotation Processing tools that already exist
ObjectLayout: Closing the (last?) inherent C vs. Java speed gapAzul Systems Inc.
This document proposes ObjectLayout as a way to close the speed gap between Java and C by enabling Java objects to have optimized memory layouts like C structs. It describes three forms - arrays of structs, structs containing other structs, and structs with arrays at the end. Vanilla Java classes called StructuredArray, intrinsic objects, and subclassable arrays are presented to capture the semantics of these forms. Optimized JDK implementations are proposed to lay out objects contiguously for improved speed. The goal is to add ObjectLayout to Java SE without requiring language or JVM changes by providing both vanilla and optimized versions.
This document provides an agenda and overview of topics related to Java language and object-oriented programming (OOP). The topics covered include string package, date package, math package, exceptions (basic, try-catch, throw), collections, input/output, and files. For each topic, key concepts and examples are briefly explained in 1-3 sentences.
The document discusses various .NET framework fundamentals including value types that contain data directly in memory versus reference types that store a reference to data on the heap. It also covers creating classes and structs, inheritance, interfaces, generics, and events. Specific examples are provided on declaring and using value types, creating user-defined types like an enum or struct, and constructing classes that inherit from a base class or implement interfaces.
Annotation processing allows for metadata to be added to Java programs without altering the program itself. Annotations can be defined and used to provide information for compilers or allow runtime/compile-time processing. Annotation processors provide a hook into the Java compilation process to generate source code and compile errors/warnings. They work by processing annotated elements in rounds. Testing annotation processors is challenging but libraries like Google's compile-testing library can help. Annotation processing also works on Android by setting up the processor as a Java module and using plugins like android-apt.
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMERAndrey Karpov
Static code analysis tools can analyze Java programs to find defects without executing the code. They use techniques like pattern matching, type inference, data flow analysis and symbolic execution. PVS-Studio is a static analysis tool for Java that was created using lessons from a C++ analyzer. It finds bugs like integer divisions by zero, dead code, copy-paste errors and other defects. Integrating static analysis into development processes helps improve code quality over time by detecting and fixing issues early.
Java and Spring Data JPA: Easy SQL Data Access
Abstract
Presenter: Miya W. Longwe, MBA, MSE, Tech Lead, Staples, Inc, Framingham MA 01702
Accessing data repositories in various applications programming languages typically involves writing of tedious boilerplate lines of code. Some application development frameworks such as Spring have tried to make the experience more succinct by providing abstraction layers such as HibernateTemplate and JdbcTemplate, etc. Despite these APIs, the developers still spend a lot time writing repetitive code than concentrating on implementing business requirements. Developers at Spring, led by Oliver Gierke, introduced Spring Data JPA which “aims to significantly improve the implementation of data access layers by reducing the effort to the amount that's actually needed. As a developer you write your repository interfaces, including custom finder methods, and Spring will provide the implementation automatically”.
Spring Data JPA provides a powerful, out-of-the-box alternative to creating your own DAO framework. You declare custom repository operations on an interface, and the framework generates dynamic implementations (not code generation) automatically, based on conventions around method names. As part of the presentation, we'll also review a demo to look at Spring Java configuration (as opposed to XML configuration), and investigate the @Profile annotation – configuration details which may make life a bit easier in various ways when setting up unit testing of our repository classes, using out-of-the-box alternative to creating DAO framework, how to create custom repositories, pagination and support for custom queries among other features.
Presenter's Bio
Miya W. Longwe is a Senior Software Engineer and Tech Lead at Staples, Inc. where he is currently working on an initiative to re-platform the company’s ecommerce architecture to offer platform-driven, modular products that can be quickly customized, enhanced, and branded as needed.
Miya has been a software professional since 1997. His 16 years software development career includes working for large companies to small startups, building solutions for enterprises and consumers, working with a broad range of technologies.
Miya Longwe is a hands-on java developer. He believes that in order to be a relevant and effective software developer one needs to remain a deeply knowledgeable, up-to-date, and productive software developer. His research interests include model-driven engineering, domain specific languages, test driven development and project risk management.
Miya graduated from the University of Malawi (Lilongwe, Malawi) and has an MBA from the University of Wales Cardiff Business School (Wales, UK) and a Masters in Software Engineering from Brandeis University (MA, USA).
Occasionally, Miya can be spotted fishing the banks of the south shore (MA) with his two boys, William and Daniel.
This document provides an overview of various Java language concepts including enums, final, static, variable arguments, encapsulation, inheritance, polymorphism, interfaces, and abstract classes. It defines each concept and provides examples to illustrate how they work in Java code. The document is presented as part of a multi-part series on the Java language and object-oriented programming.
The document discusses concurrency and threads in Java. It covers:
1. Concurrency allows running programs or parts of programs in parallel to improve throughput and interactivity. Modern computers have multiple CPU cores that can be leveraged.
2. A thread is a lightweight process that can access shared data in the same process. Java applications run in one process but use multiple threads for parallel processing.
3. Using threads introduces concurrency issues like visibility and access problems that can lead to failures if not handled properly.
The document provides an overview and introduction to Spring Data JPA, including:
1) How Spring Data abstracts away basic data management concepts and supports both relational and non-relational databases.
2) An example of refactoring from plain JPA to Spring Data JPA by defining a repository interface and using built-in query methods.
3) How the Spring Data repository abstraction reduces the effort to implement data access layers through interfaces like Repository.
This document provides an overview of the Java programming language. It discusses key features such as platform independence, object-oriented programming principles like inheritance and polymorphism, automatic memory management, and security features. It also covers basic Java concepts like primitive data types, variables, operators, flow control statements, methods, and classes.
- The DOM (Document Object Model) views an XML document as a tree structure where each node represents a component of the XML structure.
- The DOM parser constructs an internal representation of the XML data as a tree structure in memory, allowing traversal and manipulation of nodes.
- To validate an XML document using a schema with DOM, the parser factory is configured to create a validating parser, the schema language and source are set, and errors are handled.
Object.__class__.__dict__ - python object model and friends - with examplesRobert Lujo
Python object model - advanced and some not so advanced features, lot of code examples:
building blocks, objects, classes, functions, mutable and immutable, everything is an object, variables, global context, "executing" the module, standard types inheritance, multiple inheritance, mixins and mro, dynamic classes, metaclasses, property function and descriptors context managers & with, useful __methods__
The document provides templates and examples for creating Swing-based GUI applications, servlets, Java Server Pages (JSP), Java Database Connectivity (JDBC), Java Server Faces (JSF), Enterprise Java Beans (EJB), Hibernate, Struts, and web services in Java. It includes templates for common GUI components, servlets, JSP tags, database queries, managed beans, navigation rules, entity beans, Hibernate mappings, actions, and web service providers/consumers.
The document contains details of 9 practical assignments for an Advance Java course. Each practical assignment involves developing a Java program or application to demonstrate a concept. For example, Practical 01 involves creating a program to select stationary products and display prices; Practical 02 creates an editable employee table; Practical 03 uses a split pane to display planet images; and so on. The final practical involves developing a room reservation system using Enterprise Java Beans.
Java allows writing code once that can run on any platform. It compiles to bytecode that runs on the Java Virtual Machine (JVM). Key features include automatic memory management, object-oriented design, platform independence, security, and multi-threading. Classes are defined in .java files and compiled to .class files. The JVM interprets bytecode and uses just-in-time compilation to improve performance.
This document discusses aspect oriented programming (AOP) with Spring. It describes how AOP can be used to modularize cross-cutting concerns like logging and transaction management. It provides examples of implementing logging using both a naive approach and with AOP. It explains key AOP concepts like aspects, pointcuts, join points and advice. It also summarizes how AOP can be used with Spring through either the @AspectJ annotation style or XML schema-based style.
In this lecture we look at the patterns in chapter 18 in the textbook (Patterns of Enterprise Application Architecture). The lecture is in two parts. First we go through each of the patterns and explain each.
Then in the second part we look at a problem we have to solve and try to get the patterns to show themselves at the time they are needed.
This document discusses exceptions and errors in Java. It provides examples of different types of exceptions like ArrayIndexOutOfBoundsException, NullPointerException, and ClassCastException. It explains exception handling using try-catch blocks and the finally block. It also covers multi-catch, try-with-resources, exception propagation, checked vs unchecked exceptions, and creating custom exceptions. The key aspects of exception handling in Java are to not swallow exceptions, use checked exceptions for recoverable conditions, and use runtime exceptions to indicate programming errors.
Java pre-processing and annotations talk. How to do it? How it works? Why to do it?
Github code: https://github.com/luanpotter/annotation-preprocessing
https://github.com/luanpotter/reflection-utils
This document provides an overview of Java collections APIs, including:
- A history of collections interfaces added in different JDK versions from 1.0 to 1.7.
- Descriptions of common collection interfaces like List, Set, Map and their implementations.
- Comparisons of performance and characteristics of different collection implementations.
- Explanations of common collection algorithms and concurrency utilities.
- References for further reading on collections and concurrency.
This document discusses software design principles and patterns, including:
1) Generic programming allows code to work with different data types through interfaces and abstract base classes. Reflection allows examining and manipulating objects at runtime.
2) The document discusses separation of concerns, loose coupling, and high cohesion as important design principles. It gives an example of dividing an application by feature and concern.
3) The document uses a duck simulation example to illustrate issues that can arise from rigid class hierarchies and inheritance. It proposes using the strategy pattern by defining behavior interfaces and swapping concrete strategy classes to vary behavior while keeping classes loosely coupled and extensible.
Java Annotation is quite a handy tool and has the ample potential to make developer's life a lot easier(and exciting!). Learning and using custom Java Annotation Processor takes the power of Annotation even a class higher. This slide goes over a few fundamental things of an Annotation Processor to get someone started to write his/her own Annotation Processor in Java.
Key topics are,
- Java Annotation
- Usage of Annotation
- Custom Java Annotation
- Java Annotation Processor
- Usefulness of Annotation Processor
- Dive into the core of Annotation Processor
- Solve a validation problem with Custom Annotation Processor
- Get to know some exciting Annotation Processing tools that already exist
ObjectLayout: Closing the (last?) inherent C vs. Java speed gapAzul Systems Inc.
This document proposes ObjectLayout as a way to close the speed gap between Java and C by enabling Java objects to have optimized memory layouts like C structs. It describes three forms - arrays of structs, structs containing other structs, and structs with arrays at the end. Vanilla Java classes called StructuredArray, intrinsic objects, and subclassable arrays are presented to capture the semantics of these forms. Optimized JDK implementations are proposed to lay out objects contiguously for improved speed. The goal is to add ObjectLayout to Java SE without requiring language or JVM changes by providing both vanilla and optimized versions.
This document provides an agenda and overview of topics related to Java language and object-oriented programming (OOP). The topics covered include string package, date package, math package, exceptions (basic, try-catch, throw), collections, input/output, and files. For each topic, key concepts and examples are briefly explained in 1-3 sentences.
The document discusses various .NET framework fundamentals including value types that contain data directly in memory versus reference types that store a reference to data on the heap. It also covers creating classes and structs, inheritance, interfaces, generics, and events. Specific examples are provided on declaring and using value types, creating user-defined types like an enum or struct, and constructing classes that inherit from a base class or implement interfaces.
Annotation processing allows for metadata to be added to Java programs without altering the program itself. Annotations can be defined and used to provide information for compilers or allow runtime/compile-time processing. Annotation processors provide a hook into the Java compilation process to generate source code and compile errors/warnings. They work by processing annotated elements in rounds. Testing annotation processors is challenging but libraries like Google's compile-testing library can help. Annotation processing also works on Android by setting up the processor as a Java module and using plugins like android-apt.
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMERAndrey Karpov
Static code analysis tools can analyze Java programs to find defects without executing the code. They use techniques like pattern matching, type inference, data flow analysis and symbolic execution. PVS-Studio is a static analysis tool for Java that was created using lessons from a C++ analyzer. It finds bugs like integer divisions by zero, dead code, copy-paste errors and other defects. Integrating static analysis into development processes helps improve code quality over time by detecting and fixing issues early.
Java and Spring Data JPA: Easy SQL Data Access
Abstract
Presenter: Miya W. Longwe, MBA, MSE, Tech Lead, Staples, Inc, Framingham MA 01702
Accessing data repositories in various applications programming languages typically involves writing of tedious boilerplate lines of code. Some application development frameworks such as Spring have tried to make the experience more succinct by providing abstraction layers such as HibernateTemplate and JdbcTemplate, etc. Despite these APIs, the developers still spend a lot time writing repetitive code than concentrating on implementing business requirements. Developers at Spring, led by Oliver Gierke, introduced Spring Data JPA which “aims to significantly improve the implementation of data access layers by reducing the effort to the amount that's actually needed. As a developer you write your repository interfaces, including custom finder methods, and Spring will provide the implementation automatically”.
Spring Data JPA provides a powerful, out-of-the-box alternative to creating your own DAO framework. You declare custom repository operations on an interface, and the framework generates dynamic implementations (not code generation) automatically, based on conventions around method names. As part of the presentation, we'll also review a demo to look at Spring Java configuration (as opposed to XML configuration), and investigate the @Profile annotation – configuration details which may make life a bit easier in various ways when setting up unit testing of our repository classes, using out-of-the-box alternative to creating DAO framework, how to create custom repositories, pagination and support for custom queries among other features.
Presenter's Bio
Miya W. Longwe is a Senior Software Engineer and Tech Lead at Staples, Inc. where he is currently working on an initiative to re-platform the company’s ecommerce architecture to offer platform-driven, modular products that can be quickly customized, enhanced, and branded as needed.
Miya has been a software professional since 1997. His 16 years software development career includes working for large companies to small startups, building solutions for enterprises and consumers, working with a broad range of technologies.
Miya Longwe is a hands-on java developer. He believes that in order to be a relevant and effective software developer one needs to remain a deeply knowledgeable, up-to-date, and productive software developer. His research interests include model-driven engineering, domain specific languages, test driven development and project risk management.
Miya graduated from the University of Malawi (Lilongwe, Malawi) and has an MBA from the University of Wales Cardiff Business School (Wales, UK) and a Masters in Software Engineering from Brandeis University (MA, USA).
Occasionally, Miya can be spotted fishing the banks of the south shore (MA) with his two boys, William and Daniel.
This document provides an overview of various Java language concepts including enums, final, static, variable arguments, encapsulation, inheritance, polymorphism, interfaces, and abstract classes. It defines each concept and provides examples to illustrate how they work in Java code. The document is presented as part of a multi-part series on the Java language and object-oriented programming.
The document discusses concurrency and threads in Java. It covers:
1. Concurrency allows running programs or parts of programs in parallel to improve throughput and interactivity. Modern computers have multiple CPU cores that can be leveraged.
2. A thread is a lightweight process that can access shared data in the same process. Java applications run in one process but use multiple threads for parallel processing.
3. Using threads introduces concurrency issues like visibility and access problems that can lead to failures if not handled properly.
The document provides an overview and introduction to Spring Data JPA, including:
1) How Spring Data abstracts away basic data management concepts and supports both relational and non-relational databases.
2) An example of refactoring from plain JPA to Spring Data JPA by defining a repository interface and using built-in query methods.
3) How the Spring Data repository abstraction reduces the effort to implement data access layers through interfaces like Repository.
This document provides an overview of the Java programming language. It discusses key features such as platform independence, object-oriented programming principles like inheritance and polymorphism, automatic memory management, and security features. It also covers basic Java concepts like primitive data types, variables, operators, flow control statements, methods, and classes.
- The DOM (Document Object Model) views an XML document as a tree structure where each node represents a component of the XML structure.
- The DOM parser constructs an internal representation of the XML data as a tree structure in memory, allowing traversal and manipulation of nodes.
- To validate an XML document using a schema with DOM, the parser factory is configured to create a validating parser, the schema language and source are set, and errors are handled.
Object.__class__.__dict__ - python object model and friends - with examplesRobert Lujo
Python object model - advanced and some not so advanced features, lot of code examples:
building blocks, objects, classes, functions, mutable and immutable, everything is an object, variables, global context, "executing" the module, standard types inheritance, multiple inheritance, mixins and mro, dynamic classes, metaclasses, property function and descriptors context managers & with, useful __methods__
The document provides templates and examples for creating Swing-based GUI applications, servlets, Java Server Pages (JSP), Java Database Connectivity (JDBC), Java Server Faces (JSF), Enterprise Java Beans (EJB), Hibernate, Struts, and web services in Java. It includes templates for common GUI components, servlets, JSP tags, database queries, managed beans, navigation rules, entity beans, Hibernate mappings, actions, and web service providers/consumers.
The document contains details of 9 practical assignments for an Advance Java course. Each practical assignment involves developing a Java program or application to demonstrate a concept. For example, Practical 01 involves creating a program to select stationary products and display prices; Practical 02 creates an editable employee table; Practical 03 uses a split pane to display planet images; and so on. The final practical involves developing a room reservation system using Enterprise Java Beans.
Java allows writing code once that can run on any platform. It compiles to bytecode that runs on the Java Virtual Machine (JVM). Key features include automatic memory management, object-oriented design, platform independence, security, and multi-threading. Classes are defined in .java files and compiled to .class files. The JVM interprets bytecode and uses just-in-time compilation to improve performance.
This document discusses aspect oriented programming (AOP) with Spring. It describes how AOP can be used to modularize cross-cutting concerns like logging and transaction management. It provides examples of implementing logging using both a naive approach and with AOP. It explains key AOP concepts like aspects, pointcuts, join points and advice. It also summarizes how AOP can be used with Spring through either the @AspectJ annotation style or XML schema-based style.
In this lecture we look at the patterns in chapter 18 in the textbook (Patterns of Enterprise Application Architecture). The lecture is in two parts. First we go through each of the patterns and explain each.
Then in the second part we look at a problem we have to solve and try to get the patterns to show themselves at the time they are needed.
Aspect-Oriented Programming (AOP) complements Object-Oriented Programming (OOP) by providing another way of thinking about program structure. The key unit of modularity in OOP is the class, whereas in AOP the unit of modularity is the aspect. Aspects enable the modularization of concerns such as transaction management that cut across multiple types and objects. (Such concerns are often termed crosscutting concerns in AOP literature.)
One of the key components of Spring is the AOP framework. While the Spring IoC container does not depend on AOP, meaning you do not need to use AOP if you don't want to, AOP complements Spring IoC to provide a very capable middleware solution.
This document provides an overview of the Spring framework and its various modules. It discusses Spring concepts like dependency injection and inversion of control. It also covers specific Spring features such as AOP, testing, ORM/Hibernate integration, scheduling, MVC, JMS, email and more. The document includes configuration examples and code snippets for many of these Spring modules.
JSR-299 defines a unifying dependency injection and contextual lifecycle model for Java EE 6. It allows injection of various types of objects like classes, EJBs, producer methods, resources, etc. It also defines concepts like qualifiers, scopes, events, interceptors, and stereotypes to customize injections. Producers are used as sources of injectable objects and can be annotated with scopes and qualifiers.
The document discusses the basics of the Eclipse debug platform, including an overview of key components like the standard debug model, launch framework, breakpoints, and variables view. It describes how these provide common abstractions and interfaces that debugger implementations can use to integrate with the platform and user interface. It also provides an example of implementing a debugger for a pushdown automaton language to demonstrate how this works.
The document provides an overview of the Eclipse debug platform and its main components. It describes the standard debug model, which includes common abstractions like processes, threads, stack frames and variables. It also covers the launch framework, which handles running and debugging code through launch configurations, delegates and modes. Custom debuggers integrate with these components by implementing interfaces and contributing extensions.
The document provides an overview of the Eclipse debug platform and its main components. It describes the standard debug model, which includes common abstractions like processes, threads, stack frames and variables. It also covers the launch framework, which handles running and debugging code through launch configurations, delegates and modes. Custom debuggers integrate with these components by implementing interfaces and contributing extensions.
Struts 2 is an open source MVC framework based on Java EE standards. It uses a request-response pipeline where interceptors pre-process and post-process requests. The core components are interceptors, actions, and results. Interceptors provide functionality like validation while actions contain application logic and results define the response. Values are stored and accessed from a value stack using OGNL.
Spoon is an open-source library that enables you to transform and analyze Java source code. Due to a complete and fine-grained Java metamodel, you can read and write the AST built by Spoon. In this talk, you'll see all strong concepts and API with an example. Then, you'll see how you can integrate this project in yours.
The document provides an overview of the services offered by the Java Development Tools (JDT) Core and UI for extending JDT and becoming a JDT tool smith. It summarizes the three main pillars of JDT - the Java model, search engine, and abstract syntax tree (AST). The Java model is a lightweight model for views. The search engine allows quick access to declarations and references through indexing. The AST provides a precise, fully resolved compiler parse tree for code manipulation.
This document discusses aspect-oriented programming (AOP) and AspectJ. AOP aims to increase modularity by separating cross-cutting concerns from core functionality. AspectJ is a popular AOP extension for Java. It allows defining aspects that specify where advice code should run via pointcuts. Advice like before, after returning, etc. can add behavior without modifying the original code. AspectJ compiles aspects and application code together or weaves aspects into existing binaries at compile-time, post-compile, or load-time. Examples demonstrate logging and profiling cross-cutting concerns using aspects.
The document discusses aspect-oriented programming (AOP) and key AOP concepts like joinpoints, pointcuts, advice, and aspects. It explains how AOP addresses cross-cutting concerns in code through separation of concerns using pointcuts, advice, and aspects rather than scattering code throughout a system. The document also provides examples of how to configure AOP using Spring AOP through pointcuts, advice definitions, and proxies.
Aspect-oriented programming (AOP) is a programming paradigm that allows separating cross-cutting concerns into distinct modules called aspects. AspectJ is an extension to Java that implements AOP. It allows defining pointcuts that specify join points in the program flow and writing advice code to be executed at those points. Aspects modularize cross-cutting concerns like logging, profiling, and security that would otherwise be tangled throughout the codebase. AspectJ does not replace object-oriented programming but complements it by providing another way to structure programs.
WSO2 Complex Event Processor (CEP) 4.0 provides real-time analytics capabilities. Some key features of CEP 4.0 include a re-architecture of the CEP server, improvements to the Siddhi query engine (version 3.0), scalable distributed processing using Apache Storm, and better high availability support. CEP 4.0 also offers a domain specific execution manager, real-time dashboards, improved usability, and pluggable event receivers and publishers. It can execute queries in a distributed manner across multiple nodes for scalability.
Unleash the power of Context and Dependency Injection (CDI) in a JEE container. The slides go over the 2.0 specification and how each part of the specification can be applied. Code for this can be found on GitHub: https://github.com/bpaskin/JavaExamples/tree/master/CDI2.0Examples/src/com/ibm/example/cdi
The document discusses annotation processing tools (APT). It begins by defining what an annotation is and how they are used. It then covers retention policies, how annotations can be accessed at runtime via reflection, and the Mirror API. The bulk of the document provides an example of creating a custom annotation processor for Android data binding. It demonstrates creating annotations, configuring a processor, processing annotation elements, and generating code. The key aspects covered are how to implement an annotation processor by extending AbstractProcessor and processing annotation elements in the RoundEnvironment.
Rammar eru almennar aðgerðir og aðferðir sem nota má til að búa til sértækan hugbúnað. Með römmum má endurnýta kóða sem alltaf er eins eða nánast alltaf er eins. Það sem er sérhæft eru ákveðin viðfangsefni en útfærsla á þeim notar rammann. Við skilgreinum ramma og skoðum kosti og galla.
Við skoðum einnig létta gáma eða lightweight containers sem eru forrit sem sjá um lífshlaup (live-cycle) hluta og umhverfi þeirra (context). Þá skoðum við munstrið Dependency Injection sem er mjög hentugt í römmum.
Einnig skoðum við Template Method og Strategy munstrin.
Similar to Aspect oriented programming with spring (20)
Generating privacy-protected synthetic data using Secludy and MilvusZilliz
During this demo, the founders of Secludy will demonstrate how their system utilizes Milvus to store and manipulate embeddings for generating privacy-protected synthetic data. Their approach not only maintains the confidentiality of the original data but also enhances the utility and scalability of LLMs under privacy constraints. Attendees, including machine learning engineers, data scientists, and data managers, will witness first-hand how Secludy's integration with Milvus empowers organizations to harness the power of LLMs securely and efficiently.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/building-and-scaling-ai-applications-with-the-nx-ai-manager-a-presentation-from-network-optix/
Robin van Emden, Senior Director of Data Science at Network Optix, presents the “Building and Scaling AI Applications with the Nx AI Manager,” tutorial at the May 2024 Embedded Vision Summit.
In this presentation, van Emden covers the basics of scaling edge AI solutions using the Nx tool kit. He emphasizes the process of developing AI models and deploying them globally. He also showcases the conversion of AI models and the creation of effective edge AI pipelines, with a focus on pre-processing, model conversion, selecting the appropriate inference engine for the target hardware and post-processing.
van Emden shows how Nx can simplify the developer’s life and facilitate a rapid transition from concept to production-ready applications.He provides valuable insights into developing scalable and efficient edge AI solutions, with a strong focus on practical implementation.
Fueling AI with Great Data with Airbyte WebinarZilliz
This talk will focus on how to collect data from a variety of sources, leveraging this data for RAG and other GenAI use cases, and finally charting your course to productionalization.
Monitoring and Managing Anomaly Detection on OpenShift.pdfTosin Akinosho
Monitoring and Managing Anomaly Detection on OpenShift
Overview
Dive into the world of anomaly detection on edge devices with our comprehensive hands-on tutorial. This SlideShare presentation will guide you through the entire process, from data collection and model training to edge deployment and real-time monitoring. Perfect for those looking to implement robust anomaly detection systems on resource-constrained IoT/edge devices.
Key Topics Covered
1. Introduction to Anomaly Detection
- Understand the fundamentals of anomaly detection and its importance in identifying unusual behavior or failures in systems.
2. Understanding Edge (IoT)
- Learn about edge computing and IoT, and how they enable real-time data processing and decision-making at the source.
3. What is ArgoCD?
- Discover ArgoCD, a declarative, GitOps continuous delivery tool for Kubernetes, and its role in deploying applications on edge devices.
4. Deployment Using ArgoCD for Edge Devices
- Step-by-step guide on deploying anomaly detection models on edge devices using ArgoCD.
5. Introduction to Apache Kafka and S3
- Explore Apache Kafka for real-time data streaming and Amazon S3 for scalable storage solutions.
6. Viewing Kafka Messages in the Data Lake
- Learn how to view and analyze Kafka messages stored in a data lake for better insights.
7. What is Prometheus?
- Get to know Prometheus, an open-source monitoring and alerting toolkit, and its application in monitoring edge devices.
8. Monitoring Application Metrics with Prometheus
- Detailed instructions on setting up Prometheus to monitor the performance and health of your anomaly detection system.
9. What is Camel K?
- Introduction to Camel K, a lightweight integration framework built on Apache Camel, designed for Kubernetes.
10. Configuring Camel K Integrations for Data Pipelines
- Learn how to configure Camel K for seamless data pipeline integrations in your anomaly detection workflow.
11. What is a Jupyter Notebook?
- Overview of Jupyter Notebooks, an open-source web application for creating and sharing documents with live code, equations, visualizations, and narrative text.
12. Jupyter Notebooks with Code Examples
- Hands-on examples and code snippets in Jupyter Notebooks to help you implement and test anomaly detection models.
Have you ever been confused by the myriad of choices offered by AWS for hosting a website or an API?
Lambda, Elastic Beanstalk, Lightsail, Amplify, S3 (and more!) can each host websites + APIs. But which one should we choose?
Which one is cheapest? Which one is fastest? Which one will scale to meet our needs?
Join me in this session as we dive into each AWS hosting service to determine which one is best for your scenario and explain why!
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfTechgropse Pvt.Ltd.
In this blog post, we'll delve into the intersection of AI and app development in Saudi Arabia, focusing on the food delivery sector. We'll explore how AI is revolutionizing the way Saudi consumers order food, how restaurants manage their operations, and how delivery partners navigate the bustling streets of cities like Riyadh, Jeddah, and Dammam. Through real-world case studies, we'll showcase how leading Saudi food delivery apps are leveraging AI to redefine convenience, personalization, and efficiency.
GraphRAG for Life Science to increase LLM accuracyTomaz Bratanic
GraphRAG for life science domain, where you retriever information from biomedical knowledge graphs using LLMs to increase the accuracy and performance of generated answers
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceIndexBug
Imagine a world where machines not only perform tasks but also learn, adapt, and make decisions. This is the promise of Artificial Intelligence (AI), a technology that's not just enhancing our lives but revolutionizing entire industries.
Ivanti’s Patch Tuesday breakdown goes beyond patching your applications and brings you the intelligence and guidance needed to prioritize where to focus your attention first. Catch early analysis on our Ivanti blog, then join industry expert Chris Goettl for the Patch Tuesday Webinar Event. There we’ll do a deep dive into each of the bulletins and give guidance on the risks associated with the newly-identified vulnerabilities.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
Driving Business Innovation: Latest Generative AI Advancements & Success StorySafe Software
Are you ready to revolutionize how you handle data? Join us for a webinar where we’ll bring you up to speed with the latest advancements in Generative AI technology and discover how leveraging FME with tools from giants like Google Gemini, Amazon, and Microsoft OpenAI can supercharge your workflow efficiency.
During the hour, we’ll take you through:
Guest Speaker Segment with Hannah Barrington: Dive into the world of dynamic real estate marketing with Hannah, the Marketing Manager at Workspace Group. Hear firsthand how their team generates engaging descriptions for thousands of office units by integrating diverse data sources—from PDF floorplans to web pages—using FME transformers, like OpenAIVisionConnector and AnthropicVisionConnector. This use case will show you how GenAI can streamline content creation for marketing across the board.
Ollama Use Case: Learn how Scenario Specialist Dmitri Bagh has utilized Ollama within FME to input data, create custom models, and enhance security protocols. This segment will include demos to illustrate the full capabilities of FME in AI-driven processes.
Custom AI Models: Discover how to leverage FME to build personalized AI models using your data. Whether it’s populating a model with local data for added security or integrating public AI tools, find out how FME facilitates a versatile and secure approach to AI.
We’ll wrap up with a live Q&A session where you can engage with our experts on your specific use cases, and learn more about optimizing your data workflows with AI.
This webinar is ideal for professionals seeking to harness the power of AI within their data management systems while ensuring high levels of customization and security. Whether you're a novice or an expert, gain actionable insights and strategies to elevate your data processes. Join us to see how FME and AI can revolutionize how you work with data!
OpenID AuthZEN Interop Read Out - AuthorizationDavid Brossard
During Identiverse 2024 and EIC 2024, members of the OpenID AuthZEN WG got together and demoed their authorization endpoints conforming to the AuthZEN API
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slackshyamraj55
Discover the seamless integration of RPA (Robotic Process Automation), COMPOSER, and APM with AWS IDP enhanced with Slack notifications. Explore how these technologies converge to streamline workflows, optimize performance, and ensure secure access, all while leveraging the power of AWS IDP and real-time communication via Slack notifications.
2. Problem area
• How to modularize concerns that span multiple classes
and layers?
• Examples of cross-cutting concerns:
–
–
–
–
–
Transaction management
Logging
Profiling
Security
Internationalisation
3. Logging: A naive approach
Retrieving log
instance
public class HibernateEventDAO
{
private static Log log = LogFactory.getLog( HibernateEventDAO.class );
public Integer saveEvent( Event event )
{
log.info( ”Executing saveEvent( Event ) with argument + ” event.toString() );
Logging method
executions
Session session = sessionManager.getCurrentSession();
return (Integer) session.save( event );
}
public Event getEvent( Integer id )
{
log.info( ”Executing getEvent( int )” );
Session session = sessionManager.getCurrentSession();
return (Event) session.get( Event.class, id );
}
4. Logging: A naive approach
Invokes methods on
the DAOs
EventManager
Service layer
(method invocation)
DAOs perform
both logging and
persistence
operations
PersonDAO
EventDAO
Persistence layer
5. Shortcomings of naive approach
• Mixes persistence and logging functionality
– Violates the principle of separation of concerns
– Increases complexity and inter-dependency
• Involves repetition of code
– Violates the DRY principle
– Makes it difficult to change
• Couples the LogFactory to the HibernateEventDAO
– Prevents loosely coupled design
– Makes change, re-use and testing problematic
6. Logging: The AOP approach
EventManager
Intercepts method
invocations and
performs logging
DAOs perform
persistence only
Service layer
(method invocation)
AOP interceptor
PersonDAO
EventDAO
Persistence layer
7. Advantages of AOP approach
• Separates persistence and logging functionality
– The logging concern taken care of by the interceptor
– Makes it easier to understand, manage and debug
• Promotes code reuse and modularization
– The AOP interceptor is used by all methods in the DAOs
– Makes it easier to change
• Decouples the LogFactory from the DAO impl’s
– The HibernateEventDAO is unaware of being logged
– Makes change, re-use and testing simple
8. Aspect Oriented Programming
• Definition: Enables encapsulation of functionality that
affects multiple classes in separate units
• Complements object oriented programming
• Most popular implementation for Java is AspectJ
– Aspect oriented extension for Java
– Based on Eclipse, available as plugin and stand-alone
10. AOP with Spring
• The AOP framework is a key component of Spring
– Provides declarative enterprise services (transactions)
– Allows for custom aspects
• Aims at providing integration between AOP and IoC
• Integrates – but doesn’t compete – with AspectJ
• Provides two techniques for defining aspects:
– @AspectJ annotation
– XML schema-based
11. AOP concepts
• Aspect
– A concern that cuts across multiple classes and layers
• Join point
– A method invocation during the execution of a program
• Advice
– An implementation of a concern represented as an interceptor
• Pointcut
– An expression mapped to a join point
12. @AspectJ support
• Style of declaring aspects as regular Java classes with
Java 5 annotations
• Requires aspectjweaver and aspectjrt on the classpath
• Enabled by including the following information in the
Spring configuration file:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<aop:aspectj-autoproxy/>
13. Declaring an aspect
• A concern that cuts across multiple classses and layers
@Aspect annotation
import org.aspectj.lang.annotation.Aspect;
Any bean with a class
annotated as an aspect
will be automatically
detected by Spring
@Aspect
public class LoggingInterceptor
{
// ...
}
Regular bean definition
pointing to a bean class
with the @Aspect
annotation
<bean id="loggingInterceptor"
class="no.uio.inf5750.interceptor.LoggingInterceptor"/>
14. Declaring a pointcut
• An expression mapped to a join point (method
invocation)
AspectJ pointcut expression that determines
which method executions to intercept
Indicated by the
@Pointcut annotation
Pointcut signature provided by
a regular method definition
@Aspect
Public class LoggingInterceptor
{
@Pointcut( "execution( * no.uio.inf5750.dao.*.*(..) )" )
private void daoLayer() {}
15. Pointcut expression pattern
• The execution pointcut designator is used most often
Pointcut
designator.
Mandatory.
Can use * to
match any type.
Mandatory.
Method name.
Can use * to
match any type.
Mandatory.
Exception type.
Optional.
designator( modifiers return-type declaring-type name(params) throws )
Public, private,
etc. Optional.
Package and
class name.
Optional.
() = no params.
(..) = any nr of params.
(*,String) = one of any
type, one of String.
16. Pointcut expression examples
Any public method
Any public method defined
in the dao package
Any method with a name
beginning with save
Any method defined by the
EventDAO interface with one param
execution( public * *(..) )
execution( public * no.uio.inf5750.dao.*.*(..) )
execution( * save*(..) )
execution( * no.uio.inf5750.dao.EventDAO.*(*) )
17. Declaring advice
• Implementation of concern represented as an interceptor
• Types
– Before advice
– After advice
– Around advice
Before advice.
Executes before the
matched method.
Declared using the
@Before annotation.
Provides access to the
current join point (target object,
description of advised method, ect. )
@Aspect
public class LoggingInterceptor
{
@Before( ”no.uio.inf5750.interceptor.LoggingInterceptor.daoLayer()” )
public void intercept( JoinPoint joinPoint )
{
log.info( ”Executing ” + joinPoint.getSignature().toShortString() );
}
18. After returning & throwing advice
After returning advice.
Executes after the
matched method has
returned normally.
Declared using the
@AfterReturning
annotation.
@Aspect
public class LoggingInterceptor
{
@AfterReturning( ”no.uio.inf5750.interceptor.LoggingInterceptor.daoLayer()” )
public void intercept( JoinPoint joinPoint )
{
log.info( ”Executed successfully ” + joinPoint.getSignature().toShortString() );
}
After throwing advice.
Executes after the
matched method has
thrown an exception.
Declared using
@AfterThrowing.
@Aspect
public class LoggingInterceptor
{
@AfterThrowing( ”no.uio.inf5750.interceptor.LoggingInterceptor.daoLayer()” )
public void intercept( JoinPoint joinPoint )
{
log.info( ”Execution failed ” + joinPoint.getSignature().toShortString() );
}
19. Around advice
• Can do work both before and after the method executes
• Determines when, how and if the method is executed
Around advice.
The first parameter
must be of type
ProceedingJoinPoint –
calling proceed() causes
the target method to
execute.
@Aspect
public class LoggingInterceptor
{
@Around( ”no.uio.inf5750.interceptor.LoggingInterceptor.daoLayer()” )
public void intercept( ProceedingJoinPoint joinPoint )
{
log.info( ”Executing ” + joinPoint.getSignature().toShortString() );
try
{
joinPoint.proceed();
}
catch ( Throwable t )
{
log.error( t.getMessage() + ”: ” + joinPoint.getSignature().toShortString() );
throw t;
}
Declared using the
@Around annotation.
log.info( ”Successfully executed ” + joinPoint.getSignature().toShortString() );
}
20. Accessing arguments
• The args binding form makes argument values available
to the advice body
• Argument name must correspond with advice method
signature
Makes the object
argument available
to the advice body
Will restrict matching
to methods declaring
at least one parameter
@Aspect
public class LoggingInterceptor
{
@Before( ”no.uio.inf5750.interceptor.LoggingInterceptor.daoLayer() and ” +
”args( object, .. )” )
public void intercept( JoinPoint joinPoint, Object object )
{
log.info( ”Executing ” + joinPoint.getSignature().toShortString() +
” with argument ” + object.toString() );
}
21. Accessing return values
• The returning binding form makes the return value
available to the advice body
• Return value name must correspond with advice method
signature
Makes the object
return value
available to the
advice body
Will restrict matching
to methods returning a
value of specified type
@Aspect
public class LoggingInterceptor
{
@AfterReturning(
pointcut=”no.uio.inf5750.interceptor.LoggingInterceptor.daoLayer() ”,
returning=”object” )
public void intercept( JoinPoint joinPoint, Object object )
{
log.info( ”Executed ” + joinPoint.getSignature().toShortString() +
” with return value ” + object.toString() );
}
22. Schema-based support
• Lets you define aspects using the aop namespace tags
in the Spring configuration file
• Enabled by importing the Spring aop schema
• Pointcut expressions and advice types similar to
@AspectJ
• Suitable when:
– You are unable to use Java 5
– Prefer an XML based format
– You need multiple joinpoints for an advice
23. Declaring an aspect
• An aspect is a regular Java object defined as a bean in
the Spring context
All configuration inside
an <aop:config> element
<aop:config>
<aop:aspect id=”logging” ref=”loggingInterceptor”>
Aspect declared using
the <aop:aspect>
element. Backing bean
is referenced
with the ref attribute.
</aop:aspect>
</aop:config>
<bean id="loggingInterceptor"
class="no.uio.inf5750.interceptor.LoggingInterceptor"/>
Regular bean definition
24. Declaring a pointcut
• Pointcut expressions are similar to @AspectJ
• A pointcut can be shared across advice
Pointcut declared inside
<aop:config> element
using the
<aop:pointcut> element
<aop:config>
<aop:pointcut id=”daoLayer”
expression="execution( * no.uio.inf5750.dao.*.*(..) )”/>
</aop:config>
Can also be defined
inside aspects
25. Declaring advice
Before advice.
Declared inside an
aspect.
<aop:aspect id=”logging” ref=”loggingInterceptor”>
<aop:before pointcut-ref=”daoLayer” method=”intercept”/>
</aop:aspect>
Refers to pointcut
Advice is a regular
Java class
public class LoggingInterceptor
{
public void intercept( JoinPoint joinPoint )
{
// Do some useful intercepting work
}
}
Refers to advising method
27. AOP - Transaction Management
TransactionManager
interface
Transaction management
implemented with
around advice
Enters transaction
before method invocation
public interface TransactionManager
{
public void enter();
public void abort();
public void leave();
@Aspect
public interface TransactionInterceptor
{
@Around( ”execution( public no.uio.inf5750.dao.*.*(..) )” ) // In-line pointcut
public void intercept( ProceedingJoinPoint joinPoint )
{
transactionManager.enter();
try
{
joinPoint.proceed();
Aborts and rolls back
transaction if method fails
Leaves transaction if
method completes norm.
}
catch ( Throwable t )
{
transactionManager.abort();
throw t;
}
transactionManager.leave();
28. @AspectJ or Schema-based?
• Advantages of schema style
– Can be used with any JDK level
– Clearer which aspects are present in the system
• Advantages of @AspectJ style
– One single unit where information is encapsulated for an aspect
– Can be understood by AspectJ – easy to migrate later
29. Summary
• Key components in AOP are aspect, pointcut, join point,
and advice
• AOP lets you encapsulate functionality that affects
multiple classes in an interceptor
• Advantages of AOP:
– Promotes separation of concern
– Promotes code reuse and modularization
– Promotes loosely coupled design
30. References
• The Spring reference documentation - Chapter 6
– www.springframework.org
• AOP example code
– www.ifi.uio.no/INF5750/h07/undervisningsplan.xml