Class RuntimeExecBootstrapBean

java.lang.Object
org.springframework.extensions.surf.util.AbstractLifecycleBean
org.alfresco.util.exec.RuntimeExecBootstrapBean
All Implemented Interfaces:
EventListener, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener

public class RuntimeExecBootstrapBean extends org.springframework.extensions.surf.util.AbstractLifecycleBean
Application bootstrap bean that is able to execute one or more native executable statements upon startup and shutdown.
Author:
Derek Hulley
  • Field Summary

    Fields inherited from class org.springframework.extensions.surf.util.AbstractLifecycleBean

    log
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes the bean failOnError = true killProcessesOnShutdown = true enabled = true
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    onBootstrap(org.springframework.context.ApplicationEvent event)
     
    protected void
    onShutdown(org.springframework.context.ApplicationEvent event)
    Handle the shutdown of a subsystem but not the entire VM
    void
    setDisabledAtStartUp(String disabledAtStartUp)
    Deprecated.
    Use setEnabled(java.lang.String) instead, remembering that the boolean property should be inverted.
    void
    setEnabled(String enabled)
    Set whether or not the process should be enabled at ApplicationContext bootstrap.
    void
     
    void
    setFailOnError(boolean failOnError)
    Set whether a process failure generates an error or not.
    void
    setKillProcessesOnShutdown(boolean killProcessesOnShutdown)
    Set whether or not to force a shutdown of successfully started processes.
    void
    Set the commands to execute, in sequence, when the application context is initialized.

    Methods inherited from class org.springframework.extensions.surf.util.AbstractLifecycleBean

    getApplicationContext, onApplicationEvent, setApplicationContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RuntimeExecBootstrapBean

      public RuntimeExecBootstrapBean()
      Initializes the bean
      • failOnError = true
      • killProcessesOnShutdown = true
      • enabled = true
  • Method Details

    • setStartupCommands

      public void setStartupCommands(List<RuntimeExec> startupCommands)
      Set the commands to execute, in sequence, when the application context is initialized.
      Parameters:
      startupCommands - list of commands
    • setFailOnError

      public void setFailOnError(boolean failOnError)
      Set whether a process failure generates an error or not. Deviation from the default is useful if use as part of a process where the command or the codes generated by the execution may be ignored or avoided by the system.
      Parameters:
      failOnError - true (default) to issue an error message and throw an exception if the process fails to execute or generates an error return value.
      Since:
      2.1
    • setKillProcessesOnShutdown

      public void setKillProcessesOnShutdown(boolean killProcessesOnShutdown)
      Set whether or not to force a shutdown of successfully started processes. As most bootstrap processes are kicked off in order to provide the server with some or other service, this is true by default.
      Parameters:
      killProcessesOnShutdown - true to force any successfully executed commands' processes to be forcibly killed when the server shuts down.
      Since:
      2.1.0
    • setDisabledAtStartUp

      public void setDisabledAtStartUp(String disabledAtStartUp)
      Deprecated.
      Use setEnabled(java.lang.String) instead, remembering that the boolean property should be inverted.
      Set whether or not the process should be disabled at ApplicationContext bootstrap. If a RuntimeExecBootstrapBean is disabled, then the command will not be executed. This property is not required and is false by default.

      This method has been deprecated in favour of a clearer name introduced in 3.3. See setEnabled(java.lang.String).

      Parameters:
      disabledAtStartUp - any String which equalsIgnoreCase("true") to prevent the command from being executed.
      Since:
      3.2.1
    • setEnabled

      public void setEnabled(String enabled)
      Set whether or not the process should be enabled at ApplicationContext bootstrap. If a RuntimeExecBootstrapBean is not enabled, then the command will not be executed. This property is not required and is true by default.
      Parameters:
      enabled - any String which does not equalsIgnoreCase("true") will prevent the command from being executed.
      Since:
      3.3
    • setEnabledFromBean

      public void setEnabledFromBean(BooleanBean enabled)
    • onBootstrap

      protected void onBootstrap(org.springframework.context.ApplicationEvent event)
      Specified by:
      onBootstrap in class org.springframework.extensions.surf.util.AbstractLifecycleBean
    • onShutdown

      protected void onShutdown(org.springframework.context.ApplicationEvent event)
      Handle the shutdown of a subsystem but not the entire VM
      Specified by:
      onShutdown in class org.springframework.extensions.surf.util.AbstractLifecycleBean