org.codehaus.waffle.registrar
Interface Registrar

All Known Subinterfaces:
ScriptedRegistrar
All Known Implementing Classes:
AbstractRegistrar, AbstractScriptedRegistrar, PicoRegistrar

public interface Registrar

Defines the available methods for registering components (including controllers). By default Constructor based dependency injection is utilized.

Author:
Michael Ward, Mauro Talevi

Nested Class Summary
static class Registrar.Injection
           
 
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.
 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 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.
 

Method Detail

useInjection

Registrar useInjection(Registrar.Injection injection)
Use the given injection type for component instantiation. Defaults to Registrar.Injection.CONSTRUCTOR.

Parameters:
injection - the Injection to use
Returns:
The Registrar

isRegistered

boolean isRegistered(java.lang.Object typeOrInstance)
Determines if a component is already registered

Parameters:
typeOrInstance - the component Class type or Object instance/key
Returns:
A boolean flag, true if component is registered

getRegistered

java.lang.Object getRegistered(java.lang.Object typeOrInstance)
Returns a registered component

Parameters:
typeOrInstance - the component Class type or Object instance/key
Returns:
The registered component instance
Throws:
RegistrarException - if component not registered or more than one instance found

register

Registrar register(java.lang.Class<?> type,
                   java.lang.Object... parameters)
Registers a component in the current context.

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

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.

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

Registrar registerInstance(java.lang.Object instance)
Registers a component instance directly in the current context.

Parameters:
instance - to be registered
Returns:
The current Registrar which allows for chaining registration calls.

registerInstance

Registrar registerInstance(java.lang.Object key,
                           java.lang.Object instance)
Registers a component instance directly in the current context under the given key.

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

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

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

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

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.

application

void application()
Components registered in this method will be availables for the life of the Application.

See Also:
ContextLevel.APPLICATION, ServletContextListener

session

void session()
Components registered in this method will be availables for the life of a Users session.

See Also:
ContextLevel.SESSION, HttpSessionListener

request

void request()
Components registered in this method will be availables for the life of a request.

See Also:
ContextLevel.REQUEST


Copyright © 2008. All Rights Reserved.