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.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (Fixnum) id
  The job id.
- - (true, false) interrupt
  Attempt to interrupt the job.
- - (Fixnum) last_stopped
  When the job was last stopped.
- - (String) line
  The execution line of the job, i.e the shell command line that launched this job.
- - (::VertxShell::Process) process
  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
  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.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

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

    def @@j_api_type.accept?(obj)
      obj.class == Job
    end

### + (`Object`) j_api_type

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

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

    def self.j_class
      Java::IoVertxExtShellSystem::Job.java_class
    end

### + (`Object`) unwrap(obj)

    29
    30
    31
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 29

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

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

    def @@j_api_type.wrap(obj)
      Job.new(obj)
    end

## Instance Method Details

### - (`Fixnum`) id

Returns the job id

Returns:

- (`Fixnum`) —
  the job id

Raises:

- (`ArgumentError`)

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

    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`)

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

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

### - (`Fixnum`) last_stopped

Returns when the job was last stopped

Returns:

- (`Fixnum`) —
  when the job was last stopped

Raises:

- (`ArgumentError`)

    53
    54
    55
    56
    57
    58
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 53

    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

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

Returns:

- (`String`) —
  the execution line of the job, i.e the shell command line that launched this job

Raises:

- (`ArgumentError`)

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

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

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

Returns the first process in the job

Returns:

- (`::VertxShell::Process`) —
  the first process in the job

Raises:

- (`ArgumentError`)

    161
    162
    163
    164
    165
    166
    167
    168
    169
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 161

    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`)

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

    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`)

    98
    99
    100
    101
    102
    103
    104
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 98

    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`)

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

    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`)

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

    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

Returns the job exec status

Returns:

- (`:READY`, `:RUNNING`, `:STOPPED`, `:TERMINATED`) —
  the job exec status

Raises:

- (`ArgumentError`)

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

    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`)

    89
    90
    91
    92
    93
    94
    95
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 89

    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`)

    145
    146
    147
    148
    149
    150
    151
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 145

    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`)

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

    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`)

    127
    128
    129
    130
    131
    132
    133
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 127

    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`)

    136
    137
    138
    139
    140
    141
    142
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/job.rb', line 136

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