fulmine.model.container
Class ContainerFactory

java.lang.Object
  extended by fulmine.model.container.ContainerFactory
All Implemented Interfaces:
IDestroyable, IContainerFactory

public final class ContainerFactory
extends Object
implements IContainerFactory

A factory that creates IContainer implementations. An IContainerFactory.IContainerBuilder is registered for each container type (see IContainer.getType()). The registered builder creates each instance. The builder is registered using the #registerBuilder(IType, fulmine.model.container.ContainerFactory.IContainerBuilder) method. By default, if there is no builder registered for a container type, a Record is created.

The factory is thread safe.

Author:
Ramon Servadei

Nested Class Summary
 
Nested classes/interfaces inherited from interface fulmine.model.container.IContainerFactory
IContainerFactory.IContainerBuilder
 
Constructor Summary
ContainerFactory()
          Standard constructor
 
Method Summary
 boolean containsType(IType type)
          Does the factory contain an IContainerFactory.IContainerBuilder (and by association, an IContainerDefinitionField) registered against the IContainer type argument.
<T extends IContainer>
T
createContainer(String nativeContextIdentity, String identity, IType type, IDomain domain, IFrameworkContext hostContext, boolean local)
          Create an IContainer implementation from the type argument.
 void destroy()
          This is called when the object is being removed from application use.
 IContainerDefinitionField getDefinition(IType type)
          Get the IContainerDefinitionField registered against the IContainer type argument.
 void registerBuilder(IType type, IContainerFactory.IContainerBuilder builder)
          Register an IContainerFactory.IContainerBuilder against the IContainer type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainerFactory

public ContainerFactory()
Standard constructor

Method Detail

registerBuilder

public void registerBuilder(IType type,
                            IContainerFactory.IContainerBuilder builder)
Register an IContainerFactory.IContainerBuilder against the IContainer type. This will overwrite any existing builder registered against the type.

Specified by:
registerBuilder in interface IContainerFactory
Parameters:
type - the type of the IContainer the builder creates
builder - the container builder to register
Throws:
IllegalArgumentException - if the type IType.value() is less than Type.BASE_USER_START
See Also:
containsType(IType), IContainer.getType()

containsType

public boolean containsType(IType type)
Does the factory contain an IContainerFactory.IContainerBuilder (and by association, an IContainerDefinitionField) registered against the IContainer type argument.

Specified by:
containsType in interface IContainerFactory
Parameters:
type - the type of the IContainer the builder creates
Returns:
true if there is a IContainerFactory.IContainerBuilder registered against the type
See Also:
IContainer.getType()

getDefinition

public IContainerDefinitionField getDefinition(IType type)
Get the IContainerDefinitionField registered against the IContainer type argument. This should not be called for dynamic container types.

Specified by:
getDefinition in interface IContainerFactory
Parameters:
type - the type of the IContainer the definition applies to
Returns:
the IContainerDefinitionField for the type of the IContainer
Throws:
IllegalArgumentException - if the IContainer is a dynamic type (there will be no IContainerDefinitionField found)
See Also:
containsType(IType), IContainer.getType()

createContainer

public <T extends IContainer> T createContainer(String nativeContextIdentity,
                                                String identity,
                                                IType type,
                                                IDomain domain,
                                                IFrameworkContext hostContext,
                                                boolean local)
Create an IContainer implementation from the type argument. If there is no application IContainerFactory.IContainerBuilder registered for the type, a default builder is used that creates an Record.

Specified by:
createContainer in interface IContainerFactory
Parameters:
identity - the identity for the container to create
type - the type of the IContainer implementation to create
hostContext - the context the container will be associated with
nativeContextIdentity - the name of the context this container is native to - the name of its local context
domain - the domain for the container implementation
local - true the container is local to this context
Returns:
an IContainer implementation
See Also:
containsType(IType), IContainer.getType()

destroy

public void destroy()
Description copied from interface: IDestroyable
This is called when the object is being removed from application use. This releases all system resources and performs clean up prior to the object becoming redundant. This operation is idempotent.

This method must not throw a RuntimeException.

Specified by:
destroy in interface IDestroyable


Copyright © 2007-2009. All Rights Reserved.