The document discusses Spring IOC and DAO. It provides an overview of Spring framework, Inversion of Control (IOC) and Dependency Injection in Spring. It also describes how Spring supports data access with JDBC Template and DAO implementations. The JDBC Template simplifies JDBC usage and avoids common errors by providing callback interfaces for writing and reading database operations. Spring DAO classes can extend support classes to get a JDBC or Hibernate template based on the persistence mechanism.
“Program to an interface, not an implementation” they[1] say …
But when IMyInterface foo = new IMyInterface() is not valid code … how are you supposed to achieve that ? The answer is Dependency Injection.
In this talk, we’ll talk about Dependency injection, what it is and what it is not. We’ll see how it is a valuable set of practices and patterns that help design maintainable software built on top of the SOLID object-oriented principles.
We’ll see how, when used properly, it delivers many benefits such as extensibility and testability … We’ll also cover some anti-patterns, ways of using Dependency Injection that can lead to code that is painful to understand and maintain
This talk is not about DI/IOC containers per se, but focuses on the core concepts of Dependency Injection. Those concepts are essential to understand how to use those “magic-looking” tools (if they are needed at all …)
This talk is not only for .NET developers. It will contain code examples written in C#, but should be understandable by developers with knowledge in other statically-typed object-oriented languages such as Java, Vb.NET, C++ …
Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java.Never write another getter or equals method again.
After watching this you will be able to give answer on following Questions
What is lombok?
Why to use project Lombok?
How to integrate/plug lombok project jar with you Eclipse ID?
How to use lombok maven project?
What is @Getter/@Setter annotation in Lombok java?
How Project Lombok works?
What is @NonNull annotation?
What is @ToString annotation?
How to generate Equals and Hashcode using Lombok?
Check all lombok java example
What are the benefits/advantages of using lombok?
Understanding MicroSERVICE Architecture with Java & Spring BootKashif Ali Siddiqui
This is a deep journey into the realm of "microservice architecture", and in that I will try to cover each inch of it, but with a fixed tech stack of Java with Spring Cloud. Hence in the end, you will be get know each and every aspect of this distributed design, and will develop an understanding of each and every concern regarding distributed system construct.
“Program to an interface, not an implementation” they[1] say …
But when IMyInterface foo = new IMyInterface() is not valid code … how are you supposed to achieve that ? The answer is Dependency Injection.
In this talk, we’ll talk about Dependency injection, what it is and what it is not. We’ll see how it is a valuable set of practices and patterns that help design maintainable software built on top of the SOLID object-oriented principles.
We’ll see how, when used properly, it delivers many benefits such as extensibility and testability … We’ll also cover some anti-patterns, ways of using Dependency Injection that can lead to code that is painful to understand and maintain
This talk is not about DI/IOC containers per se, but focuses on the core concepts of Dependency Injection. Those concepts are essential to understand how to use those “magic-looking” tools (if they are needed at all …)
This talk is not only for .NET developers. It will contain code examples written in C#, but should be understandable by developers with knowledge in other statically-typed object-oriented languages such as Java, Vb.NET, C++ …
Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java.Never write another getter or equals method again.
After watching this you will be able to give answer on following Questions
What is lombok?
Why to use project Lombok?
How to integrate/plug lombok project jar with you Eclipse ID?
How to use lombok maven project?
What is @Getter/@Setter annotation in Lombok java?
How Project Lombok works?
What is @NonNull annotation?
What is @ToString annotation?
How to generate Equals and Hashcode using Lombok?
Check all lombok java example
What are the benefits/advantages of using lombok?
Understanding MicroSERVICE Architecture with Java & Spring BootKashif Ali Siddiqui
This is a deep journey into the realm of "microservice architecture", and in that I will try to cover each inch of it, but with a fixed tech stack of Java with Spring Cloud. Hence in the end, you will be get know each and every aspect of this distributed design, and will develop an understanding of each and every concern regarding distributed system construct.
The introduction of Project Lombok, a combination compile-time and development-time code generator, has made Java POJO verbosity history. Add Lombok to your daily coding practices, and you won't go back.
This session compares the Spring and Java EE stacks in terms of Web frameworks. It re-examines the motivations behind the Spring framework and explores the emergence of the Java EE programming model to meet the challenges posed. The presentation provides insight into when Spring and/or Java EE is appropriate for a building Web applications and if they can coexist.
Welcome to presentation on Spring boot which is really great and relatively a new project from Spring.io. Its aim is to simplify creating new spring framework based projects and unify their configurations by applying some conventions. This convention over configuration is already successfully applied in so called modern web based frameworks like Grails, Django, Play framework, Rails etc.
Frameworks are large prewritten code to which you add your own code to solve a problem in a specific domain.
You make use of a framework by calling its methods,inheritance,and supplying “call-backs” listeners.
Spring is the most popular application development framework for enterprise Java™.
Millions of developers use Spring to create high performing, easily testable, reusable code without any lock-in.
University of Colorado PhD software engineering student Aaron Schram explains the details of creating a web applications using the Spring MVC framework
Microservices pattern language (microxchg microxchg2016)Chris Richardson
My talk from http://microxchg.io/2016/index.html.
Here is the video - https://www.youtube.com/watch?v=1mcVQhbkA2U
When architecting an enterprise Java application, you need to choose between the traditional monolithic architecture consisting of a single large WAR file, or the more fashionable microservices architecture consisting of many smaller services. But rather than blindly picking the familiar or the fashionable, it’s important to remember what Fred Books said almost 30 years ago: there are no silver bullets in software. Every architectural decision has both benefits and drawbacks. Whether the benefits of one approach outweigh the drawbacks greatly depends upon the context of your particular project. Moreover, even if you adopt the microservices architecture, you must still make numerous other design decisions, each with their own trade-offs.
A software pattern is an ideal way of describing a solution to a problem in a given context along with its tradeoffs. In this presentation, we describe a pattern language for microservices. You will learn about patterns that will help you decide when and how to use microservices vs. a monolithic architecture. We will also describe patterns that solve various problems in a microservice architecture including inter-service communication, service registration and service discovery.
Migrating .NET Application to .NET CoreBaris Ceviz
"Migrate .NET Application to .NET Core with scenarios" presentation in Dotnetkonf. How to migrate .NET Desktop, ASP.NET MVC & Web API or WCF Service applications to .NET Core
This Express Js tutorial will walk you through what express js is, what we can do with it, features of express js and companies that are hiring express js developers. Express Js is a Node Js framework which helps to write the API’s very efficiently. It’s a awesome framework of node js which is helping Backend development so much and it provides wide set of features to develop both web and mobile applications it is used to build single page, multipage and hybrid web applications.
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, StrongerDataStax
Apache Cassandra 2.0 is out - now there's no reason not to ditch that ol' legacy relational system for your important online applications. Cassandra 2.0 includes big impact features like Light Weight Transactions and Triggers. Do you know about the other new enhancements that got lost in the noise. Let's put the spotlight on all the things! Changes in memory management, file handling and internals. Low hype but they pack a big punch. While we were at it, we also did a bit of house cleaning.
The introduction of Project Lombok, a combination compile-time and development-time code generator, has made Java POJO verbosity history. Add Lombok to your daily coding practices, and you won't go back.
This session compares the Spring and Java EE stacks in terms of Web frameworks. It re-examines the motivations behind the Spring framework and explores the emergence of the Java EE programming model to meet the challenges posed. The presentation provides insight into when Spring and/or Java EE is appropriate for a building Web applications and if they can coexist.
Welcome to presentation on Spring boot which is really great and relatively a new project from Spring.io. Its aim is to simplify creating new spring framework based projects and unify their configurations by applying some conventions. This convention over configuration is already successfully applied in so called modern web based frameworks like Grails, Django, Play framework, Rails etc.
Frameworks are large prewritten code to which you add your own code to solve a problem in a specific domain.
You make use of a framework by calling its methods,inheritance,and supplying “call-backs” listeners.
Spring is the most popular application development framework for enterprise Java™.
Millions of developers use Spring to create high performing, easily testable, reusable code without any lock-in.
University of Colorado PhD software engineering student Aaron Schram explains the details of creating a web applications using the Spring MVC framework
Microservices pattern language (microxchg microxchg2016)Chris Richardson
My talk from http://microxchg.io/2016/index.html.
Here is the video - https://www.youtube.com/watch?v=1mcVQhbkA2U
When architecting an enterprise Java application, you need to choose between the traditional monolithic architecture consisting of a single large WAR file, or the more fashionable microservices architecture consisting of many smaller services. But rather than blindly picking the familiar or the fashionable, it’s important to remember what Fred Books said almost 30 years ago: there are no silver bullets in software. Every architectural decision has both benefits and drawbacks. Whether the benefits of one approach outweigh the drawbacks greatly depends upon the context of your particular project. Moreover, even if you adopt the microservices architecture, you must still make numerous other design decisions, each with their own trade-offs.
A software pattern is an ideal way of describing a solution to a problem in a given context along with its tradeoffs. In this presentation, we describe a pattern language for microservices. You will learn about patterns that will help you decide when and how to use microservices vs. a monolithic architecture. We will also describe patterns that solve various problems in a microservice architecture including inter-service communication, service registration and service discovery.
Migrating .NET Application to .NET CoreBaris Ceviz
"Migrate .NET Application to .NET Core with scenarios" presentation in Dotnetkonf. How to migrate .NET Desktop, ASP.NET MVC & Web API or WCF Service applications to .NET Core
This Express Js tutorial will walk you through what express js is, what we can do with it, features of express js and companies that are hiring express js developers. Express Js is a Node Js framework which helps to write the API’s very efficiently. It’s a awesome framework of node js which is helping Backend development so much and it provides wide set of features to develop both web and mobile applications it is used to build single page, multipage and hybrid web applications.
Cassandra Community Webinar | Cassandra 2.0 - Better, Faster, StrongerDataStax
Apache Cassandra 2.0 is out - now there's no reason not to ditch that ol' legacy relational system for your important online applications. Cassandra 2.0 includes big impact features like Light Weight Transactions and Triggers. Do you know about the other new enhancements that got lost in the noise. Let's put the spotlight on all the things! Changes in memory management, file handling and internals. Low hype but they pack a big punch. While we were at it, we also did a bit of house cleaning.
How Twitter Works (Arsen Kostenko Technology Stream) IT Arena
Lviv IT Arena is a conference specially designed for programmers, designers, developers, top managers, inverstors, entrepreneurs and startuppers. Annually it takes place at the beginning of October in Lviv at Arena Lviv stadium. In 2016 the conference gathered more than 1800 participants and over 100 speakers from companies like Microsoft, Philips, Twitter, UBER and IBM. More details about the conference at itarena.lviv.ua.
Dependency Injection and Inversion Of ControlSimone Busoli
This is a short presentation I gave back in 2008 at the UgiAlt.Net conference in Milan about inversion of control and dependency injection principles. Examples use Castle project's Windsor container.
Metrics at Scale @ UBER (Mantas Klasavicius Technology Stream)IT Arena
Lviv IT Arena is a conference specially designed for programmers, designers, developers, top managers, inverstors, entrepreneurs and startuppers. Annually it takes place at the beginning of October in Lviv at Arena Lviv stadium. In 2016 the conference gathered more than 1800 participants and over 100 speakers from companies like Microsoft, Philips, Twitter, UBER and IBM. More details about the conference at itarena.lviv.ua.
This presentation goes through what Inversion of Control is, which IOC patterns that exists, which of the patterns you should use and when you should use them.
AMAZON INTERVIEW QUESTIONS FOR SOFTWARE ENGINEERING JOBS
AMAZON Interview Questions for SDE/SDE-T jobs divided In following eight areas ?
[1]. General Areas Questions
[2]. PAST EXPERIENCE AREAS Questions
[3]. Algorithms Questions
[4]. Coding Questions
[5]. TECHNICAL AREAS Questions
[6]. TEST AREAS Questions
[7]. THOUGHT PROCESS Questions
[8]. PROFESSIONAL’S DEFINITION
discuss about System system analysis, system design, system analyst's role, Development of System through analysis, SDLC, Case Tools of SAD, Implementation, etc.
Neo4j is a powerful and expressive tool for storing, querying and manipulating data. However modeling data as graphs is quite different from modeling data under a relational database. In this talk, Michael Hunger will cover modeling business domains using graphs and show how they can be persisted and queried in Neo4j. We'll contrast this approach with the relational model, and discuss the impact on complexity, flexibility and performance.
In this Java Spring Training session, you will learn Spring – Inversion of Control, Dependency Injection and Bean definitions. Topics covered in this session are:
For more information, visit this link:
Spring Framework
• Core Container
• Data Access/Integration
• Web Layer
• Spring Setup
• Key features
• Spring Bean
• Dependency Injection
• Relation between DI and IoC
• Spring IoC Containers
• Spring DI
https://www.mindsmapped.com/courses/software-development/spring-fundamentals-learn-spring-framework-and-spring-boot/
Session 43 - Spring - Part 1 - IoC DI BeansPawanMM
In this session you will learn:
1.Spring Framework
2. Core Container
3. Data Access/Integration
4. Web Layer
5. Spring Setup
6. Key features
7. Spring Bean
8. Dependency Injection
9. Relation between DI and IoC
10. Spring IoC Containers
11. Spring DI
Introduction
Framework Modules
Spring Dependencies
Dependency Injection
The IoC Container
Spring IoC Container and Beans
XML-based Configuration Metadata
XML-based Beans
Instantiation of Beans
Dependency Injection
Bean Scopes
Depends On & Lazy-initialized Beans
Customizing the Nature of a Bean
Using PropertyPlaceholderConfigurer
https://notebookbft.wordpress.com/
TUTORIAL-INTRODUCTION TO SPRING FOR BEGINNERS
EXPLANATION TO-Java Framework,Advantages of using SPRING,Difference between Hibernate and Spring.Spring architecture,Spring IoC Containters,Bean scope & Method Injection,Spring Inheritance.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
11. Well designed Easy to extend Many reusable classes. Spring substantially reduces code, speeds up development, facilitates easy testing and improves code quality Adlux Consultancy Services Pvt. Ltd.
13. Spring Modules The Core container module AOP module (Aspect Oriented Programming) JDBC abstraction and DAO module O/R mapping integration module (Object/Relational) Web module MVC framework module Adlux Consultancy Services Pvt. Ltd.
14. Inversion of Control (IOC) Instead of objects invoking other objects, the dependant objects are added through an external entity/container. Inversion of Control is the general style of using Dependency Injection to wire the application. Also known as the Hollywood principle – “don’t call me I will call you”. IoC is all about Object dependencies. Prevents hard-coded object creation and object/service lookup. Loose coupling Helps write effective unit tests. Adlux Consultancy Services Pvt. Ltd.
19. Testability is improved because your Objects don't know or care what environment they're in as long as someone injects their dependencies. Hence you can deploy Objects into a test environment and inject Mock Objects for their dependencies with ease.Adlux Consultancy Services Pvt. Ltd.
20. Pull Example public class BookDemoServiceImpl implements BookDemoService { public void addPublisherToBook(Book book) { BookDemoFactory factory = BookDemoFactory.getFactory(); BookDemoDaodao = factory.getBookDemoDao(); String isbn = book.getIsbn(); if (book.getPublisher() == null && isbn != null) { Publisher publisher = dao.findPublisherByIsbn(isbn); book.setPublisher(publisher); } } } Adlux Consultancy Services Pvt. Ltd.
21. Push Example (Dependency Injection) public class BookDemoServiceImpl implements BookDemoService { private BookDemoDaodao; public void addPublisherToBook(Book book) { String isbn = book.getIsbn(); if (book.getPublisher() == null && isbn != null) { Publisher publisher = dao.findPublisherByIsbn(isbn); book.setPublisher(publisher); } } public void setBookDemoDao(BookDemoDaodao) { this.dao = dao; } } Adlux Consultancy Services Pvt. Ltd.
22. Spring IOC The IoC container is the core component of the Spring Framework A bean is an object that is managed by the IoC container The IoC container is responsible for containing and managing beans Spring comes with two types of containers – BeanFactory – ApplicationContext Adlux Consultancy Services Pvt. Ltd.
40. The bean class is the actual implementation of the bean being described by the BeanFactory.
41. Spring will manage the scope of the beans for you. No need for doing it programmaticallyScopes singleton : A single bean definition to a single object instance. Only one shared instance will ever be created by the container The single bean instance will be stored in cache and returned for all requests. Singleton beans are created at container startup-time Singleton is default scope in Spring <bean id=“bean1” class=“Example” scope=“singleton”/> prototype : A new bean instance will be created for each request Use prototype scope for stateful beans – singleton scope for stateless beans <bean id=“bean1” class=“Example” scope=“prototype”/> Adlux Consultancy Services Pvt. Ltd.
42. request Scopes a single bean definition to the lifecycle of a single HTTP request; that is each and every HTTP request will have its own instance of a bean created off the back of a single bean definition. Only valid in the context of a Spring ApplicationContext. session Scopes a single bean definition to the lifecycle of a HTTP Session. Only valid in the context of a Spring ApplicationContext. global session Scopes a single bean definition to the lifecycle of a global HTTP Session. Typically only valid when used in a portlet context. Only valid in the context of a Spring ApplicationContext. request , session , global session scopes are used for spring web applications. Adlux Consultancy Services Pvt. Ltd.
43. Injecting dependencies via constructor Constructor-based DI is effected by invoking a constructor with a number of arguments, each representing a dependency Example of a class that could only be dependency injected using constructor injection. public class BankingAccountImpl{ // the BankingAccountImpl has a dependency on a BankDao Private BankDaobankDao; // a constructor so that the Spring container can 'inject' a BankDao public BankingAccountImpl(BankDaobankDao) { this. bankDao = bankDao; } // business logic that actually 'uses' the injected BankDao object } Adlux Consultancy Services Pvt. Ltd.
44. Injecting dependencies via setter methods Setter-based DI is realized by calling setter methods on your beans after invoking a no-arugument constructor. public class EmployeeRegister { // the EmployeeRegister has a dependency on the Employee private Employee employee; // a setter method so that the Spring container can 'inject' Employee public void setEmployee(Employee employee) { this.employee = employee; } // business logic that actually 'uses' the injected Employee Object } Adlux Consultancy Services Pvt. Ltd.
47. Autowiring Properties Beans may be auto-wired (rather than using <ref>) Per-bean attribute autowire Explicit settings override autowire=“name” Bean identifier matches property name autowire=“type” Type matches other defined bean autowire=”constructor” Match constructor argument types autowire=”autodetect” Attempt by constructor, otherwise “type” Adlux Consultancy Services Pvt. Ltd.
50. Application Layering A clear separation of application component responsibility. - Presentation layer • Concentrates on request/response actions. • Handles UI rendering from a model. • Contains formatting logic and non-business related validation logic. - Persistence layer • Used to communicate with a persistence store such as a relational database. • Provides a query language • Possible O/R mapping capabilities • JDBC, Hibernate, iBATIS, JDO, Entity Beans, etc. - Domain layer • Contains business objects that are used across above layers. • Contain complex relationships between other domain objects. • Domain objects should only have dependencies on other domain objects. Adlux Consultancy Services Pvt. Ltd.
51. What is DAO: J2EE developers use the Data Access Object (DAO) design pattern to separate low-level data access logic from high-level business logic. Implementing the DAO pattern involves more than just writing data access code. DAO stands for data access object, which perfectly describes a DAO’s role in an application. DAOs exist to provide a means to read and write data to the database .They should expose this functionality through an interface by which the rest of the application will access them. Adlux Consultancy Services Pvt. Ltd.
52. Spring’s JDBC API: Why not just use JDBC •Connection management •Exception Handling •Transaction management •Other persistence mechanisms Spring Provides a Consistent JDBC Abstraction • Spring Helper classes •JdbcTemplate • Dao Implementations • Query and BatchQueries Adlux Consultancy Services Pvt. Ltd.
53. Data Access Support for DAO implementations • implicit access to resources • many operations become one-liners • no try/catch blocks anymore Pre-built integration classes • JDBC: JdbcTemplate • Hibernate: HibernateTemplate • JDO: JdoTemplate • TopLink: TopLinkTemplate • iBatis SQL Maps: SqlMapClientTemplate Adlux Consultancy Services Pvt. Ltd.
73. Writing Data: public class InsertAccountStatementCreator implements PreparedStatementCreator { public PreparedStatement createPreparedStatement( Connection conn) throws SQLException { String sql = "insert into abbas_bank_acc(acc_no, acc_holder_name, balance) values (?, ?, ?)"; return conn.prepareStatement(sql); } } Public class InsertAccountStatementSetter implements PreparedStatementSetter{ public void setValues(PreparedStatement ps) throws SQLException { ps.setInt(0, account.getAccno()); ps.setString(1, account.getAcc_holder_name()); ps.setString(2, account.getBalance()); } Adlux Consultancy Services Pvt. Ltd.
74. Reading Data: public class BankAccountRowMapper implements RowMapper { public Object mapRow(ResultSet rs, int index) throws SQLException { BankAccount account = new BankAccount(); account.setAccno(rs.getInt("acc_no")); account.setAcc_holder_name(rs.getString("acc_holder_name")); account.setBalance(rs.getDouble("balance")); } return account; } public List selectAccounts() { String sql = "select * from abbas_bank_acc"; return getJdbcTemplate().query(sql, new BankAccountRowMapper()); } Adlux Consultancy Services Pvt. Ltd.
75. JDBC Template Methods: execute(String sql) : Issue a single SQL execute, typically a DDL statement. execute(CallableStatementCreator csc,CallableStatementCa llback action) : Execute a JDBC data access operation, implemented as callback action working on a JDBC CallableStatement. execute(PrepatedStatementCreator csc,PreparedStatementCa llback action) : Execute a JDBC data access operation, implemented as callback action working on a JDBC PreparedStatement. Adlux Consultancy Services Pvt. Ltd.
76. JDBC Template Methods: query(String sql, Object[] args, int[] argTypes, RowCallbackHandler rch) : Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, reading the ResultSet on a per-row basis with a RowCallbackHandler. query(String sql, Object[] args, int[] argTypes, RowMapper rowMapper) : Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping each row to a Java object via a RowMapper. update(String sql, Object[] args) : Issue a single SQL update operation (such as an insert, update or delete statement) via a prepared statement, binding the given arguments. Adlux Consultancy Services Pvt. Ltd.
77. Example for a JDBC-based DAO public class BankDaoImpl extends JdbcDaoSupport implements BankDAO { public void createAccount(BankAccount account) { getJdbcTemplate().execute(“insert into bank_acc values(“+accno+”,”+name+”,”+balance+”)”); } public void deleteAccount(int accno) { String sql = "delete from abbas_bank_acc where acc_no=?"; getJdbcTemplate().update(sql,new Object[]{new Integer(accno)}); } public BankAccount selectAccount(int accno) { String sql = "select * from bank_acc where acc_no=?"; final BankAccount account = new BankAccount(); getJdbcTemplate().query(sql,new Object[]{accno},new RowCallbackHandler(){ public void processRow(ResultSet rs) throws SQLException { account.setAccno(rs.getInt("acc_no")); account.setAcc_holder_name(rs.getString("acc_holder_name")); account.setBalance(rs.getDouble("balance")); } }); return account; } public List selectAccounts() { String sql = "select * from bank_acc"; return getJdbcTemplate().queryForList("select * from bank_acc where accno="+accno); public void updateAccount(BankAccount account) { String sql = "update bank_acc set balance=? where acc_no=?"; getJdbcTemplate().update(sql, new Object[]{account.getBalance(),account.getAccno()}); }}
104. Configuring Springs’ Hibernate Template <bean id="hibernateTemplate" class="org.springframework.orm.hibernate.HibernateTemplate"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="studentDao" class="com.adlux..dao.hibernate.StudentDaoHibernate"> <property name="hibernateTemplate"> <ref bean="hibernateTemplate"/> </property> </bean> <bean id="courseDao" class="com.adlux. dao.hibernate.CourseDaoHibernate"> <property name="hibernateTemplate"> <ref bean="hibernateTemplate"/> </property> </bean> Configuring a HibernateTemplate class Wiring Template class with multiple DAO objects. Adlux Consultancy Services Pvt. Ltd.
105. Hibernate Template Spring framework provides template class for Hibernate framework, which helps release the programmer from writing some repetitive codes. This template class is called HibernateTemplate. Using HibernateTemplate and HibernateCallback public Student getStudent(final Integer id) { return (Student) hibernateTemplate.execute( new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { return session.load(Student.class, id); } }); } Adlux Consultancy Services Pvt. Ltd.
106.
107. Hibernate Template Methods hibernate.load(Class entityClass, Serializable id) Return the persistent instance of the given entity class with the given identifier, throwing an exception if not found. hibernate.save(Object entity) Persist the given transient instance. hibernate.update(Object entity) Update the given persistent instance, associating it with the current Hibernate Session. Adlux Consultancy Services Pvt. Ltd.
108. Examples Using HibernateTemplate List employees = hibernatetemplate.find("from Credit"); List list = hibernatetemplate.find("from Credit c where c.cardtype=?", “Master card”); Save Credit c = new Credit(5121212121212124, ”Master card”,……); hibernatetemplate.save(c); Load & Update Credit e = (Employee) hibernatetemplate.load(Credit.class, cardno); c.setFirstName(“Anusha"); hibernatetemplate.update(e); Adlux Consultancy Services Pvt. Ltd.
113. We can make our DAO class extends HibernateDaoSupport instead of injecting the instance of HibernateTemplate to each DAO class.
114. Also provides many other methods like getSession() , closeSessionIfNecessary()Adlux Consultancy Services Pvt. Ltd.
115. Example for Spring Dao extending HibernateDaoSupport public class ExampleHibernateDAO extends HibernateDaoSupport { public void insertEmployee(Employee emp) { getHibernateTemplate().save(emp); } public List getAllEmployees() { return getHibernateTemplate().find("from Employee"); } public List findEmployeebyName(String ename) { return getHibernateTemplate().find("from Employee emp where emp.firstname=?", ename); } public void deleteEmployee(String empid) { getHibernateTemplate().delete(getHibernateTemplate().load( Employee.class, empid)); } public void updateEmployee(String empid) { Employee e = (Employee) getHibernateTemplate().load( Employee.class, empid); e.setFirstname("Anusha"); getHibernateTemplate().update(e); } } Adlux Consultancy Services Pvt. Ltd.
116. WriningsessionFactory to our DAO class <bean id="ExampleDao" class=“com.adlux.dao.ExampleHibernateDao"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> Adlux Consultancy Services Pvt. Ltd.
117. Examples using HibernateTemplate and plain hibernate Hibernate Only : public User getUserByEmailAddress(final String email) { try { Session session =getsessionFactory().openSession(); List list = session.find( "from User user where user.email=‘”+ email+”’”); return (User) list.get(0); } Catch (Exception e){ e.printstackTrace(); } finally {session.close(); } } Hibernate Template : public User getUserByEmailAddress(final String email) { List list = getHibernateTemplate().find( "from User user where user.email=?”, email); return (User) list.get(0); } Adlux Consultancy Services Pvt. Ltd.
118. Consistent exception hierarchy in spring Spring provides a convenient translation from technology specific exceptions like SQLException and HibernateException to its own exception hierarchy with the DataAccessException as the root exception. DataAccessException is a RuntimeException, so it is an unchecked exception. Our code will not be required to handle these exceptions when they are thrown by the data access tier. DataAccessException is the root of all Spring DAO exceptions Adlux Consultancy Services Pvt. Ltd.