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<java.lang.Object>
,IManagedContainer
,INotifier
,INotifier.INotifier2
,IDeactivateable
,ILifecycle
,ILifecycle.DeferrableActivation
public class ManagedContainer extends Lifecycle implements IManagedContainer
A default implementation of amanaged container
.- Author:
- Eike Stepper
-
-
Nested Class Summary
-
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
-
-
Constructor Summary
Constructors Constructor Description ManagedContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
activateElement(java.lang.Object element)
void
addPostProcessor(IElementProcessor postProcessor)
void
addPostProcessor(IElementProcessor postProcessor, boolean processExistingElements)
void
clearElements()
protected java.lang.Object
createElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description)
protected IRegistry<IFactoryKey,IFactory>
createFactoryRegistry()
protected java.util.List<IElementProcessor>
createPostProcessors()
protected void
doActivate()
protected void
doDeactivate()
void
fireEvent(IEvent event)
<T> void
forEachElement(java.lang.String productGroup, java.lang.Class<T> productType, java.lang.String description, java.util.function.Consumer<T> consumer)
<T> void
forEachElement(java.lang.String productGroup, java.lang.Class<T> productType, java.util.function.Consumer<T> consumer)
<T> void
forEachElement(java.lang.String productGroup, java.lang.Class<T> productType, java.util.function.Function<java.lang.String,java.lang.String> descriptionProvider, java.util.function.Consumer<T> consumer)
java.lang.Object
getElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description)
java.lang.Object
getElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description, boolean activate)
java.lang.String[]
getElementKey(java.lang.Object element)
<T> T
getElementOrNull(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description)
protected java.util.Map.Entry<org.eclipse.net4j.util.container.ManagedContainer.ElementKey,java.lang.Object>[]
getElementRegistryEntries()
protected org.eclipse.net4j.util.container.ManagedContainer.ElementKey[]
getElementRegistryKeys()
protected java.lang.Object[]
getElementRegistryValues()
java.lang.Object[]
getElements()
java.lang.Object[]
getElements(java.lang.String productGroup)
java.lang.Object[]
getElements(java.lang.String productGroup, java.lang.String factoryType)
IFactory
getFactory(java.lang.String productGroup, java.lang.String factoryType)
IRegistry<IFactoryKey,IFactory>
getFactoryRegistry()
java.util.Set<java.lang.String>
getFactoryTypes(java.lang.String productGroup)
java.lang.String
getName()
Returns the name of this container, ornull
if no name has been set.java.util.List<IElementProcessor>
getPostProcessors()
java.util.Set<java.lang.String>
getProductGroups()
protected java.lang.String
getTypeName()
boolean
isEmpty()
void
loadElements(java.io.InputStream stream)
protected java.lang.Object
postProcessElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description, java.lang.Object element)
java.lang.Object
putElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description, java.lang.Object element)
protected java.lang.Object
putElement(org.eclipse.net4j.util.container.ManagedContainer.ElementKey key, java.lang.Object element)
ManagedContainer
registerFactory(IFactory factory)
java.lang.Object
removeElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description)
protected java.lang.Object
removeElement(org.eclipse.net4j.util.container.ManagedContainer.ElementKey key)
void
removePostProcessor(IElementProcessor postProcessor)
void
saveElements(java.io.OutputStream stream)
void
setName(java.lang.String name)
Sets the name of this container before it is activated.java.lang.String
toString()
-
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
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:IManagedContainer
Returns the name of this container, ornull
if no name has been set.- Specified by:
getName
in interfaceIManagedContainer
- Since:
- 3.8
-
setName
public void setName(java.lang.String name)
Description copied from interface:IManagedContainer
Sets the name of this container before it is activated.- Specified by:
setName
in interfaceIManagedContainer
- Since:
- 3.8
-
getFactoryRegistry
public IRegistry<IFactoryKey,IFactory> getFactoryRegistry()
- Specified by:
getFactoryRegistry
in interfaceIManagedContainer
-
registerFactory
public ManagedContainer registerFactory(IFactory factory)
- Specified by:
registerFactory
in interfaceIManagedContainer
-
getPostProcessors
public java.util.List<IElementProcessor> getPostProcessors()
- Specified by:
getPostProcessors
in interfaceIManagedContainer
-
addPostProcessor
public void addPostProcessor(IElementProcessor postProcessor, boolean processExistingElements)
- Specified by:
addPostProcessor
in interfaceIManagedContainer
-
addPostProcessor
public void addPostProcessor(IElementProcessor postProcessor)
- Specified by:
addPostProcessor
in interfaceIManagedContainer
-
removePostProcessor
public void removePostProcessor(IElementProcessor postProcessor)
- Specified by:
removePostProcessor
in interfaceIManagedContainer
-
getProductGroups
public java.util.Set<java.lang.String> getProductGroups()
- Specified by:
getProductGroups
in interfaceIManagedContainer
-
getFactoryTypes
public java.util.Set<java.lang.String> getFactoryTypes(java.lang.String productGroup)
- Specified by:
getFactoryTypes
in interfaceIManagedContainer
-
getFactory
public IFactory getFactory(java.lang.String productGroup, java.lang.String factoryType) throws FactoryNotFoundException
- Specified by:
getFactory
in interfaceIManagedContainer
- Throws:
FactoryNotFoundException
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceIContainer<java.lang.Object>
-
getElementKey
public java.lang.String[] getElementKey(java.lang.Object element)
- Specified by:
getElementKey
in interfaceIManagedContainer
-
getElements
public java.lang.Object[] getElements()
- Specified by:
getElements
in interfaceIContainer<java.lang.Object>
-
getElements
public java.lang.Object[] getElements(java.lang.String productGroup)
- Specified by:
getElements
in interfaceIManagedContainer
-
getElements
public java.lang.Object[] getElements(java.lang.String productGroup, java.lang.String factoryType)
- Specified by:
getElements
in interfaceIManagedContainer
-
getElement
public java.lang.Object getElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description) throws FactoryNotFoundException, ProductCreationException
- Specified by:
getElement
in interfaceIManagedContainer
- Throws:
FactoryNotFoundException
ProductCreationException
-
getElement
public java.lang.Object getElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description, boolean activate) throws FactoryNotFoundException, ProductCreationException
- Specified by:
getElement
in interfaceIManagedContainer
- Throws:
FactoryNotFoundException
ProductCreationException
- Since:
- 2.0
-
getElementOrNull
public <T> T getElementOrNull(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description)
- Specified by:
getElementOrNull
in interfaceIManagedContainer
-
activateElement
protected void activateElement(java.lang.Object element)
- Since:
- 3.2
-
putElement
public java.lang.Object putElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description, java.lang.Object element)
- Specified by:
putElement
in interfaceIManagedContainer
-
putElement
protected java.lang.Object putElement(org.eclipse.net4j.util.container.ManagedContainer.ElementKey key, java.lang.Object element)
-
removeElement
public java.lang.Object removeElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description)
- Specified by:
removeElement
in interfaceIManagedContainer
-
removeElement
protected java.lang.Object removeElement(org.eclipse.net4j.util.container.ManagedContainer.ElementKey key)
-
forEachElement
public <T> void forEachElement(java.lang.String productGroup, java.lang.Class<T> productType, java.util.function.Function<java.lang.String,java.lang.String> descriptionProvider, java.util.function.Consumer<T> consumer)
- Specified by:
forEachElement
in interfaceIManagedContainer
-
forEachElement
public <T> void forEachElement(java.lang.String productGroup, java.lang.Class<T> productType, java.lang.String description, java.util.function.Consumer<T> consumer)
- Specified by:
forEachElement
in interfaceIManagedContainer
-
forEachElement
public <T> void forEachElement(java.lang.String productGroup, java.lang.Class<T> productType, java.util.function.Consumer<T> consumer)
- Specified by:
forEachElement
in interfaceIManagedContainer
-
clearElements
public void clearElements()
- Specified by:
clearElements
in interfaceIManagedContainer
-
loadElements
public void loadElements(java.io.InputStream stream) throws java.io.IOException, FactoryNotFoundException, ProductCreationException
- Specified by:
loadElements
in interfaceIManagedContainer
- Throws:
java.io.IOException
FactoryNotFoundException
ProductCreationException
-
saveElements
public void saveElements(java.io.OutputStream stream) throws java.io.IOException
- Specified by:
saveElements
in interfaceIManagedContainer
- Throws:
java.io.IOException
-
getTypeName
protected java.lang.String getTypeName()
- Since:
- 3.8
-
createFactoryRegistry
protected IRegistry<IFactoryKey,IFactory> createFactoryRegistry()
-
createPostProcessors
protected java.util.List<IElementProcessor> createPostProcessors()
-
getElementRegistryKeys
protected org.eclipse.net4j.util.container.ManagedContainer.ElementKey[] getElementRegistryKeys()
- Since:
- 2.0
-
getElementRegistryValues
protected java.lang.Object[] getElementRegistryValues()
- Since:
- 2.0
-
getElementRegistryEntries
protected java.util.Map.Entry<org.eclipse.net4j.util.container.ManagedContainer.ElementKey,java.lang.Object>[] getElementRegistryEntries()
- Since:
- 2.0
-
createElement
protected java.lang.Object createElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description) throws FactoryNotFoundException, ProductCreationException
-
postProcessElement
protected java.lang.Object postProcessElement(java.lang.String productGroup, java.lang.String factoryType, java.lang.String description, java.lang.Object element)
-
doActivate
protected void doActivate() throws java.lang.Exception
- Overrides:
doActivate
in classLifecycle
- Throws:
java.lang.Exception
-
doDeactivate
protected void doDeactivate() throws java.lang.Exception
- Overrides:
doDeactivate
in classLifecycle
- Throws:
java.lang.Exception
-
-