This video is an exercise about creating and leveraging singletons from external code and having the framework utilize it.
- So now that we've talked a little bit about … the singleton pattern, let's jump into our ID's and let's … go create some. … So back in our project, let's open up source main java … and our base package and once again as we've done before … we'll create a new package this one called singleton. … Now we're going to create a couple classes in here. … The first one we're going to create is SingA. … SingA is going to be our traditional singleton so we're … going to start with private static SingA instance. … Then we're going to make a private constructor on this guy. … Now we're going to make a public static SingA method … called getInstance and you can see that IntelliJ knows … what I'm doing here. … It's suggesting names of methods and stuff for me. … It kind of gives the feeling that this is a singleton. … But we'll go ahead and continue to create ours so if null … equals instance and I do prefer yoda syntax … with my null checks. … We will now synchronize on the class itself. … This gives us a great spot to synchronize on 'cause that's …
AuthorFrank P Moley III
- The patterns of the Spring framework
- Creational patterns in Spring
- The adapter and decorator pattern in action
- Structural patterns in Spring
- The repository pattern in action
- The observer, command, and mediator patterns
Skill Level Intermediate
What you should know1m 28s
1. Design Patterns and Spring
2. Creational Patterns in Spring
3. Structural Patterns in Spring
4. Operational Patterns in Spring
5. Other Framework Patterns in Spring
Next steps3m 27s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.