You are not logged in. Click here to log in.

Application Lifecycle Management

Search In Project

Search inClear

Tags:  not added yet

Component Info

Incorporating a non-OMS component into the OMS framework without adding content to the component.

Concept

In this example the 'ComputePOJOCompInfo' class carries the OMS annotations for the 'ComputePOJO'class, which contains no annotations. This demonstrates the separation of an annotated class and a legacy class not previously developed using OMS. The legacy class can even be compiled.

Implementation

The non-OMS component 'ComputePOJO' consumes 'param' and prints the value.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
package ex12;

/**
 *
 * @author od
 */
public class ComputePOJO {

    public double param;

    public void run() {
        System.out.println(param);
    }
}

The OMS component 'ComputePOJOCompInfo' written as an abstract class contains the requisite OMS annotations for consuming 'param' and executing the non-OMS component 'ComputePOJO'.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
package ex12;

import oms3.annotations.*;

/**
 *
 * @author od
 */
public abstract class ComputePOJOCompInfo {

    @In public double param;

    @Execute
    abstract public void run();
}

In the simulation non-OMS 'ComputePOJO' is declared as the model component, and as noted in the simulation file comments, when simulation initiates OMS will find the OMS component abstract class and merge the two components.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import static oms3.SimBuilder.instance as OMS3

OMS3.sim {
   model {
       parameter {
            'c.param' 4.6
       }

       components {
           // Referencing the POJO, OMS will pick up the abstract ~CompInfo class
           // is present and 'merge' both together.
           'c' 'ex12.ComputePOJO'
       }
    }
}