SlideShare a Scribd company logo
1 of 31
[object Object],[object Object]
 
[object Object],[object Object]
Class can be constructed in different ways  ,[object Object]
Using a constructor that takes an  int  argument which indicates the number of beanbags that the  Juggler will attempt to keep in the air
factory-created beans through the  <bean>  element’s  factory-method  attribute.
[object Object]
[object Object],Constructor Default <bean id=&quot;duke&quot; class=&quot;com.springinaction.springidol.Juggler&quot; /> Juggler juggler = new Juggler();  Constructor with primitive type <bean id=&quot;duke&quot; class=&quot;com.springinaction.springidol.Juggler&quot;>  <constructor-arg value=&quot;15&quot; /> </bean>  Juggler juggler = new Juggler(15);  Constructor with primitive type and an referecence to another bean. <bean id=&quot;sonnet29&quot; class=&quot;com.springinaction.springidol.Sonnet29&quot; />  <bean id=&quot;poeticDuke&quot; class=&quot;com.springinaction.springidol.PoeticJuggler&quot;>  <constructor-arg value=&quot;15&quot; />  <constructor-arg ref=&quot;sonnet29&quot; />  </bean>  Poem sonnet29 = new Sonnet29();  Performer duke = new PoeticJuggler(15, sonnet29);  Constructor with factory - method <bean id=&quot;theStage&quot; class=&quot;com.springinaction.springidol.Stage&quot;  factory-method=&quot;getInstance&quot; / >  public static Stage getInstance() { return StageSingletonHolder.instance; }
[object Object]
[object Object],[object Object],[object Object]
[object Object],[object Object]
Differents types of wiring: ,[object Object],[object Object],[object Object],[object Object]
don’t have an  id  attribute set.  not necessary because  you’ll never refer to the inner bean by name
they can’t be reused . They're  only useful for injection once  and  can’t be referred to by other beans ,[object Object],[object Object]
[object Object],Simple Properties: <bean id=&quot;kenny&quot; class=&quot;com.springinaction.springidol.Instrumentalist&quot;> <property name=&quot;song&quot; value=&quot;Jingle Bells&quot; /> <property name=&quot;age&quot; value=&quot;37&quot; /> </bean>  Referring other beans: <bean id=&quot;saxophone&quot; class=&quot;com.springinaction.springidol.Saxophone&quot; />  <bean id=&quot;kenny2&quot; class=&quot;com.springinaction.springidol.Instrumentalist&quot;>  <property name=&quot;song&quot; value=&quot;Jingle Bells&quot; />  <property name=&quot;instrument&quot; ref=&quot;saxophone&quot; />  </bean>  Inner Beans <bean id=&quot;kenny&quot; class=&quot;com.springinaction.springidol.Instrumentalist&quot;>  <property name=&quot;song&quot; value=&quot;Jingle Bells&quot; /> <property name=&quot;instrument&quot;>  <bean class=&quot;org.springinaction.springidol.Saxophone&quot; />  </property>  </bean>  <bean id=&quot;duke&quot; class=&quot;com.springinaction.springidol.PoeticJuggler&quot;>  <constructor-arg value=&quot;15&quot; /> <constructor-arg>  <bean class=&quot;com.springinaction.springidol.Sonnet29&quot; />  </constructor-arg>  </bean>
[object Object],Simple Properties: <bean id=&quot;kenny&quot; class=&quot;com.springinaction.springidol.Instrumentalist&quot;> <property name=&quot;song&quot; value=&quot;Jingle Bells&quot; /> <property name=&quot;age&quot; value=&quot;37&quot; /> </bean>  Referring other beans: <bean id=&quot;saxophone&quot; class=&quot;com.springinaction.springidol.Saxophone&quot; />  <bean id=&quot;kenny2&quot; class=&quot;com.springinaction.springidol.Instrumentalist&quot;>  <property name=&quot;song&quot; value=&quot;Jingle Bells&quot; />  <property name=&quot;instrument&quot; ref=&quot;saxophone&quot; />  </bean>  Inner Beans <bean id=&quot;kenny&quot; class=&quot;com.springinaction.springidol.Instrumentalist&quot;>  <property name=&quot;song&quot; value=&quot;Jingle Bells&quot; /> <property name=&quot;instrument&quot;>  <bean class=&quot;org.springinaction.springidol.Saxophone&quot; />  </property>  </bean>  <bean id=&quot;duke&quot; class=&quot;com.springinaction.springidol.PoeticJuggler&quot;>  <constructor-arg value=&quot;15&quot; /> <constructor-arg>  <bean class=&quot;com.springinaction.springidol.Sonnet29&quot; />  </constructor-arg>  </bean>
[object Object],[object Object]
polirmorfismo  ,[object Object]
[object Object],Simple Properties: <bean id=&quot;kenny&quot; class=&quot;com.springinaction.springidol.Instrumentalist&quot;> <property name=&quot;song&quot; value=&quot;Jingle Bells&quot; /> <property name=&quot;age&quot; value=&quot;37&quot; /> </bean>  Referring other beans: <bean id=&quot;saxophone&quot; class=&quot;com.springinaction.springidol.Saxophone&quot; />  <bean id=&quot;kenny2&quot; class=&quot;com.springinaction.springidol.Instrumentalist&quot;>  <property name=&quot;song&quot; value=&quot;Jingle Bells&quot; />  <property name=&quot;instrument&quot; ref=&quot;saxophone&quot; />  </bean>  Inner Beans <bean id=&quot;kenny&quot; class=&quot;com.springinaction.springidol.Instrumentalist&quot;>  <property name=&quot;song&quot; value=&quot;Jingle Bells&quot; /> <property name=&quot;instrument&quot;>  <bean class=&quot;org.springinaction.springidol.Saxophone&quot; />  </property>  </bean>  <bean id=&quot;duke&quot; class=&quot;com.springinaction.springidol.PoeticJuggler&quot;>  <constructor-arg value=&quot;15&quot; /> <constructor-arg>  <bean class=&quot;com.springinaction.springidol.Sonnet29&quot; />  </constructor-arg>  </bean>
[object Object],[object Object]
Set
Map
Properties
[object Object],[object Object]
A <list> may contain another <list> as a member for multidi-mensional lists.
Either <list> or <set> can be used to wire any implementation of java.util.Collection or an array
[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
<props>   is the element used to define a collection value of type  java.util .Properties .
<prop>   is the element used to define a member of a  <props>  collection
SpEL Overview ,[object Object]

More Related Content

Viewers also liked

Design Pattern - 3. Decorator pattern
Design Pattern - 3. Decorator patternDesign Pattern - 3. Decorator pattern
Design Pattern - 3. Decorator patternFrancesco Ierna
 
Design Pattern 5. Singleton Pattern
Design Pattern 5. Singleton PatternDesign Pattern 5. Singleton Pattern
Design Pattern 5. Singleton PatternFrancesco Ierna
 
SCBCD 2. differenze stateless stateful
SCBCD 2. differenze stateless   statefulSCBCD 2. differenze stateless   stateful
SCBCD 2. differenze stateless statefulFrancesco Ierna
 
Design Pattern 4. Factory Pattern
Design Pattern 4. Factory PatternDesign Pattern 4. Factory Pattern
Design Pattern 4. Factory PatternFrancesco Ierna
 

Viewers also liked (9)

Design Pattern - 3. Decorator pattern
Design Pattern - 3. Decorator patternDesign Pattern - 3. Decorator pattern
Design Pattern - 3. Decorator pattern
 
Design Pattern 5. Singleton Pattern
Design Pattern 5. Singleton PatternDesign Pattern 5. Singleton Pattern
Design Pattern 5. Singleton Pattern
 
SCDJWS 6. REST JAX-P
SCDJWS 6. REST  JAX-PSCDJWS 6. REST  JAX-P
SCDJWS 6. REST JAX-P
 
SCDJWS 1. xml schema
SCDJWS 1. xml schemaSCDJWS 1. xml schema
SCDJWS 1. xml schema
 
SCBCD 2. differenze stateless stateful
SCBCD 2. differenze stateless   statefulSCBCD 2. differenze stateless   stateful
SCBCD 2. differenze stateless stateful
 
SCDJWS 2. Soap
SCDJWS 2. SoapSCDJWS 2. Soap
SCDJWS 2. Soap
 
SCDJWS 3. WSDL
SCDJWS 3. WSDLSCDJWS 3. WSDL
SCDJWS 3. WSDL
 
Design Pattern 4. Factory Pattern
Design Pattern 4. Factory PatternDesign Pattern 4. Factory Pattern
Design Pattern 4. Factory Pattern
 
SCBCD 1. generic ejb
SCBCD 1. generic ejbSCBCD 1. generic ejb
SCBCD 1. generic ejb
 

Similar to 2. wiring beans

Hibernate Session 2
Hibernate Session 2Hibernate Session 2
Hibernate Session 2b_kathir
 
JSUG - Spring by Christoph Pickl
JSUG - Spring by Christoph PicklJSUG - Spring by Christoph Pickl
JSUG - Spring by Christoph PicklChristoph Pickl
 
Krazykoder struts2 data_tags
Krazykoder struts2 data_tagsKrazykoder struts2 data_tags
Krazykoder struts2 data_tagsKrazy Koder
 
Struts Tags Speakernoted
Struts Tags SpeakernotedStruts Tags Speakernoted
Struts Tags SpeakernotedHarjinder Singh
 
Beautiful Java EE - PrettyFaces
Beautiful Java EE - PrettyFacesBeautiful Java EE - PrettyFaces
Beautiful Java EE - PrettyFacesLincoln III
 
Intro To Hibernate
Intro To HibernateIntro To Hibernate
Intro To HibernateAmit Himani
 
Beginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptBeginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptStoyan Stefanov
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With BloggingTakatsugu Shigeta
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat ToolKanika2885
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat ToolKanika2885
 

Similar to 2. wiring beans (20)

Spring 2.0
Spring 2.0Spring 2.0
Spring 2.0
 
Spring 2.0
Spring 2.0Spring 2.0
Spring 2.0
 
Sping Slide 6
Sping Slide 6Sping Slide 6
Sping Slide 6
 
Hibernate Session 2
Hibernate Session 2Hibernate Session 2
Hibernate Session 2
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
JSUG - Spring by Christoph Pickl
JSUG - Spring by Christoph PicklJSUG - Spring by Christoph Pickl
JSUG - Spring by Christoph Pickl
 
JSP Custom Tags
JSP Custom TagsJSP Custom Tags
JSP Custom Tags
 
Ant
Ant Ant
Ant
 
Using Forms in Share
Using Forms in ShareUsing Forms in Share
Using Forms in Share
 
Krazykoder struts2 data_tags
Krazykoder struts2 data_tagsKrazykoder struts2 data_tags
Krazykoder struts2 data_tags
 
displaytag
displaytagdisplaytag
displaytag
 
Seam Glassfish Slidecast
Seam Glassfish SlidecastSeam Glassfish Slidecast
Seam Glassfish Slidecast
 
Struts Tags Speakernoted
Struts Tags SpeakernotedStruts Tags Speakernoted
Struts Tags Speakernoted
 
Beautiful Java EE - PrettyFaces
Beautiful Java EE - PrettyFacesBeautiful Java EE - PrettyFaces
Beautiful Java EE - PrettyFaces
 
Intro To Hibernate
Intro To HibernateIntro To Hibernate
Intro To Hibernate
 
Spring overview
Spring overviewSpring overview
Spring overview
 
Beginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScriptBeginning Object-Oriented JavaScript
Beginning Object-Oriented JavaScript
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With Blogging
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
 

Recently uploaded

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

2. wiring beans

  • 1.
  • 2.  
  • 3.
  • 4.
  • 5. Using a constructor that takes an int argument which indicates the number of beanbags that the Juggler will attempt to keep in the air
  • 6. factory-created beans through the <bean> element’s factory-method attribute.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. don’t have an id attribute set. not necessary because you’ll never refer to the inner bean by name
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. Set
  • 22. Map
  • 24.
  • 25. A <list> may contain another <list> as a member for multidi-mensional lists.
  • 26. Either <list> or <set> can be used to wire any implementation of java.util.Collection or an array
  • 27.
  • 28.
  • 29. <props> is the element used to define a collection value of type java.util .Properties .
  • 30. <prop> is the element used to define a member of a <props> collection
  • 31.
  • 32. #{} markers  : We could wire this value into a bean’s property by using #{} markers in a <property> element’s value
  • 33.
  • 35.
  • 36.
  • 37.
  • 38. byType —Attempts to match all properties of the autowired bean with beans whose types are assignable to the properties. Properties for which there’s no matching bean will remain unwired.
  • 39. constructor —Tries to match up a constructor of the autowired bean with beans whose types are assignable to the constructor arguments
  • 40. autodetect —Attempts to apply constructor autowiring first. If that fails, byType will be tried
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48. @Controller : Indicates that the class defines a Spring MVC controller
  • 49. @Repository : Indicates that the class defines a data repository
  • 50.
  • 51.
  • 53. <!-- bean declarations go here --> </beans> <bean id=&quot;kenny2&quot; class=&quot;com.springinaction.springidol.Instrumentalist&quot;> …. <property name=&quot;instrument&quot; ref=&quot;saxophone&quot; /> </bean> Autowiring byType: @Autowired public void setInstrument(Instrument instrument) { this.instrument = instrument; } Autowiring byType not in a setter method: @Autowired public void heresYourInstrument(Instrument instrument) { this.instrument = instrument; } Autowiring byConstructor: @Autowired public Instrumentalist(Instrument instrument) { this.instrument = instrument; } Autowiring in a private field: @Autowired private Instrument instrument. @Qualifier annotation will try to wire in a bean whose ID matches guitar. @Autowired @Qualifier(&quot;guitar&quot;) private Instrument instrument
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.