|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.roscopeco.janno.util.BeanBindingCollector
public class BeanBindingCollector
Simple utility class that collects instances of
BeanBinding. This can be used
by view processing servlets (for example) to ensure they get all bindings
from the request line, rather than just those from the request stack
itself.
ComponentAdapter) with an appropriate instance
of CollectionComponentParameter instantiated with the
BeanBinding class. When instantiated, all instances of
BeanBinding will be injected via the constructor, and used to build
an internal map from String (coerced from the
ComponentAdapter key) to the BeanBinding
instance from the container. The binding is queried each time a bean is
looked up, allowing custom bindings to use some other type of lookup
as necessary, and as well as providing convienient access to the beans
themselves (by simply querying the binding) this class provides methodised
access to the binding itself.
Do note, however, that only a single
PicoContainer.getComponentInstance(java.lang.Object) will be made
by any given collector for any given BeanBinding implementation
registered in the request line tree.
Like the bindings themselves, this class is immutable, and should therefore
be safe for use across multiple threads.
| Constructor Summary | |
|---|---|
BeanBindingCollector(Map<?,?> bindings)
Create a new BeanBindingCollector from the specified map. |
|
| Method Summary | |
|---|---|
static BeanBindingCollector |
collectFrom(PicoContainer pico)
Convienience method that automatically obtains a BeanCollector with all BeanBindings visible in a given
PicoContainer. |
Object |
getBean(String key)
Convienience method that will directly obtain the bean bound to a given key. |
BeanBinding |
getBinding(String key)
Obtain the BeanBinding with a given key. |
protected Map<String,BeanBinding> |
getBindings()
Provides subclass-access to the binding map. |
Set<String> |
keySet()
Returns a set of strings with all the bound bean-names. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BeanBindingCollector(Map<?,?> bindings)
BeanBindingCollector from the specified map.
Each entry will be copied from the supplied map, with keys coerced to
Strings. Passing null is equivalent to
passing an empty map.
When instantiating a collector from a request-line container, you must
use a CollectionComponentParameter
with the BeanBinding
bindings - A map containing string-to-BeanBindings. This
is copied to the binding map (with forced string keys).
ClassCastException - if an invalid BeanBinding
implementation is encountered. If this occurs you should ensure
that you are correctly registering the collector with a
CollectionComponentParameter
initialized with the BeanBinding class (and
not the BeanBindingCollector class
itself, for example).| Method Detail |
|---|
public static BeanBindingCollector collectFrom(PicoContainer pico)
BeanBindings visible in a given
PicoContainer.
pico - The PicoContainer from which bindings
should be collected (directly or by inheritence).
BeanBindingCollector with all bean-bindings visible
to the specified pico.public Set<String> keySet()
Set of valid bean names.public Object getBean(String key)
getBinding(String)) and returns the instance from it's
BeanBinding.get() method. If no binding is found with
the specified key, this method throws
IllegalArgumentException.
key - The String key.
IllegalArgumentException - if the specified key is not
bound.public BeanBinding getBinding(String key)
BeanBinding with a given key.
key - The String key.
BeanBinding that was collected with the
specified key (never null).
IllegalArgumentException - if the specified key is not
bound.protected Map<String,BeanBinding> getBindings()
List<String,BeanBinding>
held by this collector.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||