org.eclipse.ecf.core
Class ContainerFactory

java.lang.Object
  extended by org.eclipse.ecf.core.ContainerFactory
All Implemented Interfaces:
IContainerFactory, IContainerManager

public class ContainerFactory
extends java.lang.Object
implements IContainerFactory, IContainerManager

Factory for creating IContainer instances. This class provides ECF clients an entry point to constructing IContainer instances.

Here is an example use of the ContainerFactory to construct an instance of the 'standalone' container (has no connection to other containers):

IContainer container =
ContainerFactory.getDefault().createContainer("ecf.generic.client");

...further use of container here...
For more details on the creation and lifecycle of IContainer instances created via this factory see IContainer.

Since:
3.1
See Also:
IContainer, IContainerFactory

Field Summary
static java.lang.String BASE_CONTAINER_NAME
           
 
Constructor Summary
protected ContainerFactory()
           
 
Method Summary
 IContainer addContainer(IContainer container, ContainerTypeDescription typeDescription)
          Add given container to manager.
 ContainerTypeDescription addDescription(ContainerTypeDescription containerTypeDescription)
          Add a ContainerTypeDescription to the set of known ContainerDescriptions.
protected  ContainerTypeDescription addDescription0(ContainerTypeDescription containerTypeDescription)
           
 boolean addListener(IContainerManagerListener listener)
          Add listener to this IContainerManager.
 boolean containsDescription(ContainerTypeDescription containerTypeDescription)
          Check to see if a given named description is already contained by this factory
protected  boolean containsDescription0(ContainerTypeDescription containerTypeDescription)
           
 IContainer createContainer()
          Make a base IContainer instance.
 IContainer createContainer(ContainerTypeDescription containerTypeDescription)
          Create a new container.
 IContainer createContainer(ContainerTypeDescription containerTypeDescription, ID containerID)
          Create a new container.
 IContainer createContainer(ContainerTypeDescription containerTypeDescription, ID containerID, java.util.Map parameters)
          Create a new container.
 IContainer createContainer(ContainerTypeDescription containerTypeDescription, ID containerID, java.lang.Object[] parameters)
          Create a new container.
 IContainer createContainer(ContainerTypeDescription containerTypeDescription, java.util.Map parameters)
          Create a new container.
 IContainer createContainer(ContainerTypeDescription containerTypeDescription, java.lang.Object[] parameters)
          Create a new container.
 IContainer createContainer(ContainerTypeDescription containerTypeDescription, java.lang.String containerId)
          Create a new container.
 IContainer createContainer(ContainerTypeDescription containerTypeDescription, java.lang.String containerId, java.util.Map parameters)
          Create a new container.
 IContainer createContainer(ContainerTypeDescription containerTypeDescription, java.lang.String containerId, java.lang.Object[] parameters)
          Create a new container.
 IContainer createContainer(ID containerID)
          Create a new container.
 IContainer createContainer(java.lang.String containerTypeDescriptionName)
          Create a new container.
 IContainer createContainer(java.lang.String containerTypeDescriptionName, ID containerID)
          Create a new container.
 IContainer createContainer(java.lang.String containerTypeDescriptionName, ID containerID, java.util.Map parameters)
          Create a new container.
 IContainer createContainer(java.lang.String containerTypeDescriptionName, ID containerID, java.lang.Object[] parameters)
          Create a new container.
 IContainer createContainer(java.lang.String containerTypeDescriptionName, java.util.Map parameters)
          Create a new container.
 IContainer createContainer(java.lang.String containerTypeDescriptionName, java.lang.Object[] parameters)
          Create a new container.
 IContainer createContainer(java.lang.String containerTypeDescriptionName, java.lang.String containerId)
          Create a new container.
 IContainer createContainer(java.lang.String containerTypeDescriptionName, java.lang.String containerId, java.util.Map parameters)
          Create a new container.
 IContainer createContainer(java.lang.String containerTypeDescriptionName, java.lang.String containerId, java.lang.Object[] parameters)
          Create a new container.
 IContainer[] getAllContainers()
          Get all containers known to this container manager.
 IContainer getContainer(ID containerID)
          Get container for given ID.
 IContainerFactory getContainerFactory()
          Get container factory associated with this container manager.
 ContainerTypeDescription getContainerTypeDescription(ID containerID)
          Get the container type description used to create the container with the given ID.
static IContainerFactory getDefault()
           
protected  ContainerTypeDescription getDescription0(ContainerTypeDescription containerTypeDescription)
           
protected  ContainerTypeDescription getDescription0(java.lang.String containerTypeDescriptionName)
           
 ContainerTypeDescription getDescriptionByName(java.lang.String containerTypeDescriptionName)
          Get the known ContainerTypeDescription given it's name.
 java.util.List getDescriptions()
          Get a collection of the ContainerDescriptions currently known to this factory.
protected  java.util.List getDescriptions0()
           
 ContainerTypeDescription[] getDescriptionsForContainerAdapter(java.lang.Class containerAdapter)
          Get container type descriptions that support the given containerAdapter
 boolean hasContainer(ID containerID)
          Return true if this container manager has the given container under management, false otherwise.
 void removeAllContainers()
          Remove all containers from this manager
 IContainer removeContainer(IContainer container)
          Remove given container from manager.
 IContainer removeContainer(ID containerID)
          Remove given container from manager.
 ContainerTypeDescription removeDescription(ContainerTypeDescription containerTypeDescription)
          Remove given description from set known to this factory.
protected  ContainerTypeDescription removeDescription0(ContainerTypeDescription containerTypeDescription)
           
 boolean removeListener(IContainerManagerListener listener)
          Remove listener from this IContainerManager.
protected  void throwContainerCreateException(java.lang.String message, java.lang.Throwable cause, java.lang.String method)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASE_CONTAINER_NAME

public static final java.lang.String BASE_CONTAINER_NAME
See Also:
Constant Field Values
Constructor Detail

ContainerFactory

protected ContainerFactory()
Method Detail

getDefault

public static IContainerFactory getDefault()

addDescription

public ContainerTypeDescription addDescription(ContainerTypeDescription containerTypeDescription)
Description copied from interface: IContainerFactory
Add a ContainerTypeDescription to the set of known ContainerDescriptions.

Specified by:
addDescription in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to add to this factory. Must not be null.
Returns:
ContainerTypeDescription the old description of the same name, null if none found

getDescriptions

public java.util.List getDescriptions()
Description copied from interface: IContainerFactory
Get a collection of the ContainerDescriptions currently known to this factory. This allows clients to query the factory to determine what if any other ContainerDescriptions are currently registered with the factory, and if so, what they are.

Specified by:
getDescriptions in interface IContainerFactory
Returns:
List of ContainerTypeDescription instances

getDescriptions0

protected java.util.List getDescriptions0()

addDescription0

protected ContainerTypeDescription addDescription0(ContainerTypeDescription containerTypeDescription)

containsDescription

public boolean containsDescription(ContainerTypeDescription containerTypeDescription)
Description copied from interface: IContainerFactory
Check to see if a given named description is already contained by this factory

Specified by:
containsDescription in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to look for
Returns:
true if description is already known to factory, false otherwise

containsDescription0

protected boolean containsDescription0(ContainerTypeDescription containerTypeDescription)

getDescription0

protected ContainerTypeDescription getDescription0(ContainerTypeDescription containerTypeDescription)

getDescription0

protected ContainerTypeDescription getDescription0(java.lang.String containerTypeDescriptionName)

getDescriptionByName

public ContainerTypeDescription getDescriptionByName(java.lang.String containerTypeDescriptionName)
Description copied from interface: IContainerFactory
Get the known ContainerTypeDescription given it's name.

Specified by:
getDescriptionByName in interface IContainerFactory
Parameters:
containerTypeDescriptionName - the name to use as key to find ContainerTypeDescription. Must not be null.
Returns:
ContainerTypeDescription found. Null if not found.

removeDescription

public ContainerTypeDescription removeDescription(ContainerTypeDescription containerTypeDescription)
Description copied from interface: IContainerFactory
Remove given description from set known to this factory.

Specified by:
removeDescription in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to remove
Returns:
the removed ContainerTypeDescription, null if nothing removed

removeDescription0

protected ContainerTypeDescription removeDescription0(ContainerTypeDescription containerTypeDescription)

getDescriptionsForContainerAdapter

public ContainerTypeDescription[] getDescriptionsForContainerAdapter(java.lang.Class containerAdapter)
Description copied from interface: IContainerFactory
Get container type descriptions that support the given containerAdapter

Specified by:
getDescriptionsForContainerAdapter in interface IContainerFactory
Parameters:
containerAdapter - the container adapter. Must not be null.
Returns:
ContainerTypeDescription[] of descriptions that support the given container adapter. If no ContainerTypeDescriptions found that support the given adapter, an empty array will be returned.

throwContainerCreateException

protected void throwContainerCreateException(java.lang.String message,
                                             java.lang.Throwable cause,
                                             java.lang.String method)
                                      throws ContainerCreateException
Throws:
ContainerCreateException

createContainer

public IContainer createContainer()
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Make a base IContainer instance.

Specified by:
createContainer in interface IContainerFactory
Returns:
IContainer instance. A non-null instance will be returned.
Throws:
ContainerCreateException - if some problem creating the instance.

createContainer

public IContainer createContainer(ID containerID)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerID - the container's new ID. Must not be null.
Returns:
IContainer instance. A non-null. instance will be returned.
Throws:
ContainerCreateException - if some problem creating a base IContainer instance.

createContainer

public IContainer createContainer(ContainerTypeDescription containerTypeDescription)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to use. Must not be null.
Returns:
a valid instance of IContainer. Will not be null.
Throws:
ContainerCreateException - if some problem creating the instance.

createContainer

public IContainer createContainer(java.lang.String containerTypeDescriptionName)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescriptionName - the ContainerTypeDescription name to lookup. Must not be null.
Returns:
a valid instance of IContainer. Will not be null.
Throws:
ContainerCreateException

createContainer

public IContainer createContainer(ContainerTypeDescription containerTypeDescription,
                                  java.lang.Object[] parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to use to create the instance. Must not be null.
parameters - an Object [] of parameters passed to the createInstance method of the IContainerInstantiator. May be null.
Returns:
a valid instance of IContainer. A non-null instance will be returned.
Throws:
ContainerCreateException - if some problem creating the instance.

createContainer

public IContainer createContainer(java.lang.String containerTypeDescriptionName,
                                  java.lang.Object[] parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescriptionName - the ContainerTypeDescription name to lookup. Must not be null.
parameters - the Object [] of parameters passed to the IContainerInstantiator.createInstance method. May be null.
Returns:
a valid instance of IContainer. Will not be null.
Throws:
ContainerCreateException - if some problem creating the instance.

createContainer

public IContainer createContainer(ContainerTypeDescription containerTypeDescription,
                                  ID containerID,
                                  java.lang.Object[] parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to use to create the instance. Must not be null.
containerID - the container's new ID. May be null.
parameters - an Object [] of parameters passed to the createInstance method of the IContainerInstantiator. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.

createContainer

public IContainer createContainer(java.lang.String containerTypeDescriptionName,
                                  ID containerID,
                                  java.lang.Object[] parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescriptionName - the ContainerTypeDescription name to lookup. Must not be null.
containerID - the new container's id. May be null.
parameters - the Object [] of parameters passed to the IContainerInstantiator.createInstance method. May be null.
Returns:
a valid instance of IContainer. Will not be null.
Throws:
ContainerCreateException - if some problem creating the instance.

createContainer

public IContainer createContainer(ContainerTypeDescription containerTypeDescription,
                                  ID containerID)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to lookup. Must not be null.
containerID - the new container's id. May be null.
Returns:
a valid instance of IContainer. Will not be null.
Throws:
ContainerCreateException - if some problem creating the instance.

createContainer

public IContainer createContainer(java.lang.String containerTypeDescriptionName,
                                  ID containerID)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescriptionName - the ContainerTypeDescription name to lookup. Must not be null.
containerID - the new container's id. May be null.
Returns:
a valid instance of IContainer. Will not be null.
Throws:
ContainerCreateException - if some problem creating the instance.

createContainer

public IContainer createContainer(java.lang.String containerTypeDescriptionName,
                                  java.lang.String containerId)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescriptionName - the ContainerTypeDescription name to use to create the instance. Must not be null.
containerId - the container's new ID. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.
Since:
3.1

createContainer

public IContainer createContainer(java.lang.String containerTypeDescriptionName,
                                  java.lang.String containerId,
                                  java.lang.Object[] parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescriptionName - the ContainerTypeDescription name to use to create the instance. Must not be null.
containerId - the container's new ID. May be null.
parameters - an Object [] of parameters passed to the createInstance method of the IContainerInstantiator. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.
Since:
3.1

createContainer

public IContainer createContainer(ContainerTypeDescription containerTypeDescription,
                                  java.lang.String containerId)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to use to create the instance. Must not be null.
containerId - the container's new ID. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.
Since:
3.1

createContainer

public IContainer createContainer(ContainerTypeDescription containerTypeDescription,
                                  java.lang.String containerId,
                                  java.lang.Object[] parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to use to create the instance. Must not be null.
containerId - the container's new ID. May be null.
parameters - an Object [] of parameters passed to the createInstance method of the IContainerInstantiator. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.
Since:
3.1

getAllContainers

public IContainer[] getAllContainers()
Description copied from interface: IContainerManager
Get all containers known to this container manager.

Specified by:
getAllContainers in interface IContainerManager
Returns:
IContainer[] of active container instances known to this container manager. Will not return null, but may return empty IContainer[].

getContainer

public IContainer getContainer(ID containerID)
Description copied from interface: IContainerManager
Get container for given ID. If containerID is , null will be returned. If active container with given containerID, is not known to this container manager, then null will also be returned.

Specified by:
getContainer in interface IContainerManager
Parameters:
containerID - the ID of the container instance to retrieve from this manager. If null null will be returned.
Returns:
IContainer instance with given containerID. Will be null if there is no container with given ID known to this container manager.

hasContainer

public boolean hasContainer(ID containerID)
Description copied from interface: IContainerManager
Return true if this container manager has the given container under management, false otherwise.

Specified by:
hasContainer in interface IContainerManager
Parameters:
containerID - the ID of the container to find. If null this method returns false.
Returns:
true if this container manager has the given container under management, false otherwise.

addListener

public boolean addListener(IContainerManagerListener listener)
Description copied from interface: IContainerManager
Add listener to this IContainerManager.

Specified by:
addListener in interface IContainerManager
Parameters:
listener - the listener to add. Must not be null.
Returns:
true if listener successfully added

removeListener

public boolean removeListener(IContainerManagerListener listener)
Description copied from interface: IContainerManager
Remove listener from this IContainerManager.

Specified by:
removeListener in interface IContainerManager
Parameters:
listener - the listener to remove. Must not be null.
Returns:
true if listener successfully removed

addContainer

public IContainer addContainer(IContainer container,
                               ContainerTypeDescription typeDescription)
Description copied from interface: IContainerManager
Add given container to manager.

Specified by:
addContainer in interface IContainerManager
Parameters:
container - to add. Must not be null. Also container.getID() must return a non-null value. If container.getID() returns null then this method will throw a NullPointerException.
typeDescription - the container type description used to create the given container. Must not be null.
Returns:
IContainer previously added (with same ID).

removeContainer

public IContainer removeContainer(IContainer container)
Description copied from interface: IContainerManager
Remove given container from manager.

Specified by:
removeContainer in interface IContainerManager
Parameters:
container - the container to remove. Must not be null.
Returns:
IContainer instance removed. If no instance with same ID is found then null will be returned.

removeContainer

public IContainer removeContainer(ID containerID)
Description copied from interface: IContainerManager
Remove given container from manager.

Specified by:
removeContainer in interface IContainerManager
Parameters:
containerID - the ID of the container to remove. Must not be null.
Returns:
IContainer instance removed. If no instance with same ID is found then null will be returned.

getContainerTypeDescription

public ContainerTypeDescription getContainerTypeDescription(ID containerID)
Description copied from interface: IContainerManager
Get the container type description used to create the container with the given ID.

Specified by:
getContainerTypeDescription in interface IContainerManager
Parameters:
containerID - the ID of the container to get the description for.
Returns:
ContainerTypeDescription for the container with the given ID. Will return null if no container with the given containerID exists under this manager.

getContainerFactory

public IContainerFactory getContainerFactory()
Description copied from interface: IContainerManager
Get container factory associated with this container manager.

Specified by:
getContainerFactory in interface IContainerManager
Returns:
IContainerFactory. Will not return null.

removeAllContainers

public void removeAllContainers()
Description copied from interface: IContainerManager
Remove all containers from this manager

Specified by:
removeAllContainers in interface IContainerManager

createContainer

public IContainer createContainer(ContainerTypeDescription containerTypeDescription,
                                  ID containerID,
                                  java.util.Map parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to use to create the instance. Must not be null.
containerID - the container's new ID. Must not be null.
parameters - a Map of parameters (name/value pairs) passed to the createInstance method of the IContainerInstantiator. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.
Since:
3.1

createContainer

public IContainer createContainer(ContainerTypeDescription containerTypeDescription,
                                  java.lang.String containerId,
                                  java.util.Map parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to use to create the instance. Must not be null.
containerId - the container's new ID. May be null.
parameters - a Map of parameters (name/value pairs) passed to the createInstance method of the IContainerInstantiator. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.
Since:
3.1

createContainer

public IContainer createContainer(java.lang.String containerTypeDescriptionName,
                                  ID containerID,
                                  java.util.Map parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescriptionName - the ContainerTypeDescription name to lookup. Must not be null.
containerID - the container's new ID. May be null.
parameters - a Map of parameters (name/value pairs) passed to the createInstance method of the IContainerInstantiator. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.
Since:
3.1

createContainer

public IContainer createContainer(java.lang.String containerTypeDescriptionName,
                                  java.lang.String containerId,
                                  java.util.Map parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescriptionName - the ContainerTypeDescription name to lookup. Must not be null.
containerId - the container's new ID. May be null.
parameters - a Map of parameters (name/value pairs) passed to the createInstance method of the IContainerInstantiator. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.
Since:
3.1

createContainer

public IContainer createContainer(ContainerTypeDescription containerTypeDescription,
                                  java.util.Map parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescription - the ContainerTypeDescription to use to create the instance. Must not be null.
parameters - a Map of parameters (name/value pairs) passed to the createInstance method of the IContainerInstantiator. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.
Since:
3.1

createContainer

public IContainer createContainer(java.lang.String containerTypeDescriptionName,
                                  java.util.Map parameters)
                           throws ContainerCreateException
Description copied from interface: IContainerFactory
Create a new container.

Specified by:
createContainer in interface IContainerFactory
Parameters:
containerTypeDescriptionName - the ContainerTypeDescription name to lookup. Must not be null.
parameters - a Map of parameters (name/value pairs) passed to the createInstance method of the IContainerInstantiator. May be null.
Returns:
a valid instance of IContainer
Throws:
ContainerCreateException - if some problem creating the instance.
Since:
3.1