5, example
As a summary, look at an example. Suppose you want to create a measured scale; these ticks are available on the Earth, Venus and Mars. Here is a problem: gravity on each planet is different. This must be flexible to handle this issue in order to ensure that they can get the right weight. Here is an integral part of the IOC:
l Components.xml (IOC profile)
l scale.java (interface of all components)
l Scaleaware.java (Enabler interface)
l MarscaleImpl.java (component)
l VenusScaleImpl.java (components)
l EarthscaleImpl.java (component)
l ScaleAction.java (Action class)
Below is an example of MarsScaleImpl registration in Components.xml:
component>
components>
Below is the code of the Action class, which implements the Scaleaware interface:
Public Class ScaleAction Implements Action, Scaleaware
{
Private scale scale;
Public void setscale (Scale Scale)
{
THIS.SCALE = Scale;
}
Public String Execute () THROWS EXCEPTION
{
System.out.println ("The Weight of You IS:" Scale.GetWeight ());
RETURN SUCCESS;
}
}
Now, for the scale sold on Mars, as long as it will set