lib/javonet-ruby-sdk/Binaries/Perl/MacOs/X64/lib/Javonet/Sdk/Internal/InvocationContext.pm in javonet-ruby-sdk-2.1.8 vs lib/javonet-ruby-sdk/Binaries/Perl/MacOs/X64/lib/Javonet/Sdk/Internal/InvocationContext.pm in javonet-ruby-sdk-2.1.9
- old
+ new
@@ -2,11 +2,11 @@
use strict;
use warnings FATAL => 'all';
use Moose;
use aliased 'Javonet::Core::Handler::PerlHandler' => 'PerlHandler';
-use aliased 'Javonet::Core::Interpreter::Interpreter' => 'Interpreter';
+use aliased 'Javonet::Core::Interpreter::Interpreter' => 'Interpreter', qw(execute_);
use aliased 'Javonet::Core::Exception::ExceptionThrower' => 'ExceptionThrower';
extends 'Javonet::Sdk::Internal::Abstract::AbstractInstanceContext',
'Javonet::Sdk::Internal::Abstract::AbstractMethodInvocationContext',
'Javonet::Sdk::Internal::Abstract::AbstractInvocationContext';
@@ -15,76 +15,76 @@
sub new {
my $class = shift;
my $self = {
- runtime_lib => shift,
- connection_type => shift,
- tcp_address => shift,
- current_command => shift,
- isExecuted => shift
+ runtime_name => shift,
+ connection_type => shift,
+ tcp_address => shift,
+ current_command => shift,
+ isExecuted => shift,
+ response_command => 0,
};
+
bless $self, $class;
return $self;
}
DESTROY {
my $self = $_[0];
-
if ($self->{current_command}->{command_type} == Javonet::Sdk::Core::PerlCommandType::get_command_type('Reference') &&
$self->{isExecuted} == 1) {
$self->{current_command} = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('DestructReference'),
payload => $self->{current_command}->{payload}
);
$self->execute();
}
}
#@override
sub execute {
my $self = $_[0];
- my $response;
- if ($self->{runtime_lib} == Javonet::Sdk::Core::RuntimeLib::get_runtime('Perl')) {
- $response = $perl_handler->handle_command($self->{current_command});
+
+ if($self->{current_command}->{runtime} eq Javonet::Sdk::Core::RuntimeLib::get_runtime('Perl')) {
+ $self->{response_command} = $perl_handler->handle_command($self->{current_command});
+ } else {
+ $self->{response_command} = Interpreter->execute_($self->{current_command}, $self->{connection_type}, $self->{tcp_address});
}
- else {
- $response = Interpreter->execute_($self->{current_command}, $self->{connection_type}, $self->{tcp_address});
- }
- if ($response->{command_type} == Javonet::Sdk::Core::PerlCommandType::get_command_type('Exception')) {
- ExceptionThrower->throwException($response)
+ if ($self->{response_command}->{command_type} == Javonet::Sdk::Core::PerlCommandType::get_command_type('Exception')) {
+ ExceptionThrower->throwException($self->{response_command})
}
if ($self->{current_command}->{command_type} == Javonet::Sdk::Core::PerlCommandType::get_command_type('CreateClassInstance')) {
- $self->{current_command} = $response;
+ $self->{current_command} = $self->{response_command};
$self->{isExecuted} = 1;
return $self;
}
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
- $response,
+ $self->{response_command},
1
);
}
#@override
sub invoke_instance_method {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('InvokeInstanceMethod'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
@@ -92,16 +92,16 @@
#@override
sub get_instance_field {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('GetInstanceField'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
@@ -109,16 +109,16 @@
#@override
sub set_instance_field {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('SetInstanceField'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
@@ -126,16 +126,16 @@
#@override
sub create_instance {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('CreateClassInstance'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
@@ -143,16 +143,16 @@
#@override
sub invoke_static_method {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('InvokeStaticMethod'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
@@ -164,16 +164,16 @@
#@override
sub get_static_field {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('GetStaticField'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
@@ -181,139 +181,150 @@
#@override
sub set_static_field {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('SetStaticField'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
}
sub get_index {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('ArrayGetItem'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
}
sub get_size {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('ArrayGetSize'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
}
sub get_rank {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('ArrayGetRank'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
}
sub set_index {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('ArraySetItem'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
}
sub invoke_generic_static_method {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('InvokeGenericStaticMethod'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
}
sub invoke_generic_method {
my ($self, @arguments) = @_;
my $command = Javonet::Sdk::Core::PerlCommand->new(
- runtime => $self->{runtime_lib},
+ runtime => $self->{runtime_name},
command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('InvokeGenericMethod'),
payload => \@arguments
);
return Javonet::Sdk::Internal::InvocationContext->new(
- $self->{runtime_lib},
+ $self->{runtime_name},
$self->{connection_type},
$self->{tcp_address},
$self->build_command($command),
0
);
}
+sub get_current_command {
+ my $self = shift;
+ return $self->{current_command};
+}
+
#@override
sub get_value {
my $self = shift;
return $self->{current_command}->{payload}[0]
}
sub build_command {
my ($self, $command) = @_;
- my $command_payload_length = @{$self->{current_command}->{payload}};
+ my $command_payload_length = @{$command->{payload}};
for (my $i = 0; $i < $command_payload_length; $i++) {
- if (blessed($self->{current_command}->{payload}[$i]) and $self->{current_command}->{payload}[$i]->isa('Javonet::Sdk::Internal::InvocationContext')) {
- $self->{current_command}->{payload}[$i] = $self->{current_command}->{payload}[$i]->current_command;
- }
+ $command->{payload}[$i] = $self->encapsulate_payload_item($command->{payload}[$i]);
}
+ return $command->prepend_arg_to_payload($self->{current_command});
+}
- if (!defined $self->{current_command}) {
- return $command;
- }
- else {
- return $command->add_arg_to_payload_on_beginning($self->{current_command});
+sub encapsulate_payload_item {
+ my ($self, $payload_item) = @_;
+ if (blessed($payload_item) and $payload_item->isa('Javonet::Sdk::Internal::InvocationContext')) {
+ # return Javonet::Sdk::Core::PerlCommand->new(
+ # runtime => $self->{runtime_name},
+ # command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('Value'),
+ # payload => $payload_item->get_current_command(),
+ # );
+ return $payload_item->get_current_command();
+ } else {
+ return $payload_item;
}
}
no Moose;
1;
\ No newline at end of file