Spring in Practice
eBook - ePub

Spring in Practice

Joshua White, Willie Wheeler

Compartir libro
  1. 560 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Spring in Practice

Joshua White, Willie Wheeler

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

Summary Spring in Practice shows you how to tackle the challenges you face when you build Spring-based applications. The book empowers software developers to solve concrete business problems by mapping application-level issues to Spring-centric solutions. It diverges from other cookbooks because it presents the background you need to understand the domain in which a solution applies before it offers the specific steps to solve the problem. About this Book Spring in Practice covers 66 Spring development techniques and the practical issues you will encounter when using them. The book starts with three carefully crafted introductory chapters to get you up to speed on the fundamentals. And then, the core of the book takes you step-by-step through the important, practical techniques you will use no matter what type of application you're building. You'll hone your Spring skills with examples on user accounts, security, NoSQL data stores, and application integration. Along the way, you'll explore Spring-based approaches to domain-specific challenges like CRM, configuration management, and site reliability. What's Inside

  • Covers Spring 3
  • Successful outcomes with integration testing
  • Dozens of web app techniques using Spring MVC
  • Practical examples and real-world context
  • How to work effectively with data


Each technique highlights something new or interesting about Spring and focuses on that concept in detail. This book assumes you have a good foundation in Java and Java EE. Prior exposure to Spring Framework is helpful but not required.Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the Authors Willie Wheeler is a Principal Applications Engineer with 16 years of experience in Java/Java EE and Spring Framework. Joshua White is a Solutions Architect in the financial and health services industries. He has worked with Spring Framework since its inception in 2002. Table of Contents

  • Introducing Spring: the dependency injection container
  • Data persistence, ORM, and transactions
  • Building web applications with Spring Web MVC
  • Basic web forms
  • Enhancing Spring MVC applications with Web Flow
  • Authenticating users
  • Authorizing user requests
  • Communicating with users and customers
  • Creating a rich-text comment engine
  • Integration testing
  • Building a configuration management database
  • Building an article-delivery engine
  • Enterprise integration
  • Creating a Spring-based "site-up" framework

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Spring in Practice un PDF/ePUB en línea?
Sí, puedes acceder a Spring in Practice de Joshua White, Willie Wheeler en formato PDF o ePUB, así como a otros libros populares de Computer Science y Programming in Java. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Editorial
Manning
Año
2013
ISBN
9781638353782

Chapter 1. Introducing Spring: the dependency injection container

This chapter covers
  • Major functional areas of the Spring Framework
  • Flexible configuration using dependency injection
  • Wiring beans using XML
  • Autowiring and component scanning using annotations
In this chapter, we’ll provide a brief overview of the Spring Framework, beginning with a discussion of what Spring is and giving an overview of its major pieces. Then we’ll delve into the underlying principles behind the Spring Framework, and talk about inversion of control and how it relates to dependency injection. Finally, we’ll dive into a small example that shows how to use the Spring Core Container hands-on. Let’s get started.

1.1. What is Spring, and why use it?

The Spring Framework is an open source application framework created to simplify the development of enterprise Java software. The framework achieves this goal by providing developers with a component model and a set of simplified and consistent APIs that effectively insulate developers from the complexity and error-prone boilerplate code required to create complex applications.
Over the last nine years, the breadth and depth of the framework has increased significantly, yet it has remained simple to learn and easy to use. The framework has evolved into roughly 20 modules that can be grouped into 6 basic functional areas. As shown in figure 1.1, these functional areas are Data Access/Integration, Web, Aspect-Oriented Programming (AOP), Instrumentation, the Core Container, and Test.
Figure 1.1. A high-level block diagram illustrating Spring’s six basic functional areas
This modularity gives developers the freedom to choose which parts of the framework to use in their applications without the need to include the entire framework. Let’s begin our tour by looking at each of these functional areas.

1.1.1. The major pieces of the framework

In the paragraphs that follow, we’ll give you a brief introduction to each of Spring’s six basic functional areas. We’ll take a deeper dive into each of these topics as we work through individual recipes later in the book.
The Core Spring Container
We’ll further dissect what dependency injection (DI) is in section 1.2. For now, it’s enough to know that the DI container is at the core of the Spring Framework and provides the fundamental capabilities on which all the other modules are built. The container provides the facility for decoupling the creation, configuration, and management of beans (discussed later) from your application code.
Aspect-oriented programming (AOP)
The Spring Framework also supports aspect-oriented programming with both a simpler approach called Spring AOP and the more powerful AspectJ approach. AOP, which is covered in more detail later, aims to encapsulate cross-cutting concerns (security, logging, transaction management, and so on) into aspects to retain modularity and reusability. These concerns often can’t be cleanly decomposed from the rest of the system and can result in code duplication, significant dependencies between systems, or both. Like the DI container, AOP support is both independently useful to developers and used to implement different parts of framework functionality. For example, Spring implements its support for declarative transaction management through AOP because transactions are a cross-cutting concern.
Data Access/Integration
The Data Access/Integration module provides support for the Java Database Connectivity API (JDBC), object-relational mapping (ORM), Object/XML mapping (OXM), Java Message Service (JMS), and transactional support.
The JDBC module provides an abstraction layer that relieves developers from having to write tedious and error-prone boilerplate code by automatically managing database connections and connection pools, and by mapping vendor-specific errors into a uniform exception hierarchy. It also makes it easy to map java.sql.ResultSets to lists of domain objects and execute stored procedures.
If you prefer to use ORM instead of straight JDBC for database access code, you’re in luck. The ORM module supports the best and most popular ORMs available, including Hibernate, iBATIS, Java Data Objects (JDO), and the Java Persistence API (JPA).
A quick note about iBATIS
Apache iBATIS was retired in 2010 and has been superseded by MyBatis (mybatis.org). Although iBATIS 2 has been supported since Spring 2, due to release timing issues, Spring 3 doesn’t yet include official support for it. See the MyBatis-Spring module at www.mybatis.org/spring.
The OXM module provides an abstraction layer that offers simplified and consistent support for popular Object/XML mapping tools such as Castor, the Java Architecture for XML Binding (JAXB), JiBX, XMLBeans, and XStream.
The JMS module provides simplified APIs for producing and consuming messages. Finally, the Transaction module provides support for both programmatic and declarative transaction management.
Web
Spring’s Web module provides common web infrastructure code for integrating Spring into web applications, multipart file upload, and web-based remoting capabilities. In addition to providing its own servlet- or portlet-based Model-View-Controller (MVC) framework, this module integrates with popular web-development frameworks and technologies like Struts, JavaServer Faces (JSF), Velocity, FreeMarker, and JavaServer Pages (JSP).
Test
Last but not least in the framework stack is Spring’s testing support. This module provides support for using both the JUnit and TestNG frameworks.
Now that we’ve provided a high-level overview of the Spring Framework, let’s discuss the benefits of using the framework.

1.1.2. Why use it?

You may have worked with or even developed other frameworks or APIs that handle one or more of the Spring Framework’s concerns. Why would you stop to learn something that requires a fairly substantial time investment? In addition to providing you with a component model and a simplified and consistent set of APIs that effectively insulate developers from complexity and error-prone boilerplate code, here are other reasons:
  • Quality— From the overall design of the modules, packages, class structures, and APIs to the implementation and test coverage of the source code, the Spring Framework is a great example of high-quality open source software.
  • Modularity— As we mentioned earlier, the framework has evolved into roughly 20 modules, giving developers the freedom to choose which parts of the framework to use in their applications without the need to include the entire framework.
  • Promotes best practices— Spring’s plain old Java object (POJO)-based programming model promotes decoupled component models, unit testing, and other best practices.
  • Modest learning curve— Due to the consistency and simplicity of the APIs, Spring isn’t hard to learn. As we make our way through the framework, you’ll see that common patterns emerge. Plus, hundreds of resources online and in print are at your disposal, including message boards where the core developers often participate.
  • Popularity— As evidenced by myriad publications, websites, and job postings, the Spring Framework is almost ubiquitous.
For an excellent print reference that will certainly be of aid during your journey with this book, check out Craig Walls’ Spring in Action, 3rd Edition (Manning Publications, 2011).
Spring offers a lot, and it takes time to understand and appreciate the landscape. But rest assured that the effort is well worth it. By learning Spring and using it to solve problems, you’ll see how to bring together disparate technologies and incorporate them into cohesive applications. You’ll keep hardcoded configuration parameters out of your classes and centralized in standard locat...

Índice