Page 1 of 1

Passing Java objects?

PostPosted: Fri Jan 08, 2021 9:12 am
by bcole
Good day all,

I'm playing around with trying to demonstrate snippets of Java code with Opaque Behaviors in the Simulation Toolkit. I would like to be able to pass Java objects on pins but untyped output pins only send Strings. Is there an appropriate Class or Block from a library to use to have the pin retain the in-memory Java object to pass to into the Opaque Behavior? Or must I convert fUML.Kernel.Object_ into the desired Java object with ALH type calls?

In the attached model, the intent is for the opaque action to have access to a runtime Java object rather than a String.



Re: Passing Java objects?

PostPosted: Sat Jan 09, 2021 8:15 am
by bcole
I do want to note that I do have a somewhat clunky workaround be progressively serializing and deserializing these Java objects for different chunks of the code in my opaque behaviors using the Jackson API.

Re: Passing Java objects?

PostPosted: Mon Jan 11, 2021 8:01 am
by arnon_l

Values that could be passed on pins must be fUML values (based on fUML standard to execute UML Activity).

The sample of fUML values are:
- fUML.Semantics.Classes.Kernel.Object_ to store fUML object
- fUML.Semantics.Classes.Kernel.StringValue to store String value
- fUML.Semantics.Classes.Kernel.ElementValue to store UML element value
- and etc.

Unfortunately, there is no fUML values for Java object.
So using Java Serialization and Deserialization as you did would be a possible workaround(but not convenient) to pass Java object on pins.


Re: Passing Java objects?

PostPosted: Tue Jan 12, 2021 7:26 am
by bcole
Thanks for the rapid reply. I appreciate it. The serialization / deserialization works okay in this use case which is enhancing the visibility of code block tests so I'm okay with this answer.