Class ContributionFragmentRegistry<T>
- Direct Known Subclasses:
ActionContributionHandler
,ActiveFileSystemItemFactoryRegistry
,ActiveTopLevelFolderItemFactoryRegistry
,AutomaticLODContributionHandler
,AutomaticRenderViewContributionHandler
,AutomaticVideoConversionContributionHandler
,AutomationFilterRegistry
,ChainExceptionRegistry
,ChangeFinderRegistry
,ContextFactoryRegistry
,EventPipeRegistry
,EventRegistry
,FactoryBindingRegistry
,FileSystemItemFactoryRegistry
,FilterContributionHandler
,FlavorRegistry
,LifeCycleRegistry
,LifeCycleTypeRegistry
,NegotiationRegistry
,NotificationListenerVetoRegistry
,NuxeoCorsFilterDescriptorRegistry
,NuxeoHeaderDescriptorRegistry
,OAuth2ServiceProviderContributionRegistry
,OpenIDProviderFragmentRegistry
,OperationTypeRegistry
,OutputFormatRegistry
,PageProviderClassReplacerRegistry
,PageProviderRegistry
,PageRegistry
,PictureConversionRegistry
,PostContentCreationHandlerRegistry
,ProcessorRegistry
,QuotaStatsUpdaterRegistry
,RenderViewContributionHandler
,RenditionDefinitionProviderRegistry
,RenditionDefinitionRegistry
,ResourceBundleRegistry
,SimpleContributionRegistry
,SuggesterGroupRegistry
,SuggesterRegistry
,SuggestionHandlerRegistry
,TemplateProcessorRegistry
,TopLevelFolderItemFactoryRegistry
,TypeRegistry
,VideoConversionContributionHandler
contributionUpdated(String, Object, Object)
each time you need to store or remove a
contribution. Note that contribution objects that are registered by your implementation must not be modified.
You can see them as immutable objects - otherwise your local changes will be lost at the next update event.
To use it you should extends this abstract implementation and implement the abstract methods.
The implementation registry doesn't need to be thread safe since it will be called from synchronized methods.
Also, the contribution object
A simple implementation is:
public class MyRegistry extends ContributionFragmentRegistry<MyContribution> { public Map<String, MyContribution> registry = new HAshMap<String, MyContribution>(); public String getContributionId(MyContribution contrib) { return contrib.getId(); } public void contributionUpdated(String id, MyContribution contrib, MyContribution origContrib) { registry.put(id, contrib); } public void contributionRemoved(String id, MyContribution origContrib) { registry.remove(id); } public MyContribution clone(MyContribution contrib) { MyContribution clone = new MyContribution(contrib.getId()); clone.setSomeProperty(contrib.getSomeProperty()); ... return clone; } public void merge(MyContribution src, MyContribution dst) { dst.setSomeProperty(src.getSomeProperty()); ... } }Since 5.5, if the registry does not support merging of resources, you can just override the method
isSupportingMerge()
and return false, so that merge(Object, Object)
and Object.clone()
are never
called.- Author:
- Bogdan Stefanescu
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Deprecated.static class
Deprecated. -
Field Summary
Modifier and TypeFieldDescriptionprotected Map<String,
ContributionFragmentRegistry.FragmentList<T>> Deprecated. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addContribution
(T contrib) Deprecated.Add a new contribution.protected ContributionFragmentRegistry.FragmentList<T>
addFragment
(String id, T contrib) Deprecated.abstract T
Deprecated.CLone the given contribution objectabstract void
contributionRemoved
(String id, T origContrib) Deprecated.All the fragments in the contribution was removed.abstract void
contributionUpdated
(String id, T contrib, T newOrigContrib) Deprecated.Adds or updates a contribution.protected T
Deprecated.Get a merged contribution directly from the internal registry - and avoid passing by the implementation registry.abstract String
getContributionId
(T contrib) Deprecated.Returns the contribution ID given the contribution objectDeprecated.Get an array of all contribution fragmentsboolean
Deprecated.Returns true if merge is supported.abstract void
Deprecated.Merge 'src' into 'dst'.void
removeContribution
(T contrib) Deprecated.Remove a contribution.void
removeContribution
(T contrib, boolean useEqualsMethod) Deprecated.Remove a contribution.protected ContributionFragmentRegistry.FragmentList<T>
removeFragment
(String id, T contrib, boolean useEqualsMethod) Deprecated.toMap()
Deprecated.
-
Field Details
-
contribs
Deprecated.
-
-
Constructor Details
-
ContributionFragmentRegistry
public ContributionFragmentRegistry()Deprecated.
-
-
Method Details
-
getContributionId
Deprecated.Returns the contribution ID given the contribution object -
contributionUpdated
Deprecated.Adds or updates a contribution.If the contribution doesn't yet exists then it will be added, otherwise the value will be updated. If the given value is null the existing contribution must be removed.
The second parameter is the contribution that should be updated when merging, as well as stored and used. This usually represents a clone of the original contribution or a merge of multiple contribution fragments. Modifications on this object at application level will be lost on next method call on the same object id: modifications should be done in the
merge(Object, Object)
method.The last parameter is the new contribution object, unchanged (original) which was neither cloned nor merged. This object should never be modified at application level, because it will be used each time a subsequent merge is done. Also, it never should be stored.
- Parameters:
id
- - the id of the contribution that needs to be updatedcontrib
- the updated contribution object thatnewOrigContrib
- - the new, unchanged (original) contribution fragment that triggered the update.
-
contributionRemoved
Deprecated.All the fragments in the contribution was removed. Contribution must be unregistered.The first parameter is the contribution ID that should be remove and the second parameter the original contribution fragment that as unregistered causing the contribution to be removed.
-
clone
Deprecated.CLone the given contribution object -
merge
Deprecated.Merge 'src' into 'dst'. When merging only the 'dst' object is modified.- Parameters:
src
- the object to copy over the 'dst' objectdst
- this object is modified
-
isSupportingMerge
public boolean isSupportingMerge()Deprecated.Returns true if merge is supported.Hook method to be overridden if merge logics behind
Object.clone()
andmerge(Object, Object)
cannot be implemented.- Since:
- 5.5
-
addContribution
Deprecated.Add a new contribution. This will start install the new contribution and will notify the implementation about the value to add. (the final value to add may not be the same object as the one added - but a merge between multiple contributions) -
removeContribution
Deprecated.Remove a contribution. This will uninstall the contribution and notify the implementation about the new value it should store (after re-merging contribution fragments).Uses standard equality to check for old objects (useEqualsMethod == false).
- See Also:
-
removeContribution
Deprecated.Remove a contribution. This will uninstall the contribution and notify the implementation about the new value it should store (after re-merging contribution fragments).Equality can be controlled from here.
Contributions come from the runtime that keeps exact instances, so using equality usually makes it possible to remove the exact instance that was contributed by this component (without needing to reference the component name for instance). But when unit-testing, or when registrating contributions that do not come directly from the runtime, regirties need to use the equals method defined on each contribution.
- Parameters:
contrib
- the contrib to removeuseEqualsMethod
- a boolean stating that old contributions should be checked using the equals method instead of- Since:
- 5.6
-
getContribution
Deprecated.Get a merged contribution directly from the internal registry - and avoid passing by the implementation registry. Note that this operation will invoke a merge of existing fragments if needed.Since 5.5, this method has made protected as it should not be used by the service retrieving merged resources (otherwise merge will be done again). If you'd really like to call it, add a public method on your registry implementation that will call it.
-
getFragments
Deprecated.Get an array of all contribution fragments -
addFragment
Deprecated. -
removeFragment
protected ContributionFragmentRegistry.FragmentList<T> removeFragment(String id, T contrib, boolean useEqualsMethod) Deprecated. -
toMap
Deprecated.- Since:
- 9.3
-