File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Information about Design Patterns used by Spring. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Information about Design Patterns used by Spring." Watch "Information about Design Patterns used by Spring." New topic

Information about Design Patterns used by Spring.

pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 415

Hi Craig,

I have read Spring in Action second edition. I loved it! But I was missing something called design patterns. Book explain each feature very well and in detail. But I was looking for the design patterns that spring developers have used to implement those features. Understanding the design behind each feature makes me more confident of using a feature without any doubt and makes me confident to explain the client who doesn't know spring but aware of design patterns. Can we see such things in third edition?

Pawan Chopra
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1323

The only one i know Singleton, in spring config file defined beans are singleton by default.

[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Craig Walls
Ranch Hand

Joined: Sep 19, 2003
Posts: 335

I wouldn't consider the design patterns under the covers of Spring as being "in Action" kind of topics. I don't disagree that they might be interesting reading material...just not the subject of an "in Action" kind of book.

If you're curious about the underlying design, I strongly encourage you to check the code out of SVN (or Git, depending on which piece of the Spring portfolio you're interested in) and read it. the code. You'll learn a lot. And you'll also question a lot of decisions made. As you question those decisions, try to answer the "why" for yourself--I find trying to do that helps me understand the mindset of the developer who wrote it. If you get stuck, feel free to ask on the forums--I'm sure someone will be happy to help you.

But I wouldn't concern myself too much with the specific design pattern names--those are good, no doubt, for communicating the dsign. But the main thing is to understand why that pattern was chosen.

As for "singleton" which was mentioned: Be careful to not confuse a singleton bean with the singleton design pattern. The singleton design pattern (of which I've seen a handful of different approaches) is intended to ensure a single instance of any given type within an application. A singleton bean, on the other hand, only guarantees that Spring will not create another instance of the bean as you defined it. You are still able to create your own instances of it and even Spring might create more instances of it if you define another bean of the same type. In short, the singleton design pattern is a stronger concept than the singleton bean. (Even then, the singleton design pattern is not a strong enough concept to guarantee a unique instance universally--you could certainly create more instance in another JVM.)

Spring in Action - Unleash POJO power in your applications!
Modular Java - Discover the secret weapon to modularity on the Java platform!
XDoclet in Action - Your complete guide to code generation with XDoclet.
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 415

Thanks Craig! Would love to see some books on those topics as well
Hitesh Singh

Joined: Mar 04, 2010
Posts: 9
As I know is that Spring Framework & Design pattern is made by ROD Johnson. First he build Design pattern & based on that he made spring framework because spring framework has implemented many design pattern concepts like singleton,factory,prototype,Decorator etc.

prototype is for creating mutiple bean instance.
Decorator is for cross cutting functionality..

I agree. Here's the link:
subject: Information about Design Patterns used by Spring.
It's not a secret anymore!