Package org.nuxeo.ecm.core.uidgen
Class UIDGeneratorComponent
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.ecm.core.uidgen.UIDGeneratorComponent
-
- All Implemented Interfaces:
UIDGeneratorService
,Adaptable
,Component
,Extensible
,TimestampedService
public class UIDGeneratorComponent extends DefaultComponent implements UIDGeneratorService
Service that writes MetaData.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
defaultSequencer
static String
EXTENSION_POINT_SEQUENCER_FACTORY
Extension point is deprecated should be removed - preserved for now only for startup warnings.protected Map<String,UIDGenerator>
generators
static String
ID
protected LinkedHashMap<String,UIDSequencerProviderDescriptor>
sequencerContribs
protected Map<String,UIDSequencer>
sequencers
static String
SEQUENCERS_EXTENSION_POINT
static String
UID_GENERATORS_EXTENSION_POINT
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description UIDGeneratorComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
computeDefault()
String
createUID(DocumentModel doc)
<T> T
getAdapter(Class<T> adapter)
Returns an object which is an instance of the given class associated with this object.UIDSequencer
getSequencer()
Retrieves the defaultUIDSequencer
UIDSequencer
getSequencer(String name)
RetrievesUIDSequencer
by it's nameUIDGenerator
getUIDGeneratorFor(DocumentModel doc)
Returns the uid generator to use for this document.void
registerExtension(Extension extension)
Registers the given extension.protected void
registerGenerators(Extension extension, Object[] contribs)
protected void
registerSequencers(Extension extension, Object[] contribs)
void
setUID(DocumentModel doc)
Creates a new UID for the given doc and sets the field configured in the generator component with this value.void
start(ComponentContext context)
Start the component.void
stop(ComponentContext context)
Stop the component.void
unregisterExtension(Extension extension)
Unregisters the given extension.protected void
unregisterSequencers(Extension extension, Object[] contribs)
-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, setLastModified, setModifiedNow, setName, unregister, unregisterContribution
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
ID
public static final String ID
- See Also:
- Constant Field Values
-
UID_GENERATORS_EXTENSION_POINT
public static final String UID_GENERATORS_EXTENSION_POINT
- See Also:
- Constant Field Values
-
SEQUENCERS_EXTENSION_POINT
public static final String SEQUENCERS_EXTENSION_POINT
- See Also:
- Constant Field Values
-
EXTENSION_POINT_SEQUENCER_FACTORY
public static final String EXTENSION_POINT_SEQUENCER_FACTORY
Extension point is deprecated should be removed - preserved for now only for startup warnings.- See Also:
- Constant Field Values
-
generators
protected final Map<String,UIDGenerator> generators
-
sequencers
protected final Map<String,UIDSequencer> sequencers
-
sequencerContribs
protected final LinkedHashMap<String,UIDSequencerProviderDescriptor> sequencerContribs
-
defaultSequencer
protected String defaultSequencer
-
-
Method Detail
-
start
public void start(ComponentContext context)
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
stop
public void stop(ComponentContext context)
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
-
registerExtension
public void registerExtension(Extension extension)
Description copied from interface:Extensible
Registers the given extension.- Specified by:
registerExtension
in interfaceExtensible
- Overrides:
registerExtension
in classDefaultComponent
- Parameters:
extension
- the extension to register
-
unregisterExtension
public void unregisterExtension(Extension extension)
Description copied from interface:Extensible
Unregisters the given extension.- Specified by:
unregisterExtension
in interfaceExtensible
- Overrides:
unregisterExtension
in classDefaultComponent
- Parameters:
extension
- the extension to unregister
-
computeDefault
protected void computeDefault()
-
getUIDGeneratorFor
public UIDGenerator getUIDGeneratorFor(DocumentModel doc)
Returns the uid generator to use for this document.Choice is made following the document type and the generator configuration.
- Specified by:
getUIDGeneratorFor
in interfaceUIDGeneratorService
-
setUID
public void setUID(DocumentModel doc) throws PropertyNotFoundException
Creates a new UID for the given doc and sets the field configured in the generator component with this value.- Specified by:
setUID
in interfaceUIDGeneratorService
- Throws:
PropertyNotFoundException
-
createUID
public String createUID(DocumentModel doc)
- Specified by:
createUID
in interfaceUIDGeneratorService
- Returns:
- a new UID for the given document
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
Description copied from interface:Adaptable
Returns an object which is an instance of the given class associated with this object. Returnsnull
if no such object can be found.- Specified by:
getAdapter
in interfaceAdaptable
- Overrides:
getAdapter
in classDefaultComponent
- Parameters:
adapter
- the adapter class to look up- Returns:
- a object castable to the given class, or
null
if this object does not have an adapter for the given class
-
getSequencer
public UIDSequencer getSequencer()
Description copied from interface:UIDGeneratorService
Retrieves the defaultUIDSequencer
- Specified by:
getSequencer
in interfaceUIDGeneratorService
- Returns:
- the default
UIDSequencer
-
getSequencer
public UIDSequencer getSequencer(String name)
Description copied from interface:UIDGeneratorService
RetrievesUIDSequencer
by it's name- Specified by:
getSequencer
in interfaceUIDGeneratorService
- Parameters:
name
- the name of theUIDSequencer
- Returns:
- the
UIDSequencer
matching the name
-
-