Package org.eclipse.net4j.util.container

# Class ManagedContainer

java.lang.Object
org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.lifecycle.Lifecycle
org.eclipse.net4j.util.container.ManagedContainer

All Implemented Interfaces:
  `IContainer<Object>`, `IManagedContainer`, `INotifier`, `INotifier.INotifier2`, `IDeactivateable`, `ILifecycle`, `ILifecycle.DeferrableActivation`

public class ManagedContainer extends Lifecycle implements IManagedContainer
A default implementation of a `managed container`.

Author:
  Eike Stepper

## Nested Class Summary

## Nested classes/interfaces inherited from class org.eclipse.net4j.util.event.Notifier

`Notifier.Cancelation`

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.container.IContainer

`IContainer.Modifiable<E>, IContainer.Persistable<E>, IContainer.Persistence<E>`

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

`ILifecycle.DeferrableActivation`

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.container.IManagedContainer

`IManagedContainer.ContainerAware`

## Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier

`INotifier.INotifier2`

## Field Summary

### Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

`USE_LABEL`

## Constructor Summary

Constructors
Constructor
Description
`ManagedContainer()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`activateElement(Object element)`
`void`
`addPostProcessor(IElementProcessor postProcessor)`
`void`
`addPostProcessor(IElementProcessor postProcessor, boolean processExistingElements)`
`void`
`clearElements()`
`int`
`countElements(String productGroup)`
`int`
`countElements(String productGroup, String factoryType)`
`<T> T`
`createElement(String productGroup, String factoryType, String description)`
`<T> T`
`createElement(String productGroup, String factoryType, Tree config)`
`protected IRegistry<IFactoryKey,IFactory>`
`createFactoryRegistry()`
`protected List<IElementProcessor>`
`createPostProcessors()`
`protected void`
`doActivate()`
`protected void`
`doDeactivate()`
`void`
`fireEvent(IEvent event)`
`<T> void`
`forEachElement(String productGroup, Class<T> productType, String description, Consumer<T> consumer)`
`<T> void`
`forEachElement(String productGroup, Class<T> productType, Consumer<T> consumer)`
`<T> void`
`forEachElement(String productGroup, Class<T> productType, Function<String,String> descriptionProvider, Consumer<T> consumer)`
`Object`
`getElement(String productGroup, String factoryType, String description)`
`Object`
`getElement(String productGroup, String factoryType, String description, boolean activate)`
`String[]`
`getElementKey(Object element)`
`<T> T`
`getElementOrNull(String productGroup, String factoryType)`
`<T> T`
`getElementOrNull(String productGroup, String factoryType, String description)`
`<T> T`
`getElementOrNull(String productGroup, String factoryType, Tree config)`
`protected Map.Entry<org.eclipse.net4j.util.container.ManagedContainer.ElementKey,Object>[]`
`getElementRegistryEntries()`
`protected org.eclipse.net4j.util.container.ManagedContainer.ElementKey[]`
`getElementRegistryKeys()`
`protected Object[]`
`getElementRegistryValues()`
`Object[]`
`getElements()`
`Object[]`
`getElements(String productGroup)`
`Object[]`
`getElements(String productGroup, String factoryType)`
`IFactory`
`getFactory(String productGroup, String factoryType)`
`IRegistry<IFactoryKey,IFactory>`
`getFactoryRegistry()`
`Set<String>`
`getFactoryTypes(String productGroup)`
`String`
`getName()`
Returns the name of this container, or `null` if no name has been set.
`List<IElementProcessor>`
`getPostProcessors()`
`Set<String>`
`getProductGroups()`
`protected String`
`getTypeName()`
`boolean`
`isEmpty()`
`void`
`loadElements(InputStream stream)`
`protected Object`
`postProcessElement(String productGroup, String factoryType, String description, Object element)`
`Object`
`putElement(String productGroup, String factoryType, String description, Object element)`
`protected Object`
`putElement(org.eclipse.net4j.util.container.ManagedContainer.ElementKey key, Object element)`
`ManagedContainer`
`registerFactory(IFactory factory)`
`Object`
`removeElement(String productGroup, String factoryType, String description)`
`protected Object`
`removeElement(org.eclipse.net4j.util.container.ManagedContainer.ElementKey key)`
`void`
`removePostProcessor(IElementProcessor postProcessor)`
`void`
`saveElements(OutputStream stream)`
`void`
`setName(String name)`
Sets the name of this container before it is activated.
`String`
`toString()`
`IManagedContainer`
`unregisterFactory(IFactory factory)`

### Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

`activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeActivate, doBeforeDeactivate, dump, getLifecycleState, isActive, isDeferredActivation`

### Methods inherited from class org.eclipse.net4j.util.event.Notifier

`addListener, addUniqueListener, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListener`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

`activate, deactivate, getLifecycleState, isActive`

### Methods inherited from interface org.eclipse.net4j.util.event.INotifier

`addListener, getListeners, hasListeners, removeListener`

## Constructor Details

### ManagedContainer

public ManagedContainer()

## Method Details

### getName

public String getName()
Description copied from interface: `IManagedContainer`
Returns the name of this container, or `null` if no name has been set.

Specified by:
  `getName` in interface `IManagedContainer`
Since:
  3.8

### setName

public void setName(String name)
Description copied from interface: `IManagedContainer`
Sets the name of this container before it is activated.

Specified by:
  `setName` in interface `IManagedContainer`
Since:
  3.8

### getFactoryRegistry

public IRegistry<IFactoryKey,IFactory> getFactoryRegistry()

Specified by:
  `getFactoryRegistry` in interface `IManagedContainer`

### registerFactory

public ManagedContainer registerFactory(IFactory factory)

Specified by:
  `registerFactory` in interface `IManagedContainer`

### unregisterFactory

public IManagedContainer unregisterFactory(IFactory factory)

Specified by:
  `unregisterFactory` in interface `IManagedContainer`

### getPostProcessors

public List<IElementProcessor> getPostProcessors()

Specified by:
  `getPostProcessors` in interface `IManagedContainer`

### addPostProcessor

public void addPostProcessor(IElementProcessor postProcessor, boolean processExistingElements)

Specified by:
  `addPostProcessor` in interface `IManagedContainer`

### addPostProcessor

public void addPostProcessor(IElementProcessor postProcessor)

Specified by:
  `addPostProcessor` in interface `IManagedContainer`

### removePostProcessor

public void removePostProcessor(IElementProcessor postProcessor)

Specified by:
  `removePostProcessor` in interface `IManagedContainer`

### getProductGroups

public Set<String> getProductGroups()

Specified by:
  `getProductGroups` in interface `IManagedContainer`

### getFactoryTypes

public Set<String> getFactoryTypes(String productGroup)

Specified by:
  `getFactoryTypes` in interface `IManagedContainer`

### getFactory

public IFactory getFactory(String productGroup, String factoryType) throws FactoryNotFoundException

Specified by:
  `getFactory` in interface `IManagedContainer`
Throws:
  `FactoryNotFoundException`

### isEmpty

public boolean isEmpty()

Specified by:
  `isEmpty` in interface `IContainer<Object>`

### getElementKey

public String[] getElementKey(Object element)

Specified by:
  `getElementKey` in interface `IManagedContainer`

### getElements

public Object[] getElements()

Specified by:
  `getElements` in interface `IContainer<Object>`

### getElements

public Object[] getElements(String productGroup)

Specified by:
  `getElements` in interface `IManagedContainer`

### getElements

public Object[] getElements(String productGroup, String factoryType)

Specified by:
  `getElements` in interface `IManagedContainer`

### getElement

public Object getElement(String productGroup, String factoryType, String description) throws FactoryNotFoundException, ProductCreationException

Specified by:
  `getElement` in interface `IManagedContainer`
Throws:
  `FactoryNotFoundException`
  `ProductCreationException`

### getElement

public Object getElement(String productGroup, String factoryType, String description, boolean activate) throws FactoryNotFoundException, ProductCreationException

Specified by:
  `getElement` in interface `IManagedContainer`
Throws:
  `FactoryNotFoundException`
  `ProductCreationException`
Since:
  2.0

### getElementOrNull

public <T> T getElementOrNull(String productGroup, String factoryType) throws ProductCreationException

Specified by:
  `getElementOrNull` in interface `IManagedContainer`
Throws:
  `ProductCreationException`

### getElementOrNull

public <T> T getElementOrNull(String productGroup, String factoryType, String description) throws ProductCreationException

Specified by:
  `getElementOrNull` in interface `IManagedContainer`
Throws:
  `ProductCreationException`

### getElementOrNull

public <T> T getElementOrNull(String productGroup, String factoryType, Tree config) throws ProductCreationException

Specified by:
  `getElementOrNull` in interface `IManagedContainer`
Throws:
  `ProductCreationException`
Since:
  3.23

### createElement

public <T> T createElement(String productGroup, String factoryType, String description) throws FactoryNotFoundException, ProductCreationException

Specified by:
  `createElement` in interface `IManagedContainer`
Throws:
  `FactoryNotFoundException`
  `ProductCreationException`
Since:
  3.23

### createElement

public <T> T createElement(String productGroup, String factoryType, Tree config) throws FactoryNotFoundException, ProductCreationException

Specified by:
  `createElement` in interface `IManagedContainer`
Throws:
  `FactoryNotFoundException`
  `ProductCreationException`
Since:
  3.23

### countElements

public int countElements(String productGroup)

Specified by:
  `countElements` in interface `IManagedContainer`

### countElements

public int countElements(String productGroup, String factoryType)

Specified by:
  `countElements` in interface `IManagedContainer`

### activateElement

protected void activateElement(Object element)

Since:
  3.2

### putElement

public Object putElement(String productGroup, String factoryType, String description, Object element)

Specified by:
  `putElement` in interface `IManagedContainer`

### putElement

protected Object putElement(org.eclipse.net4j.util.container.ManagedContainer.ElementKey key, Object element)

### removeElement

public Object removeElement(String productGroup, String factoryType, String description)

Specified by:
  `removeElement` in interface `IManagedContainer`

### removeElement

protected Object removeElement(org.eclipse.net4j.util.container.ManagedContainer.ElementKey key)

### forEachElement

public <T> void forEachElement(String productGroup, Class<T> productType, Function<String,String> descriptionProvider, Consumer<T> consumer)

Specified by:
  `forEachElement` in interface `IManagedContainer`

### forEachElement

public <T> void forEachElement(String productGroup, Class<T> productType, String description, Consumer<T> consumer)

Specified by:
  `forEachElement` in interface `IManagedContainer`

### forEachElement

public <T> void forEachElement(String productGroup, Class<T> productType, Consumer<T> consumer)

Specified by:
  `forEachElement` in interface `IManagedContainer`

### clearElements

public void clearElements()

Specified by:
  `clearElements` in interface `IManagedContainer`

### loadElements

public void loadElements(InputStream stream) throws IOException, FactoryNotFoundException, ProductCreationException

Specified by:
  `loadElements` in interface `IManagedContainer`
Throws:
  `IOException`
  `FactoryNotFoundException`
  `ProductCreationException`

### saveElements

public void saveElements(OutputStream stream) throws IOException

Specified by:
  `saveElements` in interface `IManagedContainer`
Throws:
  `IOException`

### fireEvent

public void fireEvent(IEvent event)

Overrides:
  `fireEvent` in class `Notifier`

### toString

public String toString()

Overrides:
  `toString` in class `Lifecycle`

### getTypeName

protected String getTypeName()

Since:
  3.8

### createFactoryRegistry

protected IRegistry<IFactoryKey,IFactory> createFactoryRegistry()

### createPostProcessors

protected List<IElementProcessor> createPostProcessors()

### getElementRegistryKeys

protected org.eclipse.net4j.util.container.ManagedContainer.ElementKey[] getElementRegistryKeys()

Since:
  2.0

### getElementRegistryValues

protected Object[] getElementRegistryValues()

Since:
  2.0

### getElementRegistryEntries

protected Map.Entry<org.eclipse.net4j.util.container.ManagedContainer.ElementKey,Object>[] getElementRegistryEntries()

Since:
  2.0

### postProcessElement

protected Object postProcessElement(String productGroup, String factoryType, String description, Object element)

### doActivate

protected void doActivate() throws Exception

Overrides:
  `doActivate` in class `Lifecycle`
Throws:
  `Exception`

### doDeactivate

protected void doDeactivate() throws Exception

Overrides:
  `doDeactivate` in class `Lifecycle`
Throws:
  `Exception`