Package org.exoplatform.commons.upgrade
Class UpgradeProductPlugin
- java.lang.Object
-
- org.exoplatform.container.component.BaseComponentPlugin
-
- org.exoplatform.commons.upgrade.UpgradeProductPlugin
-
- All Implemented Interfaces:
org.exoplatform.container.component.ComponentPlugin
public abstract class UpgradeProductPlugin extends org.exoplatform.container.component.BaseComponentPlugin
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanasyncUpgradeExecutionTrue if the upgrade execution should be processed asynchronously else, it will be executed synchronouslyprotected booleanexecuteOnlyOnceDetermines whether the plugin should be executed once or even version upgrade.static StringOLD_PRODUCT_GROUP_IDprotected StringoldProductGroupIdstatic StringPRODUCT_GROUP_IDprotected StringproductGroupIdThe plugin's product maven group identifier, by example: org.exoplatform.portal for gatein.protected StringtargetVersionThe target version of this upgrade Plugin.static StringUPGRADE_COMPLETED_STATUSstatic StringUPGRADE_PLUGIN_ASYNCstatic StringUPGRADE_PLUGIN_ENABLEstatic StringUPGRADE_PLUGIN_EXECUTE_ONCE_PARAMETERstatic StringUPGRADE_PLUGIN_EXECUTION_ORDERstatic StringUPGRADE_PLUGIN_TARGET_PARAMETER
-
Constructor Summary
Constructors Constructor Description UpgradeProductPlugin(org.exoplatform.commons.api.settings.SettingService settingService, org.exoplatform.container.xml.InitParams initParams)UpgradeProductPlugin(org.exoplatform.container.xml.InitParams initParams)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidafterUpgrade()Execute some operations synchronously after the execution of processUpgrade method synchronously or asynchronouslyvoidbeforeUpgrade()Execute some operations synchronously after the execution of processUpgrade method synchronously or asynchronouslybooleanequals(Object obj)intgetPluginExecutionOrder()StringgetProductGroupId()StringgetTargetVersion()StringgetValue(String paramName)inthashCode()booleanisAsyncUpgradeExecution()booleanisEnabled()Determines if the plugin is enabled, this method will be called when adding the plugin to the upgradePlugins list.booleanisExecuteOnlyOnce()abstract voidprocessUpgrade(String oldVersion, String newVersion)Proceed to the transparent upgrade, this method will be called if the Product version has changed, which means, it will be called once the stored Product Version and the one declared in ProductInfo are differentbooleanshouldProceedToUpgrade(String newVersion, String previousVersion)This method is called when a new version has been detected to decide whether proceed to upgrade or not.booleanshouldProceedToUpgrade(String newVersion, String previousGroupVersion, UpgradePluginExecutionContext previousUpgradePluginExecution)This method is called when a new version has been detected to decide whether proceed to upgrade or not.voidstoreValueForPlugin(String paramName, String paramValue)
-
-
-
Field Detail
-
UPGRADE_COMPLETED_STATUS
public static final String UPGRADE_COMPLETED_STATUS
- See Also:
- Constant Field Values
-
PRODUCT_GROUP_ID
public static final String PRODUCT_GROUP_ID
- See Also:
- Constant Field Values
-
OLD_PRODUCT_GROUP_ID
public static final String OLD_PRODUCT_GROUP_ID
- See Also:
- Constant Field Values
-
UPGRADE_PLUGIN_ASYNC
public static final String UPGRADE_PLUGIN_ASYNC
- See Also:
- Constant Field Values
-
UPGRADE_PLUGIN_TARGET_PARAMETER
public static final String UPGRADE_PLUGIN_TARGET_PARAMETER
- See Also:
- Constant Field Values
-
UPGRADE_PLUGIN_EXECUTE_ONCE_PARAMETER
public static final String UPGRADE_PLUGIN_EXECUTE_ONCE_PARAMETER
- See Also:
- Constant Field Values
-
UPGRADE_PLUGIN_EXECUTION_ORDER
public static final String UPGRADE_PLUGIN_EXECUTION_ORDER
- See Also:
- Constant Field Values
-
UPGRADE_PLUGIN_ENABLE
public static final String UPGRADE_PLUGIN_ENABLE
- See Also:
- Constant Field Values
-
productGroupId
protected String productGroupId
The plugin's product maven group identifier, by example: org.exoplatform.portal for gatein.
-
oldProductGroupId
protected String oldProductGroupId
-
targetVersion
protected String targetVersion
The target version of this upgrade Plugin.
-
asyncUpgradeExecution
protected boolean asyncUpgradeExecution
True if the upgrade execution should be processed asynchronously else, it will be executed synchronously
-
executeOnlyOnce
protected boolean executeOnlyOnce
Determines whether the plugin should be executed once or even version upgrade. If true, the method shouldProceedToUpgrade will not be called to test if the Upgrade Plugin should be executed or not.
-
-
Method Detail
-
getProductGroupId
public String getProductGroupId()
-
beforeUpgrade
public void beforeUpgrade()
Execute some operations synchronously after the execution of processUpgrade method synchronously or asynchronously
-
afterUpgrade
public void afterUpgrade()
Execute some operations synchronously after the execution of processUpgrade method synchronously or asynchronously
-
isAsyncUpgradeExecution
public boolean isAsyncUpgradeExecution()
-
isExecuteOnlyOnce
public boolean isExecuteOnlyOnce()
-
getTargetVersion
public String getTargetVersion()
-
isEnabled
public boolean isEnabled()
Determines if the plugin is enabled, this method will be called when adding the plugin to the upgradePlugins list. SeeUpgradeProductService.addUpgradePlugin(UpgradeProductPlugin)- Returns:
- true: if the plugin is enabled: should be added to the upgradePlugins list false: if the plugin is disabled: should not be added to the upgradePlugins list
-
processUpgrade
public abstract void processUpgrade(String oldVersion, String newVersion)
Proceed to the transparent upgrade, this method will be called if the Product version has changed, which means, it will be called once the stored Product Version and the one declared in ProductInfo are different- Parameters:
oldVersion- the old version that is stored in internal datasourcenewVersion- the new version read from ProductInfo Service
-
shouldProceedToUpgrade
public boolean shouldProceedToUpgrade(String newVersion, String previousVersion)
This method is called when a new version has been detected to decide whether proceed to upgrade or not. It should take care that some versions could be skipped while upgrading, i.e: the upgrade could happen when the product is switched from version 1.0 to 1.3.- Parameters:
previousVersion- The previous version of plugin's productnewVersion- The previous version of plugin's product- Returns:
- true: if the plugin should be executed when switching product from previousVersion to newVersion false: if the upgrade isn't necessary
-
shouldProceedToUpgrade
public boolean shouldProceedToUpgrade(String newVersion, String previousGroupVersion, UpgradePluginExecutionContext previousUpgradePluginExecution)
This method is called when a new version has been detected to decide whether proceed to upgrade or not. It will test on previous version of artifact, previous version of group and newer version to decide whether to upgrade or not. This method will call shouldProceedToUpgrade(previousVersion, newVersion) to include optional specific check(s).- Parameters:
newVersion- The current version of running serverpreviousGroupVersion- The previous version of plugin's product group (social, portal...) This parameter will be equals to '0' if first time it runs.previousUpgradePluginExecution- The previous version and execution count of plugin (retrieved from last run) This parameter will be null if first time it runs.- Returns:
- true: if the plugin should be executed when switching product from previousVersion to newVersion false: if the upgrade isn't necessary
-
getPluginExecutionOrder
public int getPluginExecutionOrder()
-
-