List of Listings

Chapter 1. Springing into action

Listing 1.1. EJB 2.1 forced you to implement methods that weren’t needed.

Listing 1.2. Spring doesn’t make any unreasonable demands on HelloWorldBean.

Listing 1.3. A DamselRescuingKnight can only embark on RescueDamselQuests.

Listing 1.4. A BraveKnight is flexible enough to take on any Quest he’s given

Listing 1.5. To test BraveKnight, you’ll inject it with a mock Quest.

Listing 1.6. Injecting a SlayDragonQuest into a BraveKnight with Spring

Listing 1.7. KnightMain.java loads the Spring context containing a knight.

Listing 1.8. A Minstrel is a musically inclined logging system of medieval times

Listing 1.9. A BraveKnight that must call Minstrel methods

Listing 1.10. Declaring the Minstrel as an aspect

Listing 1.11. Many Java APIs, such as JDBC, involve writing a lot of boilerplate code.

Listing 1.12. Templates let your code focus on the task at hand.

Chapter 2. Wiring beans

Listing 2.1. A juggling bean

Listing 2.2. A juggler who waxes poetic

Listing 2.3. A class that represents a great work of the Bard

Listing 2.4. The Stage singleton class

Listing 2.5. Defining a performer who is talented with musical instruments

Listing 2.6. A saxophone implementation of Instrument

Listing 2.7. A piano implementation of Instrument

Listing 2.8. A performer that’s a one-man-band

Listing 2.9. Changing OneManBand’s instrument collection to a Map

Listing 2.10. A list of cities, defined using Spring’s <util:list> element

Chapter 3. Minimizing XML configuration in Spring

Listing 3.1. Use @Qualifier to create your own qualifier annotation.

Listing 3.2. Creating a custom qualifier using JSR-330’s @Qualifier

Chapter 4. Aspect-oriented Spring

Listing 4.1. The Audience class for our talent competition

Listing 4.2. Defining an audience aspect using Spring’s AOP configuration elements

Listing 4.3. Defining a named pointcut to eliminate redundant pointcut definitions

Listing 4.4. The watchPerformance() method provides AOP around advice.

Listing 4.5. Defining a named pointcut to eliminate redundant pointcut definitions

Listing 4.6. Annotating Audience to be an aspect

Listing 4.7. Using @AspectJ annotations to turn a Magician into an aspect

Listing 4.8. Introducing the Contestant interface using @AspectJ annotations

Listing 4.9. An AspectJ implementation of a talent competition judge

Listing 4.10. An implementation of the CriticismEngine used by JudgeAspect

Chapter 5. Hitting the database

Listing 5.1. Using JDBC to insert a row into a database

Listing 5.2. Using JDBC to update a row in a database

Listing 5.3. Using JDBC to query a row from a database

Listing 5.4. A SimpleJdbcTemplate-based addSpitter() method

Listing 5.5. Querying for a Spitter using SimpleJdbcTemplate

Listing 5.6. Using named parameters with Spring JDBC templates

Listing 5.7. Hibernate’s contextual sessions enable Spring-free Hibernate DAOs.

Listing 5.8. A pure JPA DAO doesn’t use any Spring templates.

Chapter 6. Managing transactions

Listing 6.1. saveSpittle() saves a Spittle

Listing 6.2. Programmatically adding transactions to saveSpittle()

Listing 6.3. Annotating the spitter service to be transactional

Chapter 7. Building web applications with Spring MVC

Listing 7.1. <mvc:resources> sets up a handler for serving static resources.

Listing 7.2. HomeController welcomes the user to the Spitter application.

Listing 7.3. A test to assert that the HomeController does its job correctly

Listing 7.4. Tiles defined

Listing 7.5. The home page <div> element will be inserted into the template.

Listing 7.6. A conventional approach to handling requests for a Spitter’s spittles

Listing 7.7. The list.jsp file is a JSP that’s used to display a list of Spittle objects.

Listing 7.8. Displaying the form for registering a spitter

Listing 7.9. Rendering a form to capture user registration information

Listing 7.10. The addSpitter method processes input from the spitter form.

Listing 7.11. Annotating a Spitter for validation

Listing 7.12. The <sf:errors> JSP tag can be used to display form validation errors.

Listing 7.13. addSpitterFromForm() takes a MultipartFile as a parameter.

Listing 7.14. This saveImage() method posts a user’s image to the Amazon S3 cloud

Chapter 8. Working with Spring Web Flow

Listing 8.1. The pizza order flow, defined as a Spring Web Flow

Listing 8.2. An Order carries all of the details pertaining to a pizza order

Listing 8.3. A JSP view that thanks the customer for their order

Listing 8.4. Identifying the hungry pizza customer with a web flow

Listing 8.5. Welcoming the customer and asking for their phone number

Listing 8.6. Registering a new customer

Listing 8.7. Warning a customer that pizza can’t be delivered to their address

Listing 8.8. The order subflow view states to display the order and to create a pizza

Listing 8.9. Adding pizzas to an order with an HTML form bound to a flow-scoped object

Listing 8.10. The payment subflow has one view state and one action state.

Listing 8.11. The PaymentType enumeration defines customer’s choices for payment.

Chapter 9. Securing Spring

Listing 9.1. Adding the Spring Security namespace to a Spring configuration XML file

Listing 9.2. Using the security namespace as the default namespace

Listing 9.3. Spring Security can automatically generate a simple login form for you.

Listing 9.4. The Spitter application uses a custom login page defined as JSP.

Listing 9.5. Conditional rendering with the <security:authorize> tag

Listing 9.6. A sample LDIF file used to load user details into LDAP

Listing 9.7. A permission evaluator provides the logic behind hasPermission()

Chapter 10. Working with remote services

Listing 10.1. SpitterService defines the service layer of the Spitter application.

Listing 10.2. SpringBeanAutowiringSupport on JAX-WS endpoints

Listing 10.3. SimpleJaxWsServiceExporter turns beans into JAX-WS endpoints.

Chapter 11. Giving Spring some REST

Listing 11.1. DisplaySpittleController is a RESTless Spring MVC controller.

Listing 11.2. SpittleController is a RESTful Spring MVC controller.

Listing 11.3. Creating new Spittles with POST

Listing 11.4. ContentNegotiatingViewResolver chooses the best view.

Listing 11.5. REST clients can involve boilerplate code and exception handling.

Listing 11.6. A ResponseEntity includes the HTTP status code.

Chapter 12. Messaging in Spring

Listing 12.1. Sending a message using conventional (non-Spring) JMS

Listing 12.2. Receiving a message using conventional (non-Spring) JMS

Listing 12.3. Sending a Spittle using JmsTemplate

Listing 12.4. Receiving a message using JmsTemplate

Listing 12.5. A Spring MDP asynchronously receives and processes messages.

Listing 12.6. AlertServiceImpl is a JMS-free POJO that will handle JMS messages.

Chapter 13. Managing Spring beans with JMX

Listing 13.1. Annotating HomeController to be an MBean

Listing 13.2. Using a NotificationPublisher to send JMX notifications

Chapter 14. Odds and ends

Listing 14.1. Sending an email with Spring using a MailSender

Listing 14.2. MimeMessageHelper simplifies sending emails with attachments.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset