Communication between Features¶
Features can communicate together through the use of Shared Interfaces. This mechanism is described in Shared Interfaces section.
For Applications to use the Shared Interface mechanism, a Kernel must provide:
- an API for a first Application to register its Shared Interface, and for a second Application to get a proxy on it
- a set of registered Kernel types converters
Kernel Service Registry¶
Although an Application can use another Application instance of a Shared Interface, it must, first, be provided a reference (a proxy of the other Application instance).
For that, a Kernel must provide an API for Applications to register and retrieve instances of shared interface: a KF service registry. Such registry can be implemented using the Kernel.bind() KF API to create a proxy for the requesting consumer Application.
Note that this can also be used for an Application instance of a Kernel type. In this case, a Converter must be defined and the converted instance is returned instead of creating a proxy.
An implementation of such KF service registry is provided by the Wadapps multisandbox implementation.
Kernel Types Converter¶
The Shared Interface mechanism allows to transfer an object instance of a Kernel type from one Feature to an other (see Transferable Types section).
To do that, the Kernel must register a new Kernel type converter. See the Converter class and Kernel.addConverter() method for more details.
The table below shows some converters defined in the com.microej.library.util#kf-util library.
Type | Converter Class | Conversion Rule |
---|---|---|
java.lang.Boolean | BooleanConverter | Clone by copy |
java.lang.Byte | ByteConverter | Clone by copy |
java.lang.Character | CharacterConverter | Clone by copy |
java.lang.Short | ShortConverter | Clone by copy |
java.lang.Integer | IntegerConverter | Clone by copy |
java.lang.Float | FloatConverter | Clone by copy |
java.lang.Long | LongConverter | Clone by copy |
java.lang.Double | DoubleConverter | Clone by copy |
java.lang.String | StringConverter | Clone by copy |
java.io.InputStream | InputStreamConverter | Create a Proxy reference |
java.util.Date | DateConverter | Clone by copy |
java.util.List<T> | ListConverter | Clone by copy with recursive element conversion |
java.util.Map<K,V> | MapConverter | Clone by copy with recursive keys and values conversion |