The java instruction is used to embed Java source code within Obix source code.
For more information about embedded Java, please refer to Chapter 10, Embedded Java source code.
Table 8.31. java syntax
| Production | Syntax | Links |
|---|---|---|
java_instruction |
| the section called “java instruction” |
Example 8.26. java example
service instruction_examples
command embedded_java_example
script
var string hello_from_java = "Hello from Java"
var string hello_from_obix
java
// access variable defined in Obix code
System.out.println(v_hello_from_java.a_value_get().java_value());
// use Obix service
li_obix.li_system.li_user_interface.se_console.co_message_command(v_hello_from_java);
// assign value to variable defined in Obix code
v_hello_from_obix = new fa_string("Hello from Obix");
end java
// display value defined in Java code
se_console.co_message ( v_hello_from_obix )
end script
end command
end serviceThe above code displays the following on the system console:
Hello from Java Hello from Java Hello from Obix