From the course: Spring: Design Patterns
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
The Prototype pattern
- [Instructor] Of all the patterns that we're going to talk about on this course, the prototype pattern is the one that I have used the least in raw Java. But it's one that I use quite often in Spring. And we're going to spend quite a bit of time focusing on the Spring side of this pattern. So let's talk about how it's used in Spring. Any bean that has its scope marked as prototype are treated as prototype beans. Now in Spring, the bean configuration itself is what is used as the prototype. In fact, in Java config, the actual bean method gets called every time that you need an instance of that object through the prototype scoping. New instances are created, not cloned as we will see in a traditional Java implementation when needed by the runtime and this is important. None of this work is actually done at startup, it is not done until the instance is actually needed and injected into the application context or the runtime itself. Now the traditional Java pattern is often done through…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
The Factory pattern4m 39s
-
(Locked)
Factory pattern in action5m 38s
-
(Locked)
The Builder pattern2m 55s
-
(Locked)
Builder pattern in action6m 1s
-
(Locked)
The Singleton pattern4m 1s
-
(Locked)
Singleton pattern in action4m 55s
-
(Locked)
The Prototype pattern4m 36s
-
(Locked)
Prototype pattern in action4m 59s
-
-
-
-
-