|
Nuxeo Enterprise Platform 5.4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.nuxeo.runtime.model.ContributionFragmentRegistry<T>
public abstract class ContributionFragmentRegistry<T>
This is a contribution registry that is managing contribution fragments and merge them as needed.
The implementation will be notified through #contributionUpdated(String, 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{ public Map registry = new HAshMap (); 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()); ... } }
Nested Class Summary | |
---|---|
static class |
ContributionFragmentRegistry.Fragment<T>
|
static class |
ContributionFragmentRegistry.FragmentList<T>
|
Constructor Summary | |
---|---|
ContributionFragmentRegistry()
|
Method Summary | |
---|---|
void |
addContribution(T contrib)
Add a new contribution. |
abstract T |
clone(T object)
CLone the given contribution object |
abstract void |
contributionRemoved(String id,
T origContrib)
All the fragments in the contribution was removed. |
abstract void |
contributionUpdated(String id,
T contrib,
T origContrib)
Add or update a contribution. |
T |
getContribution(String id)
Get a merged contribution directly from the internal registry - and avoid passing by the implementation registry. |
abstract String |
getContributionId(T contrib)
Get the contribution ID given the contribution object |
ContributionFragmentRegistry.FragmentList<T>[] |
getFragments()
Get an array of all contribution fragments |
abstract void |
merge(T src,
T dst)
Merge 'src' into 'dst'. |
void |
removeContribution(T contrib)
Remove a contribution. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ContributionFragmentRegistry()
Method Detail |
---|
public abstract String getContributionId(T contrib)
contrib
-
public abstract void contributionUpdated(String id, T contrib, T origContrib)
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 actual contribution value which should be stored (updated).
This usually represent 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 contributionUpdated(String, Object, Object)
call on the same object id.
The last parameter is the original contribution object which was either cloned or merged.
You should never modify this object at application level. Because it will be used each time a subsequent
merge is done.
Also you should not store this object. Usually you will never need to touch this object.
id
- - the id of the contribution that need to be updatedcontrib
- the updated contribution object thatorigContrib
- - the original contribution fragment that triggered the update.public abstract void contributionRemoved(String id, T origContrib)
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.
id
- origContrib
- public abstract T clone(T object)
object
-
public abstract void merge(T src, T dst)
src
- the object to copy over the 'dst' objectdst
- this object is modifiedpublic void addContribution(T contrib)
contrib
- public void removeContribution(T contrib)
contrib
- public T getContribution(String id)
id
-
public ContributionFragmentRegistry.FragmentList<T>[] getFragments()
|
Nuxeo Enterprise Platform 5.4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |