SlideShare una empresa de Scribd logo
1 de 38
Spring Framework Dhaval   Shah
Contents ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Why Use Spring? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Why Use Spring? ,[object Object],[object Object],[object Object]
Spring Overview ,[object Object],[object Object],[object Object],[object Object],[object Object]
Spring Framework
Spring DI/IoC ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Spring DI/IoC (Cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Spring DI/IoC (Cont’d) ,[object Object],<bean id=&quot;exampleBean&quot; class=&quot;examples.ExampleBean&quot;> <property name=&quot;beanOne&quot;><ref bean=&quot;anotherExampleBean&quot;/></property> <property name=&quot;beanTwo&quot;><ref bean=&quot;yetAnotherBean&quot;/></property> <property name=&quot;integerProperty&quot;>1</property> </bean> <bean id=&quot;anotherExampleBean&quot; class=&quot;examples.AnotherBean&quot;/> <bean id=&quot;yetAnotherBean&quot; class=&quot;examples.YetAnotherBean&quot;/> <bean id=&quot;exampleBean&quot; class=&quot;examples.ExampleBean&quot;> <constructor-arg><ref bean=&quot;anotherExampleBean&quot;/></constructor-arg> <constructor-arg><ref bean=&quot;yetAnotherBean&quot;/></constructor-arg> <constructor-arg><value>1</value></constructor-arg> </bean> <bean id=&quot;anotherExampleBean&quot; class=&quot;examples.AnotherBean&quot;/> <bean id=&quot;yetAnotherBean&quot; class=&quot;examples.YetAnotherBean&quot;/>
Spring DI/IoC (Cont’d) ,[object Object]
Dependency Injection (cont'd) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dependency Injection (cont'd) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Spring AOP
AOP Fundamentals ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
AOP Fundamentals ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
AOP Fundamentals ,[object Object],[object Object],[object Object],[object Object],[object Object]
Spring AOP ,[object Object],Advice Type Interface Description Around org.aopalliance.intercept.MethodInterceptor Intercepts call to the target method Before org.springframework.aop.BeforeAdvice Called before the target method is invoked After org.springframework.aop.AfterReturningAdvice Called after the target method is invoked Throws org.springframework.aop.ThrowsAdvice Called when target method throws an exception
Spring AOP Example
Transactions
Spring Transaction Manager Transaction Manager Implementation Purpose org.springframework.jdbc.datasource.DataSourceTransactionManager Manages transactions on a single JDBC DataSource. org.springframework.orm.hibernate.HibernateTransactionManager Used to manage transactions when Hibernate is the persistence mechanism. org.springframework.orm.jdo.JdoTransactionManager Used to manage transactions when JDO is used for persistence. org.springframework.transaction.jta.JtaTransactionManager Manages transactions using a Java Transaction API (JTA ) implementation. Must be used when a transaction spans multiple resources. org.springframework.orm.ojb.PersistenceBrokerTransactionManager Manages transactions when Apache’s Object Relational Bridge (OJB) is used for persistence.
Transaction Configuration ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Declarative Transactions ,[object Object],[object Object],[object Object]
Injecting Transaction Support <bean id=“reservationService&quot;  class=&quot;org.springframework.transaction.interceptor.TransactionProxyFactoryBean&quot;>  <property name=&quot;transactionManager&quot;> <ref bean=&quot;transactionManager&quot;/> </property>  <property name=&quot;target&quot;><ref local=“reservationServiceTarget&quot;/></property> <property name=&quot;transactionAttributes&quot;>  <props> <prop key=“reserveRoom*&quot;>PROPAGATION_REQUIRED</prop>  <prop key=&quot;*&quot;>PROPAGATION_REQUIRED,readOnly</prop>  </props>  </property>  </bean> Declarative transaction support for single bean
Transaction Autoproxy < bean id=&quot;autoproxy&quot;  class=&quot;org...DefaultAdvisorAutoProxyCreator&quot;> </bean> <bean id=&quot;transactionAdvisor&quot; class=&quot;org...TransactionAttributeSourceAdvisor&quot; autowire =&quot;constructor&quot; > </bean> <bean id=&quot;transactionInterceptor&quot; class=&quot;org...TransactionInterceptor&quot; autowire =&quot;byType&quot;>  </bean> <bean id=&quot;transactionAttributeSource&quot; class=&quot;org...AttributesTransactionAttributeSource&quot; autowire =&quot;constructor&quot;> </bean> <bean id=&quot;attributes&quot; class=&quot;org...CommonsAttributes&quot; /> Caches metadata from classes Generic autoproxy support Applies transaction using transactionManager Invokes interceptor based on attributes
Data Access
Data Access ,[object Object],[object Object],[object Object],[object Object],[object Object]
Hibernate DAO Example public class ReservationDaoImpl extends HibernateDaoSupport  implements ReservationDao { public Reservation getReservation (Long orderId) { return (Reservation)getHibernateTemplate().load(Reservation .class,  orderId); } public void saveReservation (Reservation r) { getHibernateTemplate().saveOrUpdate(r); } public void remove(Reservation Reservation) { getHibernateTemplate().delete(r); }
Hibernate DAO (cont’d) public Reservation[] findReservations(Room room) { List list = getHibernateTemplate().find( &quot;from Reservation reservation “ + “  where reservation.resource =? “ + “  order by reservation.start&quot;, instrument); return (Reservation[]) list.toArray(new Reservation[list.size()]);
Hibernate DAO (cont’d) public Reservation[] findReservations(final DateRange range) { final HibernateTemplate template = getHibernateTemplate(); List list = (List) template.execute(new HibernateCallback() { public Object doInHibernate(Session session) { Query query = session.createQuery( &quot;from Reservation r “ + “  where r.start > :rangeStart and r.start < :rangeEnd “); query.setDate(&quot;rangeStart&quot;, range.getStartDate() query.setDate(&quot;rangeEnd&quot;, range.getEndDate()) return query.list(); } }); return (Reservation[]) list.toArray(new Reservation[list.size()]); } }
Hibernate Example <bean id=&quot;sessionFactory&quot; class=&quot;org.springframework.orm.hibernate.LocalSessionFactoryBean&quot;> <property name=&quot;dataSource&quot;><ref bean=&quot;dataSource&quot;/></property> <property name=&quot;mappingResources&quot;> <list> <value>com/jensenp/Reservation/Room.hbm.xml</value> <value>com/jensenp/Reservation/Reservation.hbm.xml</value> <value>com/jensenp/Reservation/Resource.hbm.xml</value>  </list> </property>  <property name=&quot;hibernateProperties&quot;> <props> <prop key=&quot;hibernate.dialect&quot;>${hibernate.dialect}</prop> <prop key=&quot;hibernate.hbm2ddl.auto&quot;>${hibernate.hbm2ddl.auto} </prop> <prop key=&quot;hibernate.show_sql&quot;>${hibernate.show_sql}</prop> </props> </property> </bean> <bean id=“reservationDao&quot; class=&quot;com.jensenp.Reservation.ReservationDaoImpl&quot;> <property name=&quot;sessionFactory&quot;><ref bean=&quot;sessionFactory&quot;/> </property> </bean>
JDBC Support ,[object Object],[object Object],[object Object],[object Object]
Web Framework
DispatcherServlet ,[object Object],[object Object],[object Object],[object Object]
DispatcherServlet Configuration ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dispatcher Servlet Configuration ,[object Object],[object Object],[object Object],[object Object]
Controllers ,[object Object],[object Object],[object Object]
Controller Implementations ,[object Object],[object Object],[object Object],[object Object],[object Object]
References ,[object Object],[object Object],[object Object],[object Object]

Más contenido relacionado

La actualidad más candente

Exception Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in RubyException Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in RubyWen-Tien Chang
 
Testing untestable Code - PFCongres 2010
Testing untestable Code - PFCongres 2010Testing untestable Code - PFCongres 2010
Testing untestable Code - PFCongres 2010Stephan Hochdörfer
 
Spring training
Spring trainingSpring training
Spring trainingTechFerry
 
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksJSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksMario Heiderich
 
Java 7 new features
Java 7 new featuresJava 7 new features
Java 7 new featuresShivam Goel
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java scriptnanjil1984
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java scriptDivyaKS12
 
Real world dependency injection - DPC10
Real world dependency injection - DPC10Real world dependency injection - DPC10
Real world dependency injection - DPC10Stephan Hochdörfer
 
Random Ruby Tips - Ruby Meetup 27 Jun 2018
Random Ruby Tips - Ruby Meetup 27 Jun 2018Random Ruby Tips - Ruby Meetup 27 Jun 2018
Random Ruby Tips - Ruby Meetup 27 Jun 2018Kenneth Teh
 
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)Joshua Warren
 

La actualidad más candente (17)

Exception Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in RubyException Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in Ruby
 
Testing untestable Code - PFCongres 2010
Testing untestable Code - PFCongres 2010Testing untestable Code - PFCongres 2010
Testing untestable Code - PFCongres 2010
 
Spring training
Spring trainingSpring training
Spring training
 
C++ boot camp part 1/2
C++ boot camp part 1/2C++ boot camp part 1/2
C++ boot camp part 1/2
 
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating FrameworksJSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
 
Java 7 new features
Java 7 new featuresJava 7 new features
Java 7 new features
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
 
Wt unit 4 server side technology-2
Wt unit 4 server side technology-2Wt unit 4 server side technology-2
Wt unit 4 server side technology-2
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
 
Real world dependency injection - DPC10
Real world dependency injection - DPC10Real world dependency injection - DPC10
Real world dependency injection - DPC10
 
Wt unit 5 client &amp; server side framework
Wt unit 5 client &amp; server side frameworkWt unit 5 client &amp; server side framework
Wt unit 5 client &amp; server side framework
 
my test
my testmy test
my test
 
hibernate with JPA
hibernate with JPAhibernate with JPA
hibernate with JPA
 
Random Ruby Tips - Ruby Meetup 27 Jun 2018
Random Ruby Tips - Ruby Meetup 27 Jun 2018Random Ruby Tips - Ruby Meetup 27 Jun 2018
Random Ruby Tips - Ruby Meetup 27 Jun 2018
 
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
 

Similar a Spring overview

Similar a Spring overview (20)

Jsp
JspJsp
Jsp
 
Jsfsunum
JsfsunumJsfsunum
Jsfsunum
 
Spring 2.0
Spring 2.0Spring 2.0
Spring 2.0
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
 
Developing Transactional JEE Apps With Spring
Developing Transactional JEE Apps With SpringDeveloping Transactional JEE Apps With Spring
Developing Transactional JEE Apps With Spring
 
Os Leonard
Os LeonardOs Leonard
Os Leonard
 
Spring 2.0
Spring 2.0Spring 2.0
Spring 2.0
 
Migration testing framework
Migration testing frameworkMigration testing framework
Migration testing framework
 
Struts,Jsp,Servlet
Struts,Jsp,ServletStruts,Jsp,Servlet
Struts,Jsp,Servlet
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
 
Strutsjspservlet
Strutsjspservlet Strutsjspservlet
Strutsjspservlet
 
Uma introdução ao framework Spring
Uma introdução ao framework SpringUma introdução ao framework Spring
Uma introdução ao framework Spring
 
Spring and DWR
Spring and DWRSpring and DWR
Spring and DWR
 
Basic Hibernate Final
Basic Hibernate FinalBasic Hibernate Final
Basic Hibernate Final
 
Struts2
Struts2Struts2
Struts2
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
Custom Action Framework
Custom Action FrameworkCustom Action Framework
Custom Action Framework
 
Seam Introduction
Seam IntroductionSeam Introduction
Seam Introduction
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
C:\fakepath\jsp01
C:\fakepath\jsp01C:\fakepath\jsp01
C:\fakepath\jsp01
 

Más de Dhaval Shah

JVM memory management & Diagnostics
JVM memory management & DiagnosticsJVM memory management & Diagnostics
JVM memory management & DiagnosticsDhaval Shah
 
Transaction boundaries in Microservice Architecture
Transaction boundaries in Microservice ArchitectureTransaction boundaries in Microservice Architecture
Transaction boundaries in Microservice ArchitectureDhaval Shah
 
Anatomy of Test Driven Development
Anatomy of Test Driven DevelopmentAnatomy of Test Driven Development
Anatomy of Test Driven DevelopmentDhaval Shah
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice ArchitectureDhaval Shah
 
OO design principles & heuristics
OO design principles & heuristicsOO design principles & heuristics
OO design principles & heuristicsDhaval Shah
 
Enterprise application performance - Understanding & Learnings
Enterprise application performance - Understanding & LearningsEnterprise application performance - Understanding & Learnings
Enterprise application performance - Understanding & LearningsDhaval Shah
 

Más de Dhaval Shah (7)

JVM memory management & Diagnostics
JVM memory management & DiagnosticsJVM memory management & Diagnostics
JVM memory management & Diagnostics
 
Transaction boundaries in Microservice Architecture
Transaction boundaries in Microservice ArchitectureTransaction boundaries in Microservice Architecture
Transaction boundaries in Microservice Architecture
 
Anatomy of Test Driven Development
Anatomy of Test Driven DevelopmentAnatomy of Test Driven Development
Anatomy of Test Driven Development
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
OO design principles & heuristics
OO design principles & heuristicsOO design principles & heuristics
OO design principles & heuristics
 
Enterprise application performance - Understanding & Learnings
Enterprise application performance - Understanding & LearningsEnterprise application performance - Understanding & Learnings
Enterprise application performance - Understanding & Learnings
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 

Último

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Último (20)

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Spring overview

  • 2.
  • 3.
  • 4.
  • 5.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 14.
  • 15.
  • 16.
  • 17.
  • 20. Spring Transaction Manager Transaction Manager Implementation Purpose org.springframework.jdbc.datasource.DataSourceTransactionManager Manages transactions on a single JDBC DataSource. org.springframework.orm.hibernate.HibernateTransactionManager Used to manage transactions when Hibernate is the persistence mechanism. org.springframework.orm.jdo.JdoTransactionManager Used to manage transactions when JDO is used for persistence. org.springframework.transaction.jta.JtaTransactionManager Manages transactions using a Java Transaction API (JTA ) implementation. Must be used when a transaction spans multiple resources. org.springframework.orm.ojb.PersistenceBrokerTransactionManager Manages transactions when Apache’s Object Relational Bridge (OJB) is used for persistence.
  • 21.
  • 22.
  • 23. Injecting Transaction Support <bean id=“reservationService&quot; class=&quot;org.springframework.transaction.interceptor.TransactionProxyFactoryBean&quot;> <property name=&quot;transactionManager&quot;> <ref bean=&quot;transactionManager&quot;/> </property> <property name=&quot;target&quot;><ref local=“reservationServiceTarget&quot;/></property> <property name=&quot;transactionAttributes&quot;> <props> <prop key=“reserveRoom*&quot;>PROPAGATION_REQUIRED</prop> <prop key=&quot;*&quot;>PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> Declarative transaction support for single bean
  • 24. Transaction Autoproxy < bean id=&quot;autoproxy&quot; class=&quot;org...DefaultAdvisorAutoProxyCreator&quot;> </bean> <bean id=&quot;transactionAdvisor&quot; class=&quot;org...TransactionAttributeSourceAdvisor&quot; autowire =&quot;constructor&quot; > </bean> <bean id=&quot;transactionInterceptor&quot; class=&quot;org...TransactionInterceptor&quot; autowire =&quot;byType&quot;> </bean> <bean id=&quot;transactionAttributeSource&quot; class=&quot;org...AttributesTransactionAttributeSource&quot; autowire =&quot;constructor&quot;> </bean> <bean id=&quot;attributes&quot; class=&quot;org...CommonsAttributes&quot; /> Caches metadata from classes Generic autoproxy support Applies transaction using transactionManager Invokes interceptor based on attributes
  • 26.
  • 27. Hibernate DAO Example public class ReservationDaoImpl extends HibernateDaoSupport implements ReservationDao { public Reservation getReservation (Long orderId) { return (Reservation)getHibernateTemplate().load(Reservation .class, orderId); } public void saveReservation (Reservation r) { getHibernateTemplate().saveOrUpdate(r); } public void remove(Reservation Reservation) { getHibernateTemplate().delete(r); }
  • 28. Hibernate DAO (cont’d) public Reservation[] findReservations(Room room) { List list = getHibernateTemplate().find( &quot;from Reservation reservation “ + “ where reservation.resource =? “ + “ order by reservation.start&quot;, instrument); return (Reservation[]) list.toArray(new Reservation[list.size()]);
  • 29. Hibernate DAO (cont’d) public Reservation[] findReservations(final DateRange range) { final HibernateTemplate template = getHibernateTemplate(); List list = (List) template.execute(new HibernateCallback() { public Object doInHibernate(Session session) { Query query = session.createQuery( &quot;from Reservation r “ + “ where r.start > :rangeStart and r.start < :rangeEnd “); query.setDate(&quot;rangeStart&quot;, range.getStartDate() query.setDate(&quot;rangeEnd&quot;, range.getEndDate()) return query.list(); } }); return (Reservation[]) list.toArray(new Reservation[list.size()]); } }
  • 30. Hibernate Example <bean id=&quot;sessionFactory&quot; class=&quot;org.springframework.orm.hibernate.LocalSessionFactoryBean&quot;> <property name=&quot;dataSource&quot;><ref bean=&quot;dataSource&quot;/></property> <property name=&quot;mappingResources&quot;> <list> <value>com/jensenp/Reservation/Room.hbm.xml</value> <value>com/jensenp/Reservation/Reservation.hbm.xml</value> <value>com/jensenp/Reservation/Resource.hbm.xml</value> </list> </property> <property name=&quot;hibernateProperties&quot;> <props> <prop key=&quot;hibernate.dialect&quot;>${hibernate.dialect}</prop> <prop key=&quot;hibernate.hbm2ddl.auto&quot;>${hibernate.hbm2ddl.auto} </prop> <prop key=&quot;hibernate.show_sql&quot;>${hibernate.show_sql}</prop> </props> </property> </bean> <bean id=“reservationDao&quot; class=&quot;com.jensenp.Reservation.ReservationDaoImpl&quot;> <property name=&quot;sessionFactory&quot;><ref bean=&quot;sessionFactory&quot;/> </property> </bean>
  • 31.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.

Notas del editor

  1. Template closures JDBC support also provided