net.mchaplin.ioc
Interface ContainerI

All Superinterfaces:
ComponentI
All Known Implementing Classes:
DefaultContainer

public interface ContainerI
extends ComponentI

Container interface. Components can be registered & retrieved from a Container, which manages instances lookup & lifecycle

Author:
mchaplin@users.sourceforge.net $Header: $Revision: $Date:
See Also:
DefaultContainer

Field Summary
 
Fields inherited from interface net.mchaplin.ioc.component.ComponentI
CMP_I
 
Method Summary
 void addSon(ContainerI container)
           
 ContainerI getContainer()
          Provide component dependencies lookup facility
 java.lang.String getInstanceName()
           
 ContainerI getParent()
           
 java.util.Map<java.lang.String,java.util.List<ComponentI>> getRegisteredTypes()
           
 ContainerI[] getSons()
           
 java.lang.String getState()
          Return the current state of a Container instance, as formatted text.
 java.lang.String lookupComponent(java.lang.Class classType)
          Lookup for to see if a given component is currently registered in this Container, its parent or sons.
 java.lang.String lookupComponent(java.lang.Class classType, int where)
          Lookup for to see if a given component is currently registered.
 void makeComponentAvailable()
          Gives back a Component when you stop using it.
 void registerComponentImplementation(java.lang.Class component)
          Register a Component into the Container
 void registerComponentImplementation(java.lang.Class component, java.lang.Class factory)
          Custom component registration.
 void registerComponentImplementation(java.lang.Class component, java.lang.Class factory, java.lang.String type)
          Custom component registration.
 void registerComponentImplementation(java.lang.Class component, java.lang.String type)
          Component registration.
 void registerComponentInstance(ComponentI instance)
           
 void registerComponentInstance(ComponentI instance, java.lang.String key)
           
 void registerFactoryImplementation(java.lang.Class factory)
          Register a Factory for later use.
 void reset()
          Provide facility for runtime component redeployment
 ComponentI retrieveComponentInstance(java.lang.Class classType)
          Retrieve the first instance in List of given type.
 ComponentI retrieveComponentInstance(java.lang.String key)
          Retrieve the first instance in List of given type.
 ComponentI retrieveComponentInstance(java.lang.String key, java.lang.String location)
          Retrieve the first instance in List of given type.
 void retrieveComponentInstances()
          Retrieve a list of all registered components
 java.util.List retrieveComponentInstances(java.lang.String key)
          Retrieve a list of registered components for the given key
 ComponentFactoryI retrieveFactoryInstance(java.lang.Class classType)
          Retrieve the first instance in List of given type.
 ComponentFactoryI retrieveFactoryInstance(java.lang.String key)
          Retrieve the first instance in List of given type.
 void setInstanceName(java.lang.String instanceName)
           
 void setParent(ContainerI aParent)
           
 void unregisterComponentInstance(ComponentI instance)
           
 
Methods inherited from interface net.mchaplin.ioc.component.ComponentI
setContainer
 

Method Detail

registerComponentImplementation

void registerComponentImplementation(java.lang.Class component)
Register a Component into the Container

Parameters:
component - the component to register

registerFactoryImplementation

void registerFactoryImplementation(java.lang.Class factory)
Register a Factory for later use.

Parameters:
factory - the factory to register

registerComponentImplementation

void registerComponentImplementation(java.lang.Class component,
                                     java.lang.String type)
Component registration. Will try a newInstance() call on it & register if not already present.

Parameters:
component - the component Class to register
simple - if true, will try a newInstance() call only. Otherwise, will introspect potential constructors for already known components & try to instanciate through reflection
type - optional, the type to register this instance as. If set, the Component will be registered under its fully qualified class name

registerComponentImplementation

void registerComponentImplementation(java.lang.Class component,
                                     java.lang.Class factory)
                                     throws ContainerException
Custom component registration. The factory will be instanciated through a Factory() Constructor. The component will then be instanciated through the Factory.retrieveInstance() method

Parameters:
component - the component to register
factory - the factory to register
Throws:
ContainerException
See Also:
registerComponentImplementation(java.lang.Class, java.lang.Class)

registerComponentImplementation

void registerComponentImplementation(java.lang.Class component,
                                     java.lang.Class factory,
                                     java.lang.String type)
                                     throws ContainerException
Custom component registration. The factory will be instanciated through a Factory() Constructor. The component will then be instanciated through the Factory.retrieveInstance() method

Parameters:
component - the component to register
factory - the factory to register
type - the type to register this instance as. If set, the Component will be registered under its fully qualified class name
Throws:
ContainerException
See Also:
registerComponentImplementation(java.lang.Class, java.lang.Class)

registerComponentInstance

void registerComponentInstance(ComponentI instance)

registerComponentInstance

void registerComponentInstance(ComponentI instance,
                               java.lang.String key)

lookupComponent

java.lang.String lookupComponent(java.lang.Class classType)
Lookup for to see if a given component is currently registered in this Container, its parent or sons. Use if you have no knowledge of where the component is located

Parameters:
classType - the Class type to lookup for.
Returns:
the name of the container where a Component instance has been found or null.

lookupComponent

java.lang.String lookupComponent(java.lang.Class classType,
                                 int where)
Lookup for to see if a given component is currently registered.

Parameters:
classType - the Class type to lookup for.
where - where to lookup the component : here, parent or sons
Returns:
the name of the container where a Component instance has been found or null.

retrieveComponentInstance

ComponentI retrieveComponentInstance(java.lang.Class classType)
Retrieve the first instance in List of given type.

Parameters:
classType - the Class type to retrieve an instance of.
Returns:
an instance of ComponentI, whose Class match classType

retrieveComponentInstance

ComponentI retrieveComponentInstance(java.lang.String key)
Retrieve the first instance in List of given type.

Parameters:
key - the component type to retrieve an instance of
Returns:
an instance of ComponentI, whose full name match key

retrieveComponentInstance

ComponentI retrieveComponentInstance(java.lang.String key,
                                     java.lang.String location)
Retrieve the first instance in List of given type.

Parameters:
key - the component type to retrieve an instance of
location - the location of the container where the component should be retrieved from.
Returns:
an instance of ComponentI, whose full name match key

retrieveFactoryInstance

ComponentFactoryI retrieveFactoryInstance(java.lang.Class classType)
Retrieve the first instance in List of given type.

Parameters:
classType - the Class type to retrieve an instance of.
Returns:
an instance of ComponentI, whose Class match classType

retrieveFactoryInstance

ComponentFactoryI retrieveFactoryInstance(java.lang.String key)
Retrieve the first instance in List of given type.

Parameters:
key - the key to retrieve associated Factory instance.
Returns:
an instance of ComponentI, whose full name match key

retrieveComponentInstances

java.util.List retrieveComponentInstances(java.lang.String key)
Retrieve a list of registered components for the given key


retrieveComponentInstances

void retrieveComponentInstances()
Retrieve a list of all registered components


makeComponentAvailable

void makeComponentAvailable()
Gives back a Component when you stop using it. TODO : manage component lock/unlock mode


unregisterComponentInstance

void unregisterComponentInstance(ComponentI instance)

getState

java.lang.String getState()
Return the current state of a Container instance, as formatted text.

Returns:
the current Container State as formatted text.

setParent

void setParent(ContainerI aParent)
See Also:
setParent(net.mchaplin.ioc.ContainerI)

getInstanceName

java.lang.String getInstanceName()
Returns:
Returns the instanceName.

setInstanceName

void setInstanceName(java.lang.String instanceName)
Parameters:
instanceName - The instanceName to set.

getParent

ContainerI getParent()
See Also:
getParent()

getRegisteredTypes

java.util.Map<java.lang.String,java.util.List<ComponentI>> getRegisteredTypes()
Returns:
Returns the registeredTypes.

getSons

ContainerI[] getSons()
Returns:
Returns the sons.

addSon

void addSon(ContainerI container)

getContainer

ContainerI getContainer()
Description copied from interface: ComponentI
Provide component dependencies lookup facility

Specified by:
getContainer in interface ComponentI
Returns:
the Container that holds this Component.
See Also:
net.mchaplin.ioc.ComponentI#getContainer()

reset

void reset()
Description copied from interface: ComponentI
Provide facility for runtime component redeployment

Specified by:
reset in interface ComponentI
See Also:
net.mchaplin.ioc.ComponentI#reset()


Copyright © 2004-2005 mchaplin.net. All Rights Reserved.