Class AbstractUpgradeOperation<T>

java.lang.Object
org.craftercms.commons.upgrade.impl.operations.AbstractUpgradeOperation<T>
Type Parameters:
T - The target type supported
All Implemented Interfaces:
UpgradeOperation<T>, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
UpdateVersionUpgradeOperation

public abstract class AbstractUpgradeOperation<T> extends Object implements UpgradeOperation<T>, org.springframework.context.ApplicationContextAware
Base class for all UpgradeOperation implementations that provides access to system resources Supported YAML properties:
  • currentVersion: (required) the version number that will be upgraded
  • nextVersion (required) the version number to use after the upgrade
Since:
3.1.5
Author:
joseross
  • Field Details

    • logger

      protected org.slf4j.Logger logger
    • currentVersion

      protected String currentVersion
      The current version.
    • nextVersion

      protected String nextVersion
      The next version.
    • enabled

      protected boolean enabled
      Indicates if the operation should be executed, true by default
    • applicationContext

      protected org.springframework.context.ApplicationContext applicationContext
      The application context
  • Constructor Details

    • AbstractUpgradeOperation

      public AbstractUpgradeOperation()
  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • setEnabled

      public void setEnabled(boolean enabled)
    • init

      public void init(String currentVersion, String nextVersion, org.apache.commons.configuration2.HierarchicalConfiguration<?> config) throws ConfigurationException
      Description copied from interface: UpgradeOperation
      Initializes the instance with the given configuration
      Specified by:
      init in interface UpgradeOperation<T>
      Parameters:
      currentVersion - the current version
      nextVersion - the next version
      config - the operation configuration
      Throws:
      ConfigurationException
    • doInit

      protected void doInit(org.apache.commons.configuration2.HierarchicalConfiguration<?> config) throws ConfigurationException
      Throws:
      ConfigurationException
    • execute

      public void execute(UpgradeContext<T> context) throws UpgradeException
      Description copied from interface: UpgradeOperation
      Performs a single upgrade operation.
      Specified by:
      execute in interface UpgradeOperation<T>
      Parameters:
      context - the upgrade context
      Throws:
      UpgradeException - if there is any error performing the upgrade
    • doExecute

      protected abstract void doExecute(UpgradeContext<T> context) throws Exception
      Throws:
      Exception
    • loadResource

      protected org.springframework.core.io.Resource loadResource(String path)