This week's book giveaway is in the Python forum.
We're giving away four copies of Python Continuous Integration and Delivery and have Moritz Lenz on-line!
See this thread for details.
Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Use of Bean Locator Pattern  RSS feed

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anybody has used 'Bean Locator' pattern in their life?
I have searched experiences using this pattern and I have not found something.
 
Marshal
Posts: 63409
205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not heard of it; let's try duplicating this question in another forum where you might get more attention.
 
Sheriff
Posts: 21641
101
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frameworks like Spring and CDI use it internally. You ask for a bean to be injected, and the framework will locate an appropriate instance and inject that. JNDI look-ups can probably also be seen as the bean locator pattern.
 
Saloon Keeper
Posts: 20508
115
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Bean Locator" is an implementation specific term. Patterns are supposed to be abstract, and what I suspect that what you are looking for is the Service Locator pattern.

Service Locators are resources that code can use to locate a particular set of functions, which are typically defined in terms of an Interface, although you can have a Service Locator return a concrete object as well.

I'll have to contest Rob's claim that resource frameworks such as Spring and CDI use Bean Locators internally. Those frameworks actually implement the Factory pattern and how they work internally is supposed to be opaque to their clients. In fact, it's common for them to keep their beans in an internal Map object (or chain of Maps), but that's purely their decision.

The lines are not clear-cut. A Service Locator is expected to return an existing interface/object, but there's no reason it cannot also manufacture one. I would, however expect a Service Locator to consistently return the same object, whereas a Factory has the option to return multiple instances of an object.

User-designed Factories generally return objects of only one or a small number of class/interface types. Systems like Spring are usually designed to return objects of many different types.

You could use a Service Locator to find a Factory, but in actual practice, the factory is typically a Singleton and located as a static class.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!