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.

Prototype pattern in action

Prototype pattern in action

From the course: Spring: Design Patterns

Start my 1-month free trial

Prototype pattern in action

- [Instructor] So now that we've talked a little bit about the prototype pattern I want to show you how it's used in the Spring Framework as opposed to the Java Framework this time. So let's jump into our IDE and just like we've done a couple times before let's create a new package in our base package And this time we're going to call it Prototype. Now we're going to create two very dumb classes here and the first we're going to call ProtoTrue and the second we're going to call ProtoFalse Now we're not going to do anything with either one of these classes as far as implementation. What we are going to do is jump into the Design Patterns App application. Alright, so in this class we're going to create a Bean. Public ProtoFalse and we'll simply call it that and we will return a new ProtoFalse object. Now we're going to do another Bean and this time we're going to set it Scope to be equal to prototype. Now we're going to do a public ProtoTrue and we will return a new ProtoTrue. Now, in…

Contents