Webwarp Util Registry
General
The module provides a simple object registry. By default the registry
is based on Spring. The registry allows static access to object
instances that is independent of the underlying component
model.
Class Overview
- net.sf.webwarp.util.registry.Registry:
Registry Interface.
- net.sf.webwarp.util.registry.RegistryUtil:
Class holding the current registered registry instance.
- net.sf.webwarp.util.registry.spring.RegistrySpringImpl
is a Spring based implementation of a registry. The class
registers itself in RegistryUtil when instantiated.
Using the registry
Initializing the registry
For
using the registry the corresponding registry implementation must be
instantiated. As a default implementation a Spring based registry
implementation is available, that programmatically is instantiated as
follows:
new net.sf.webwarp.util.registry.spring.SpringRegistryImpl();
or within a Spring context:
<bean id="Registry" class="net.sf.webwarp.util.registry.spring.RegistrySpringImpl" />
Accessing the registry
The registry can be accessed using the net.sf.webwarp.util.registry.RegistryUtil
class:
import net.sf.webwarp.util.registry.Registry;
import net.sf.webwarp.util.registry.RegstryUtil;
[...]
Registry registry = RegistryUtil.getRegistry();
Object byName = registry.getBean("BeanName");
Object byClass = registry.getBean(MyBean.class);
Collection<MyBean> allByClass = getBeans(MyBean.class);
Webwarp Util