Package org.alfresco.repo.module
Class AbstractModuleComponent
java.lang.Object
org.alfresco.repo.module.AbstractModuleComponent
- All Implemented Interfaces:
ModuleComponent,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware
- Direct Known Subclasses:
ImporterModuleComponent,LoggerModuleComponent
@AlfrescoPublicApi
public abstract class AbstractModuleComponent
extends Object
implements ModuleComponent, org.springframework.beans.factory.BeanNameAware
Implementation of a
ModuleComponent to provide
the basic necessities.- Since:
- 2.0
- Author:
- Roy Wetherall, Derek Hulley
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuthenticationComponentprotected ModuleServiceprotected ServiceRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks for the presence of all generally-required properties.booleanfinal voidexecute()Perform the actual component's work.protected abstract voidThe method that performs the actual work.A list of module components that must be executed prior to this instance.getName()inthashCode()voidinit()booleanvoidsetAppliesFromVersion(String version) Set the minimum module version number to which this component applies.voidsetAppliesToVersion(String version) Set the minimum module version number to which this component applies.voidsetAuthenticationComponent(AuthenticationComponent authenticationComponent) voidsetBeanName(String name) Convenience method that will set the name of the component to match the bean name, unless thenamehas been explicitly set.voidsetDependsOn(List<ModuleComponent> dependsOn) voidsetDescription(String description) Set the component's description.voidsetExecuteOnceOnly(boolean executeOnceOnly) voidsetModuleId(String moduleId) voidsetModuleService(ModuleService moduleService) Set the module service to register with.voidSet the component name, which must be unique within the context of the module.voidsetServiceRegistry(ServiceRegistry serviceRegistry) voidsetSinceVersion(String version) Set the version number for which this component was added.voidsetTenantAdminService(TenantAdminService tenantAdminService) final voidshutdown()Perform any cleanup required to remove module.toString()
-
Field Details
-
serviceRegistry
-
authenticationComponent
-
moduleService
-
-
Constructor Details
-
AbstractModuleComponent
public AbstractModuleComponent()
-
-
Method Details
-
checkProperties
protected void checkProperties()Checks for the presence of all generally-required properties. -
toString
-
equals
-
hashCode
public int hashCode() -
setAuthenticationComponent
-
setModuleService
Set the module service to register with. If not set, the component will not be automatically started.- Parameters:
moduleService- the service to register against. This is optional.
-
setServiceRegistry
-
setTenantAdminService
-
getModuleId
- Specified by:
getModuleIdin interfaceModuleComponent- Returns:
- Returns the globally unique module ID.
-
setModuleId
- Parameters:
moduleId- the globally unique module name.
-
getName
- Specified by:
getNamein interfaceModuleComponent- Returns:
- Returns the name of the component in the context of the module ID. It does not have to be globally unique.
-
setName
Set the component name, which must be unique within the context of the module. If the is not set, then the bean name will be used.- Parameters:
name- the name of the component within the module.- See Also:
-
setBeanName
Convenience method that will set the name of the component to match the bean name, unless thenamehas been explicitly set.- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
getDescription
- Specified by:
getDescriptionin interfaceModuleComponent- Returns:
- Returns a description of the component.
-
setDescription
Set the component's description. This will automatically be I18N'ized, so it may just be a resource bundle key.- Parameters:
description- a description of the component.
-
getSinceVersionNumber
- Specified by:
getSinceVersionNumberin interfaceModuleComponent- Returns:
- Returns the version number of the module for which this component was introduced.
-
setSinceVersion
Set the version number for which this component was added. -
getAppliesFromVersionNumber
- Specified by:
getAppliesFromVersionNumberin interfaceModuleComponent- Returns:
- Returns the smallest version number of the module to which this component applies.
-
setAppliesFromVersion
Set the minimum module version number to which this component applies. Default 0.0. -
getAppliesToVersionNumber
- Specified by:
getAppliesToVersionNumberin interfaceModuleComponent- Returns:
- Returns the largest version number of the module to which this component applies.
-
setAppliesToVersion
Set the minimum module version number to which this component applies. Default 999.0. -
getDependsOn
A list of module components that must be executed prior to this instance. This is the only way to guarantee ordered execution. The dependencies may include components from other modules, guaranteeing an early failure if a module is missing.- Specified by:
getDependsOnin interfaceModuleComponent- Returns:
- Returns a list of components that must be executed prior to this component.
-
setDependsOn
- Parameters:
dependsOn- a list of modules that must be executed before this one
-
isExecuteOnceOnly
public boolean isExecuteOnceOnly()- Specified by:
isExecuteOnceOnlyin interfaceModuleComponent- Returns:
- Returns true always. Override as required.
-
setExecuteOnceOnly
public void setExecuteOnceOnly(boolean executeOnceOnly) - Parameters:
executeOnceOnly- true to force execution of this component with each startup or false if it must only be executed once.
-
init
public void init() -
executeInternal
The method that performs the actual work. For the most part, derived classes will only have to override this method to be fully functional.- Throws:
Throwable- any problems, just throw them
-
execute
public final void execute()Perform the actual component's work. Execution will be done within the context of a system account with an enclosing transaction. Long-running processes should be spawned from the calling thread, if required. All failures should just be thrown out as runtime exceptions and will be dealt with by the associated module infrastructure.- Specified by:
executein interfaceModuleComponent- See Also:
-
shutdown
public final void shutdown()Description copied from interface:ModuleComponentPerform any cleanup required to remove module.- Specified by:
shutdownin interfaceModuleComponent
-