Class List Method List File List

# Class: VertxShell::Job

Inherits:
  Object
  - Object
  - VertxShell::Job
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb

## Overview

A job executed in a JobController, grouping one or several process.

The job life cycle can be controlled with the #run, #resume and #suspend and #interrupt methods.

## Instance Method Summary (collapse)

- - (Fixnum) id
  @return the job id.
- - (true, false) interrupt?
  Attempt to interrupt the job.
- - (Fixnum) last_stopped
  @return when the job was last stopped.
- - (String) line
  @return the execution line of the job, i.e the shell command line that launched this job.
- - (::VertxShell::Process) process
  @return the first process in the job.
- - (self) resume(foreground = nil)
  Resume the job.
- - (self) run
  Run the job, before running the job a must be set.
- - (self) set_session(session = nil)
  Set a session on the job.
- - (self) set_tty(tty = nil)
  Set a tty on the job.
- - (:READY, ...) status
  @return the job exec status.
- - (self) status_update_handler { ... }
  Set an handler called when the job terminates.
- - (self) suspend
  Resume the job.
- - (void) terminate
  Terminate the job.
- - (self) to_background
  Send the job to background.
- - (self) to_foreground
  Send the job to foreground.

## Instance Method Details

### - (`Fixnum`) id

@return the job id

Returns:

- (`Fixnum`)

Raises:

- (`ArgumentError`)

    24
    25
    26
    27
    28
    29
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 24

    def id
      if !block_given?
        return @j_del.java_method(:id, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling id()"
    end

### - (`true`, `false`) interrupt?

Attempt to interrupt the job.

Returns:

- (`true`, `false`) —
  true if the job is actually interrupted

Raises:

- (`ArgumentError`)

    95
    96
    97
    98
    99
    100
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 95

    def interrupt?
      if !block_given?
        return @j_del.java_method(:interrupt, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling interrupt?()"
    end

### - (`Fixnum`) last_stopped

@return when the job was last stopped

Returns:

- (`Fixnum`)

Raises:

- (`ArgumentError`)

    40
    41
    42
    43
    44
    45
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 40

    def last_stopped
      if !block_given?
        return @j_del.java_method(:lastStopped, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling last_stopped()"
    end

### - (`String`) line

@return the execution line of the job, i.e the shell command line that launched this job

Returns:

- (`String`)

Raises:

- (`ArgumentError`)

    48
    49
    50
    51
    52
    53
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 48

    def line
      if !block_given?
        return @j_del.java_method(:line, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling line()"
    end

### - (`::VertxShell::Process`) process

@return the first process in the job

Returns:

- (`::VertxShell::Process`)

Raises:

- (`ArgumentError`)

    150
    151
    152
    153
    154
    155
    156
    157
    158
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 150

    def process
      if !block_given?
        if @cached_process != nil
          return @cached_process
        end
        return @cached_process = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:process, []).call(),::VertxShell::Process)
      end
      raise ArgumentError, "Invalid arguments when calling process()"
    end

### - (`self`) resume(foreground = nil)

Resume the job.

Parameters:

- foreground (`true`, `false`) (defaults to: `nil`) —
  true when the job is resumed in foreground

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    104
    105
    106
    107
    108
    109
    110
    111
    112
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 104

    def resume(foreground=nil)
      if !block_given? && foreground == nil
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:resume, []).call(),::VertxShell::Job)
      elsif (foreground.class == TrueClass || foreground.class == FalseClass) && !block_given?
        @j_del.java_method(:resume, [Java::boolean.java_class]).call(foreground)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling resume(foreground)"
    end

### - (`self`) run

Run the job, before running the job a must be set.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    86
    87
    88
    89
    90
    91
    92
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 86

    def run
      if !block_given?
        @j_del.java_method(:run, []).call()
        return self
      end
      raise ArgumentError, "Invalid arguments when calling run()"
    end

### - (`self`) set_session(session = nil)

Set a session on the job.

Parameters:

- session (`::VertxShell::Session`) (defaults to: `nil`) —
  the session to use

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    67
    68
    69
    70
    71
    72
    73
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 67

    def set_session(session=nil)
      if session.class.method_defined?(:j_del) && !block_given?
        @j_del.java_method(:setSession, [Java::IoVertxExtShellSession::Session.java_class]).call(session.j_del)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_session(session)"
    end

### - (`self`) set_tty(tty = nil)

Set a tty on the job.

Parameters:

- tty (`::VertxShell::Tty`) (defaults to: `nil`) —
  the tty to use

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    57
    58
    59
    60
    61
    62
    63
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 57

    def set_tty(tty=nil)
      if tty.class.method_defined?(:j_del) && !block_given?
        @j_del.java_method(:setTty, [Java::IoVertxExtShellTerm::Tty.java_class]).call(tty.j_del)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_tty(tty)"
    end

### - (`:READY`, ...) status

@return the job exec status

Returns:

- (`:READY`, `:RUNNING`, `:STOPPED`, `:TERMINATED`)

Raises:

- (`ArgumentError`)

    32
    33
    34
    35
    36
    37
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 32

    def status
      if !block_given?
        return @j_del.java_method(:status, []).call().name.intern
      end
      raise ArgumentError, "Invalid arguments when calling status()"
    end

### - (`self`) status_update_handler { ... }

Set an handler called when the job terminates.

Yields:

- the terminate handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    77
    78
    79
    80
    81
    82
    83
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 77

    def status_update_handler
      if block_given?
        @j_del.java_method(:statusUpdateHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event.name.intern) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling status_update_handler()"
    end

### - (`self`) suspend

Resume the job.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    133
    134
    135
    136
    137
    138
    139
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 133

    def suspend
      if !block_given?
        @j_del.java_method(:suspend, []).call()
        return self
      end
      raise ArgumentError, "Invalid arguments when calling suspend()"
    end

### - (`void`) terminate

This method returns an undefined value.

Terminate the job.

Raises:

- (`ArgumentError`)

    142
    143
    144
    145
    146
    147
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 142

    def terminate
      if !block_given?
        return @j_del.java_method(:terminate, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling terminate()"
    end

### - (`self`) to_background

Send the job to background.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    115
    116
    117
    118
    119
    120
    121
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 115

    def to_background
      if !block_given?
        @j_del.java_method(:toBackground, []).call()
        return self
      end
      raise ArgumentError, "Invalid arguments when calling to_background()"
    end

### - (`self`) to_foreground

Send the job to foreground.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    124
    125
    126
    127
    128
    129
    130
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 124

    def to_foreground
      if !block_given?
        @j_del.java_method(:toForeground, []).call()
        return self
      end
      raise ArgumentError, "Invalid arguments when calling to_foreground()"
    end