Class: ConfigRuntimeFactory

Inherits:
AbstractConfigRuntimeFactory show all
Defined in:
lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb

Overview

The ConfigRuntimeFactory class implements the AbstractConfigRuntimeFactory interface and provides methods for creating runtime contexts. Each method corresponds to a specific runtime (CLR, JVM, .NET Core, Perl, Ruby, Node.js, Python) and returns a RuntimeContext instance for that runtime. # @see Refer to this article on Javonet Guides

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ConfigRuntimeFactory

Returns a new instance of ConfigRuntimeFactory.



11
12
13
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 11

def initialize(path)
  @path = path
end

Instance Method Details

#clr(config_name = "default") ⇒ RuntimeContext

Creates a RuntimeContext instance to interact with CLR runtime.

Parameters:

  • config_name (String) (defaults to: "default")

    The name of the configuration to use.

Returns:

See Also:

  • to this {https://www.javonet.com/guides/v2/ruby/foundations/runtime-context article on Javonet Guides}


19
20
21
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 19

def clr(config_name = "default")
  get_runtime_context(RuntimeName::CLR, config_name)
end

#get_runtime_context(runtime, config_name) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 71

def get_runtime_context(runtime, config_name)
  jfr = JsonFileResolver.new(@path)

  begin
    license_key = jfr.get_license_key
    Transmitter.activate_with_credentials(license_key)
  rescue
    # licenseKey not found - do nothing
  end

  conn_type = jfr.get_channel_type(RuntimeNameHandler.get_name(runtime), config_name)
  if conn_type == "tcp"
    conn_data = TcpConnectionData.new(jfr.get_channel_host(RuntimeNameHandler.get_name(runtime), config_name),
                                      jfr.get_channel_port(RuntimeNameHandler.get_name(runtime), config_name))
    return RuntimeContext.get_instance(runtime, ConnectionType::TCP, conn_data)
  elsif conn_type == "inMemory"
    return RuntimeContext.get_instance(runtime, ConnectionType::IN_MEMORY, nil)
  else
    raise "Invalid connection type"
  end
end

#jvm(config_name = "default") ⇒ RuntimeContext

Creates a RuntimeContext instance to interact with JVM runtime.

Parameters:

  • config_name (String) (defaults to: "default")

    The name of the configuration to use.

Returns:

See Also:

  • to this {https://www.javonet.com/guides/v2/ruby/foundations/runtime-context article on Javonet Guides}


27
28
29
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 27

def jvm(config_name = "default")
  get_runtime_context(RuntimeName::JVM, config_name)
end

#netcore(config_name = "default") ⇒ RuntimeContext

Creates a RuntimeContext instance to interact with .NET runtime.

Parameters:

  • config_name (String) (defaults to: "default")

    The name of the configuration to use.

Returns:

See Also:

  • to this {https://www.javonet.com/guides/v2/ruby/foundations/runtime-context article on Javonet Guides}


35
36
37
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 35

def netcore(config_name = "default")
  get_runtime_context(RuntimeName::NETCORE, config_name)
end

#nodejs(config_name = "default") ⇒ RuntimeContext

Creates a RuntimeContext instance to interact with Node.js runtime.

Parameters:

  • config_name (String) (defaults to: "default")

    The name of the configuration to use.

Returns:

  • (RuntimeContext)

    a RuntimeContext instance for the Node.js runtime

See Also:

  • to this {https://www.javonet.com/guides/v2/ruby/foundations/runtime-context article on Javonet Guides}


59
60
61
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 59

def nodejs(config_name = "default")
  get_runtime_context(RuntimeName::NODEJS, config_name)
end

#perl(config_name = "default") ⇒ RuntimeContext

Creates a RuntimeContext instance to interact with Perl runtime.

Parameters:

  • config_name (String) (defaults to: "default")

    The name of the configuration to use.

Returns:

See Also:

  • to this {https://www.javonet.com/guides/v2/ruby/foundations/runtime-context article on Javonet Guides}


43
44
45
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 43

def perl(config_name = "default")
  get_runtime_context(RuntimeName::PERL, config_name)
end

#python(config_name = "default") ⇒ RuntimeContext

Creates a RuntimeContext instance to interact with Python runtime.

Parameters:

  • config_name (String) (defaults to: "default")

    The name of the configuration to use.

Returns:

  • (RuntimeContext)

    a RuntimeContext instance for the Python runtime

See Also:

  • to this {https://www.javonet.com/guides/v2/ruby/foundations/runtime-context article on Javonet Guides}


67
68
69
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 67

def python(config_name = "default")
  get_runtime_context(RuntimeName::PYTHON, config_name)
end

#ruby(config_name = "default") ⇒ RuntimeContext

Creates a RuntimeContext instance to interact with Ruby runtime.

Parameters:

  • config_name (String) (defaults to: "default")

    The name of the configuration to use.

Returns:

See Also:

  • to this {https://www.javonet.com/guides/v2/ruby/foundations/runtime-context article on Javonet Guides}


51
52
53
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 51

def ruby(config_name = "default")
  get_runtime_context(RuntimeName::RUBY, config_name)
end