Core Spring 5 Certification in Detail

Core Spring 5 Certification in Detail

Core Spring 5 Certification in Detail Ivan Krizsan Version: 2019-02-04 Core Spring 5 Certification in Detail by Ivan Krizsan Copyright © 2018-2019 by Ivan Krizsan All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. Exempted from this legal reservation is material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, these names, symbols etc are only used in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. While the information in this book is believed to be true and accurate at the date of publication, no legal responsibility for any errors or omissions is accepted. The author makes no warranty, express or implied, with respect to the material contained herein. Cover from Max Pixel licensed under the Creative Commons Zero – CC0 license. 1 Core Spring 5 Certification in Detail by Ivan Krizsan Introduction This book contains a walk-through of the Core Spring 5 certification topics. The text is deliberately kept brief. Please consult the references for in-depth discussions. My recommendation to those aspiring to gain thorough knowledge of the topics covered by the Core Spring certification is to try to answer each and every topic and before reading this document. Organization This book is organized according to the Pivotal Core Spring Certification Study Guide available at the time of writing. There are eight major sections: • Container, Dependency and IoC • Aspect Oriented Programming • Data Management • Spring Boot • Spring MVC and the Web Layer • Security • REST • Testing 2 Core Spring 5 Certification in Detail by Ivan Krizsan Table of Contents Introduction..........................................................................................................................................2 Organization.........................................................................................................................................2 Table of Contents..................................................................................................................................3 Container, Dependency and IoC.........................................................................................................11 What is dependency injection and what are the advantages?........................................................12 What is a pattern? What is an anti-pattern? Is dependency injection a pattern?............................13 What is a pattern?......................................................................................................................13 What is an anti-pattern?............................................................................................................13 Is dependency injection a pattern?............................................................................................13 What is an interface and what are the advantages of making use of them in Java?......................14 Why are interfaces recommended for Spring beans?................................................................14 What is meant by application-context?..........................................................................................15 What is the concept of a “container” and what is its lifecycle?.....................................................16 How are you going to create a new instance of an ApplicationContext?......................................18 Non-Web Applications..............................................................................................................18 AnnotationConfigApplicationContext.................................................................................18 Web Applications......................................................................................................................19 Servlet 2 – ContextLoaderListener and web.xml.................................................................19 Servlet 2 – ContextLoaderListener, DispatcherServlet and web.xml..................................19 Servlet 3 – Web Application Initializers...............................................................................20 Servlet 3 – XmlWebApplicationContext..............................................................................21 Servlet 3 – AnnotationConfigWebApplicationContext........................................................22 Can you describe the lifecycle of a Spring Bean in an ApplicationContext?................................23 How are you going to create an ApplicationContext in an integration test?.................................25 JUnit 4 Example........................................................................................................................25 JUnit 5 Example........................................................................................................................25 Web Application Context..........................................................................................................26 What is the preferred way to close an application context? Does Spring Boot do this for you?...28 Standalone Application.............................................................................................................28 Web Application........................................................................................................................28 Spring Boot Closing Application Context.................................................................................28 Dependency Injection, Component Scanning, Meta-Annotations and Bean Scopes....................29 Describe dependency injection using Java configuration.........................................................29 Describe dependency injection using annotations (@Component, @Autowired)....................29 Describe component scanning, Stereotypes and Meta-Annotations.........................................30 Component scanning............................................................................................................30 Stereotype Annotations.........................................................................................................31 Meta-Annotations.................................................................................................................31 Describe scopes for Spring beans? What is the default scope?.................................................32 Are beans lazily or eagerly instantiated by default? How do you alter this behavior?..................33 What is a property source? How would you use @PropertySource?............................................34 What is a BeanFactoryPostProcessor and what is it used for? When is it invoked?.....................35 When is a bean factory post processor invoked?......................................................................35 Why would you define a static @Bean method?......................................................................35 What is a ProperySourcesPlaceholderConfigurer used for?.....................................................36 3 Core Spring 5 Certification in Detail by Ivan Krizsan What is a BeanPostProcessor and how is it different to a BeanFactoryPostProcessor? What do they do? When are they called?.....................................................................................................37 BeanPostProcessor....................................................................................................................37 BeanFactoryPostProcessor........................................................................................................37 What is an initialization method and how is it declared on a Spring bean?..............................38 What is a destroy method, how is it declared and when is it called?........................................40 Consider how you enable JSR-250 annotations like @PostConstruct and @PreDestroy? When/how will they get called?...........................................................................................42 How else can you define an initialization or destruction method for a Spring bean?..........42 What does component-scanning do?.............................................................................................42 What is the behavior of the annotation @Autowired with regards to field injection, constructor injection and method injection?.....................................................................................................43 @Autowired and Field Injection...............................................................................................44 @Autowired and Constructor Injection....................................................................................44 @Autowired and Method Injection...........................................................................................45 What do you have to do, if you would like to inject something into a private field? How does this impact testing?...............................................................................................................................47

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    221 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us