Class 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
    • Constructor Detail

      • RuntimeExecBootstrapBean

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

      • 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