Component '@Name' Alias
Annotating alternative names to components.
Concept
Modelers using OMS may incorporate components from other models and apply the '@Name' annotation to reduce verbosity or provide a more meaningful context to the component when connecting components in the simulation file.
Implementation
In this example an '@Name' alias is used instead of a fully qualified Java package name for component class declaration. Here 'Component' has been given the alias 'Greetings' (line 9). The component prints out the contents of the 'message' parameter.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 |
package ex07;
import oms3.annotations.*;
/**
*
* @author od
*/
@Name("Greetings")
public class Component {
@In public String message;
@Execute
public void run() {
System.out.println(message);
}
}
|
In order to use the 'Greetings' alias, the simulation file must specify the .jar files to be included in the simulation. Also please note the cautions in the simulation file comments below.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 |
import static oms3.SimBuilder.instance as OMS3
OMS3.sim {
// need to specify the jar files as a simulation resource.
// this way you can name an @Name alias for a component.
resource "$oms_prj/dist/*.jar"
model {
parameter {
'c.message' "Greet the World ..."
}
components {
// the component has the @Name("Greetings") annotation,
// the name can be used as an alias for the full qualified class
// name. be careful with this feature. It is hard to track, which
// class is being use. This feature is targeted for IDEs mainly.
'c' 'Greetings'
}
}
}
|