Class: ConfigRuntimeFactory
- Inherits:
-
AbstractConfigRuntimeFactory
- Object
- AbstractConfigRuntimeFactory
- ConfigRuntimeFactory
- 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
-
#clr(config_name = "default") ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with CLR runtime.
- #get_runtime_context(runtime, config_name) ⇒ Object
-
#initialize(path) ⇒ ConfigRuntimeFactory
constructor
A new instance of ConfigRuntimeFactory.
-
#jvm(config_name = "default") ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with JVM runtime.
- #load_modules(runtime, config_name, jfr, rtm_ctx) ⇒ Object
-
#netcore(config_name = "default") ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with .NET runtime.
-
#nodejs(config_name = "default") ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Node.js runtime.
-
#perl(config_name = "default") ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Perl runtime.
-
#python(config_name = "default") ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Python runtime.
-
#ruby(config_name = "default") ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with Ruby runtime.
Constructor Details
#initialize(path) ⇒ ConfigRuntimeFactory
Returns a new instance of ConfigRuntimeFactory.
12 13 14 |
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 12 def initialize(path) @path = path end |
Instance Method Details
#clr(config_name = "default") ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with CLR runtime.
20 21 22 |
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 20 def clr(config_name = "default") get_runtime_context(RuntimeName::CLR, config_name) end |
#get_runtime_context(runtime, config_name) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 72 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)) rtm_ctx = RuntimeContext.get_instance(runtime, ConnectionType::TCP, conn_data) elsif conn_type == "inMemory" rtm_ctx = RuntimeContext.get_instance(runtime, ConnectionType::IN_MEMORY, nil) else raise "Invalid connection type" end load_modules(runtime, config_name, jfr, rtm_ctx) rtm_ctx end |
#jvm(config_name = "default") ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with JVM runtime.
28 29 30 |
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 28 def jvm(config_name = "default") get_runtime_context(RuntimeName::JVM, config_name) end |
#load_modules(runtime, config_name, jfr, rtm_ctx) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 96 def load_modules(runtime, config_name, jfr, rtm_ctx) modules = jfr.get_modules(RuntimeNameHandler.get_name(runtime), config_name) .split(';') .reject(&:empty?) config_directory_absolute_path = File.dirname(@path) modules.each do |mod| if Pathname.new(mod).absolute? rtm_ctx.load_library(mod) else rtm_ctx.load_library(File.join(config_directory_absolute_path, mod)) end end end |
#netcore(config_name = "default") ⇒ RuntimeContext
Creates a RuntimeContext instance to interact with .NET runtime.
36 37 38 |
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 36 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.
60 61 62 |
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 60 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.
44 45 46 |
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 44 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.
68 69 70 |
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 68 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.
52 53 54 |
# File 'lib/javonet-ruby-sdk/sdk/config_runtime_factory.rb', line 52 def ruby(config_name = "default") get_runtime_context(RuntimeName::RUBY, config_name) end |