org.codehaus.waffle.registrar.pico
Class PicoRegistrar

java.lang.Object
  extended by org.codehaus.waffle.registrar.pico.PicoRegistrar
All Implemented Interfaces:
Registrar, ScriptedRegistrar

public class PicoRegistrar
extends java.lang.Object
implements ScriptedRegistrar

This Registrar is backed by PicoContainer for managing Dependency Injection. This registrar is passed to the custom registrar defined in the web.xml as a delegate.

Author:
Michael Ward, Mauro Talevi

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.codehaus.waffle.registrar.Registrar
Registrar.Injection
 
Constructor Summary
PicoRegistrar(org.picocontainer.MutablePicoContainer picoContainer, ParameterResolver parameterResolver, org.picocontainer.LifecycleStrategy lifecycleStrategy, RegistrarMonitor registrarMonitor, org.picocontainer.ComponentMonitor componentMonitor, MessageResources messageResources)
           
 
Method Summary
 void application()
          Components registered in this method will be availables for the life of the Application.
 java.lang.Object getRegistered(java.lang.Object typeOrInstance)
          Returns a registered component
 boolean isRegistered(java.lang.Object typeOrInstance)
          Determines if a component is already registered
 Registrar register(java.lang.Class<?> type, java.lang.Object... parameters)
          Registers a component in the current context.
 Registrar register(java.lang.Object key, java.lang.Class<?> type, java.lang.Object... parameters)
          Registers a component in the current context under the given key.
 void registerCachedComponentAdapter(org.picocontainer.ComponentAdapter<?> componentAdapter)
           
 Registrar registerInstance(java.lang.Object instance)
          Registers a component instance directly in the current context.
 Registrar registerInstance(java.lang.Object key, java.lang.Object instance)
          Registers a component instance directly in the current context under the given key.
 Registrar registerNonCaching(java.lang.Class<?> type, java.lang.Object... parameters)
          Registers a component in non-caching mode, ie with new instance created for each class with a defined dependency
 Registrar registerNonCaching(java.lang.Object key, java.lang.Class<?> type, java.lang.Object... parameters)
          Registers a component under the given key in non-caching mode, ie with new instance created for each class with a defined dependency
 void registerScript(java.lang.String key, java.lang.String scriptedClassName)
          Register a script with Waffle
 void registerUnCachedComponentAdapter(org.picocontainer.ComponentAdapter<?> componentAdapter)
           
 void request()
          Components registered in this method will be availables for the life of a request.
 void session()
          Components registered in this method will be availables for the life of a Users session.
 Registrar useInjection(Registrar.Injection injection)
          Use the given injection type for component instantiation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PicoRegistrar

public PicoRegistrar(org.picocontainer.MutablePicoContainer picoContainer,
                     ParameterResolver parameterResolver,
                     org.picocontainer.LifecycleStrategy lifecycleStrategy,
                     RegistrarMonitor registrarMonitor,
                     org.picocontainer.ComponentMonitor componentMonitor,
                     MessageResources messageResources)
Method Detail

useInjection

public Registrar useInjection(Registrar.Injection injection)
Description copied from interface: Registrar
Use the given injection type for component instantiation. Defaults to Registrar.Injection.CONSTRUCTOR.

Specified by:
useInjection in interface Registrar
Parameters:
injection - the Injection to use
Returns:
The Registrar

isRegistered

public boolean isRegistered(java.lang.Object typeOrInstance)
Description copied from interface: Registrar
Determines if a component is already registered

Specified by:
isRegistered in interface Registrar
Parameters:
typeOrInstance - the component Class type or Object instance/key
Returns:
A boolean flag, true if component is registered

getRegistered

public java.lang.Object getRegistered(java.lang.Object typeOrInstance)
Description copied from interface: Registrar
Returns a registered component

Specified by:
getRegistered in interface Registrar
Parameters:
typeOrInstance - the component Class type or Object instance/key
Returns:
The registered component instance

register

public Registrar register(java.lang.Class<?> type,
                          java.lang.Object... parameters)
Description copied from interface: Registrar
Registers a component in the current context.

Specified by:
register in interface Registrar
Parameters:
type - represents both the key and type the object will be registered under
parameters - any parameters needed to satisfy the component being registered
Returns:
The current Registrar which allows for chaining registration calls.

register

public Registrar register(java.lang.Object key,
                          java.lang.Class<?> type,
                          java.lang.Object... parameters)
Description copied from interface: Registrar
Registers a component in the current context under the given key.

Specified by:
register in interface Registrar
Parameters:
key - represents the key the object will be registered under
type - represents the component type
parameters - any parameters needed to satisfy the component being registered
Returns:
The current Registrar which allows for chaining registration calls.

registerInstance

public Registrar registerInstance(java.lang.Object instance)
Description copied from interface: Registrar
Registers a component instance directly in the current context.

Specified by:
registerInstance in interface Registrar
Parameters:
instance - to be registered
Returns:
The current Registrar which allows for chaining registration calls.

registerInstance

public Registrar registerInstance(java.lang.Object key,
                                  java.lang.Object instance)
Description copied from interface: Registrar
Registers a component instance directly in the current context under the given key.

Specified by:
registerInstance in interface Registrar
Parameters:
key - the key the instance is to be registered under
instance - to be registered
Returns:
The current Registrar which allows for chaining registration calls.

registerNonCaching

public Registrar registerNonCaching(java.lang.Class<?> type,
                                    java.lang.Object... parameters)
Description copied from interface: Registrar
Registers a component in non-caching mode, ie with new instance created for each class with a defined dependency

Specified by:
registerNonCaching in interface Registrar
Parameters:
type - represents both the key and type the object will be registered under
parameters - any parameters needed to satisfy the component being registered
Returns:
The current Registrar which allows for chaining registration calls.

registerNonCaching

public Registrar registerNonCaching(java.lang.Object key,
                                    java.lang.Class<?> type,
                                    java.lang.Object... parameters)
Description copied from interface: Registrar
Registers a component under the given key in non-caching mode, ie with new instance created for each class with a defined dependency

Specified by:
registerNonCaching in interface Registrar
Parameters:
key - represents the key the object will be registered under
type - represents the component type
parameters - any parameters needed to satisfy the component being registered
Returns:
The current Registrar which allows for chaining registration calls.

registerUnCachedComponentAdapter

public void registerUnCachedComponentAdapter(org.picocontainer.ComponentAdapter<?> componentAdapter)

registerCachedComponentAdapter

public void registerCachedComponentAdapter(org.picocontainer.ComponentAdapter<?> componentAdapter)

application

public void application()
Description copied from interface: Registrar
Components registered in this method will be availables for the life of the Application.

Specified by:
application in interface Registrar
See Also:
ContextLevel.APPLICATION, ServletContextListener

session

public void session()
Description copied from interface: Registrar
Components registered in this method will be availables for the life of a Users session.

Specified by:
session in interface Registrar
See Also:
ContextLevel.SESSION, HttpSessionListener

request

public void request()
Description copied from interface: Registrar
Components registered in this method will be availables for the life of a request.

Specified by:
request in interface Registrar
See Also:
ContextLevel.REQUEST

registerScript

public void registerScript(java.lang.String key,
                           java.lang.String scriptedClassName)
Description copied from interface: ScriptedRegistrar
Register a script with Waffle

Specified by:
registerScript in interface ScriptedRegistrar
Parameters:
key - the key this script should be registred under
scriptedClassName - represent the name of the scripted class being registered


Copyright © 2008. All Rights Reserved.