org.alfresco.repo.module
Class AbstractModuleComponent

java.lang.Object
  extended by org.alfresco.repo.module.AbstractModuleComponent
All Implemented Interfaces:
ModuleComponent, org.springframework.beans.factory.BeanNameAware
Direct Known Subclasses:
ImporterModuleComponent, LoggerModuleComponent, ModuleComponentHelperTest.NoopModuleComponent

public abstract class AbstractModuleComponent
extends java.lang.Object
implements ModuleComponent, org.springframework.beans.factory.BeanNameAware

Implementation of a ModuleComponent to provide the basic necessities.

Since:
2.0
See Also:
AbstractModuleComponent.executeInternal()

Field Summary
protected  AuthenticationComponent authenticationComponent
           
protected  ModuleService moduleService
           
protected  ServiceRegistry serviceRegistry
           
 
Constructor Summary
AbstractModuleComponent()
           
 
Method Summary
protected  void checkProperties()
          Checks for the presence of all generally-required properties.
 boolean equals(java.lang.Object obj)
           
 void execute()
          Perform the actual component's work.
protected abstract  void executeInternal()
          The method that performs the actual work.
 org.alfresco.util.VersionNumber getAppliesFromVersionNumber()
          
 org.alfresco.util.VersionNumber getAppliesToVersionNumber()
          
 java.util.List getDependsOn()
          A list of module components that must be executed prior to this instance.
 java.lang.String getDescription()
          
 java.lang.String getModuleId()
          
 java.lang.String getName()
          
 org.alfresco.util.VersionNumber getSinceVersionNumber()
          
 int hashCode()
           
 void init()
           
 boolean isExecuteOnceOnly()
          
 void setAppliesFromVersion(java.lang.String version)
          Set the minimum module version number to which this component applies.
 void setAppliesToVersion(java.lang.String version)
          Set the minimum module version number to which this component applies.
 void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
           
 void setBeanName(java.lang.String name)
          Convenience method that will set the name of the component to match the bean name, unless the name has been explicitly set.
 void setDependsOn(java.util.List dependsOn)
           
 void setDescription(java.lang.String description)
          Set the component's description.
 void setExecuteOnceOnly(boolean executeOnceOnly)
           
 void setModuleId(java.lang.String moduleId)
           
 void setModuleService(ModuleService moduleService)
          Set the module service to register with.
 void setName(java.lang.String name)
          Set the component name, which must be unique within the context of the module.
 void setServiceRegistry(ServiceRegistry serviceRegistry)
           
 void setSinceVersion(java.lang.String version)
          Set the version number for which this component was added.
 void setTenantAdminService(TenantAdminService tenantAdminService)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serviceRegistry

protected ServiceRegistry serviceRegistry

authenticationComponent

protected AuthenticationComponent authenticationComponent

moduleService

protected ModuleService moduleService
Constructor Detail

AbstractModuleComponent

public AbstractModuleComponent()
Method Detail

checkProperties

protected void checkProperties()
Checks for the presence of all generally-required properties.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
AbstractModuleComponent.getModuleId(), AbstractModuleComponent.getName()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

setAuthenticationComponent

public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)

setModuleService

public void setModuleService(ModuleService moduleService)
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

public void setServiceRegistry(ServiceRegistry serviceRegistry)

setTenantAdminService

public void setTenantAdminService(TenantAdminService tenantAdminService)

getModuleId

public java.lang.String getModuleId()

Specified by:
getModuleId in interface ModuleComponent
Returns:
Returns the globally unique module ID.

setModuleId

public void setModuleId(java.lang.String moduleId)
Parameters:
moduleId - the globally unique module name.

getName

public java.lang.String getName()

Specified by:
getName in interface ModuleComponent
Returns:
Returns the name of the component in the context of the module ID. It does not have to be globally unique.

setName

public void setName(java.lang.String name)
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:
AbstractModuleComponent.setBeanName(String)

setBeanName

public void setBeanName(java.lang.String name)
Convenience method that will set the name of the component to match the bean name, unless the name has been explicitly set.

Specified by:
setBeanName in interface org.springframework.beans.factory.BeanNameAware

getDescription

public java.lang.String getDescription()

Specified by:
getDescription in interface ModuleComponent
Returns:
Returns a description of the component.

setDescription

public void setDescription(java.lang.String description)
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

public org.alfresco.util.VersionNumber getSinceVersionNumber()

Specified by:
getSinceVersionNumber in interface ModuleComponent
Returns:
Returns the version number of the module for which this component was introduced.

setSinceVersion

public void setSinceVersion(java.lang.String version)
Set the version number for which this component was added.


getAppliesFromVersionNumber

public org.alfresco.util.VersionNumber getAppliesFromVersionNumber()

Specified by:
getAppliesFromVersionNumber in interface ModuleComponent
Returns:
Returns the smallest version number of the module to which this component applies.

setAppliesFromVersion

public void setAppliesFromVersion(java.lang.String version)
Set the minimum module version number to which this component applies. Default 0.0.


getAppliesToVersionNumber

public org.alfresco.util.VersionNumber getAppliesToVersionNumber()

Specified by:
getAppliesToVersionNumber in interface ModuleComponent
Returns:
Returns the largest version number of the module to which this component applies.

setAppliesToVersion

public void setAppliesToVersion(java.lang.String version)
Set the minimum module version number to which this component applies. Default 999.0.


getDependsOn

public java.util.List 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:
getDependsOn in interface ModuleComponent
Returns:
Returns a list of components that must be executed prior to this component.

setDependsOn

public void setDependsOn(java.util.List dependsOn)
Parameters:
dependsOn - a list of modules that must be executed before this one

isExecuteOnceOnly

public boolean isExecuteOnceOnly()

Specified by:
isExecuteOnceOnly in interface ModuleComponent
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

protected abstract void executeInternal()
                                 throws java.lang.Throwable
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:
java.lang.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:
execute in interface ModuleComponent
See Also:
the abstract method to be implemented by subclasses


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.