Class List Method List File List

# Class: VertxShell::ShellServer

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

## Overview

The shell server.

A shell server is associated with a collection of : the #register_term_server method registers a term server. Term servers life cycle are managed by this server.

When a receives an incoming connection, a instance is created and associated with this connection.

The #create_shell method can be used to create instance for testing purposes.

## Class Method Summary (collapse)

- + (::VertxShell::ShellServer) create(vertx = nil, options = nil)
  Create a new shell server with default options.

## Instance Method Summary (collapse)

- - (void) close { ... }
  Close the shell server, this is an asynchronous close.
- - (::VertxShell::Shell) create_shell(term = nil)
  Create a new shell, the returned shell should be closed explicitely.
- - (self) listen { ... }
  Start the shell service, this is an asynchronous start.
- - (self) register_command_resolver(resolver = nil)
  Register a command resolver for this server.
- - (self) register_term_server(termServer = nil)
  Register a term server to this shell server, the term server lifecycle methods are managed by this shell server.

## Class Method Details

### + (`::VertxShell::ShellServer`) create(vertx = nil, options = nil)

Create a new shell server with default options.

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the vertx
- options (`Hash`) (defaults to: `nil`) —
  the options

Returns:

- (`::VertxShell::ShellServer`) —
  the created shell server

Raises:

- (`ArgumentError`)

    33
    34
    35
    36
    37
    38
    39
    40
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/shell_server.rb', line 33

    def self.create(vertx=nil,options=nil)
      if vertx.class.method_defined?(:j_del) && !block_given? && options == nil
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtShell::ShellServer.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxShell::ShellServer)
      elsif vertx.class.method_defined?(:j_del) && options.class == Hash && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtShell::ShellServer.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtShell::ShellServerOptions.java_class]).call(vertx.j_del,Java::IoVertxExtShell::ShellServerOptions.new(::Vertx::Util::Utils.to_json_object(options))),::VertxShell::ShellServer)
      end
      raise ArgumentError, "Invalid arguments when calling create(vertx,options)"
    end

## Instance Method Details

### - (`void`) close { ... }

This method returns an undefined value.

Close the shell server, this is an asynchronous close.

Yields:

- handler for getting notified when service is stopped

Raises:

- (`ArgumentError`)

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

    def close
      if !block_given?
        return @j_del.java_method(:close, []).call()
      elsif block_given?
        return @j_del.java_method(:close, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
      end
      raise ArgumentError, "Invalid arguments when calling close()"
    end

### - (`::VertxShell::Shell`) create_shell(term = nil)

Create a new shell, the returned shell should be closed explicitely.

Parameters:

- term (`::VertxShell::Term`) (defaults to: `nil`) —
  the shell associated terminal

Returns:

- (`::VertxShell::Shell`) —
  the created shell

Raises:

- (`ArgumentError`)

    64
    65
    66
    67
    68
    69
    70
    71
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/shell_server.rb', line 64

    def create_shell(term=nil)
      if !block_given? && term == nil
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createShell, []).call(),::VertxShell::Shell)
      elsif term.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:createShell, [Java::IoVertxExtShellTerm::Term.java_class]).call(term.j_del),::VertxShell::Shell)
      end
      raise ArgumentError, "Invalid arguments when calling create_shell(term)"
    end

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

Start the shell service, this is an asynchronous start.

Yields:

- handler for getting notified when service is started

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

    def listen
      if !block_given?
        @j_del.java_method(:listen, []).call()
        return self
      elsif block_given?
        @j_del.java_method(:listen, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling listen()"
    end

### - (`self`) register_command_resolver(resolver = nil)

Register a command resolver for this server.

Parameters:

- resolver (`::VertxShell::CommandResolver`) (defaults to: `nil`) —
  the resolver

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

    def register_command_resolver(resolver=nil)
      if resolver.class.method_defined?(:j_del) && !block_given?
        @j_del.java_method(:registerCommandResolver, [Java::IoVertxExtShellCommand::CommandResolver.java_class]).call(resolver.j_del)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling register_command_resolver(resolver)"
    end

### - (`self`) register_term_server(termServer = nil)

Register a term server to this shell server, the term server lifecycle methods are managed by this shell server.

Parameters:

- termServer (`::VertxShell::TermServer`) (defaults to: `nil`) —
  the term server to add

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

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