liveBook · Manning

Wiring

As explained in Spring Start Here, Second Edition

Wiring is the direct establishment of relationships between Spring-managed beans by calling the methods that create them.

Wiring directly links Spring-managed beans by calling the methods that create them. It lets collaborating objects refer to one another; autowiring is a separate approach that uses Spring to provide a reference. section 3.0

Figure 3.1 Having two beans in the Spring context, we want to establish a relationship between them. We do this so that one object can then delegate to the other in the implementation of their responsibilities. You can do this using a wiring approach, which implies directly calling the methods that declare the beans to establish the link between them, or through auto-wiring. You use the framework’s dependency injection capabilities.

See how a relationship between two beans lets one object delegate work to the other, and how wiring differs from autowiring. section 3.1

Person and Parrot

Register a Person and a Parrot as beans with @Bean methods. Before establishing their relationship, Person.getParrot() returns null—a simple way to spot the missing link. section 3.1

How Spring Start Here, Second Edition covers it

How deep it goes
Defines direct bean-method linking and outlines bean registration plus relationship establishment, without detailing the call syntax.
Examples
Uses @Bean methods to register a Person and Parrot, then checks the unlinked Person reference.
What it assumes
Assumes beans are registered in the Spring context before their relationship is established.
What you can do after
Apply it by calling bean-creation methods to link Spring-managed objects after registering them.
How it connects
Distinguishes wiring from autowiring and ties both to dependency injection and the Spring context.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Start Here, Second Edition. The section links point to the parts of the book it draws on.