Previous Topic

Next Topic

Book Contents

Book Index

Factories

The factories allow dynamic creation and registration of FunctionalItem OSGi services.

Overview

Functional Item Factory

FunctionalItemFactory allows dynamic creation and registration of FunctionalItem OSGi services. Each factory should be registered as a FunctionalItem with additional service registration property supportedClasses, that defines the supported main functional item interfaces. That means that the factory should provide:

Each FunctionalItemFactory should be a ServiceFactory also in order to allow removal of its functional items only. Furthermore, each factory is responsible for the management of the functional items that are created and registered by a concrete user. It is not acceptable to be possible for everyone to remove the registered functional items by other users unless, they have all permissions.

Type Factory

TypeFactory is used for dynamic creation of custom types, ones that could not be automatically created by FIM, i.e. used on beans creation instead of bean constructor invocation. For more information, please refer to Defining Functional Items, under Supported Types. For registration management of functional items, FunctionalItemFactory services should be used.

Each factory should be registered as a service in the registry with additional service registration property supportedClasses, that defines the set of types which instances could be created by the factory. That means that the factory should provide:

Prefix "+" is used to mark that all extensions of a supported class are also supported.

For example use:

The "service.ranking" service property could be used to set the priority of the factory that should be used by FIM utilities. That means that if there are several registered factories that support same type, the factory with the highest ranking will be used on type instances creation. Factories are dynamic and may be deleted or new ones may be introduced. Therefore in order to determine which Factory will be used for the type creation such ranking is needed.

Number Type Factory

FIM provides a type factory in order to enable creation of number instances of any type. So, actually, the NumberTypeFactory extends the FIM supported types with java.lang.Number type. More information on the FIM supported types can be found under Supported Types.

The factory is provided by com.prosyst.mbs.fim.core.jar bundle and has fim:number:factory UID. It requires one creation property called value and its value should be the string representation of the number that should be created.

So when a string representing a number is typed on change of java.lang.Number type property or as an operation java.lang.Number argument, the FIM applications will be able to call FIM Utilities and use a proper number created by the factory. The exact number instance type is detected by the factory during the string parsing. So when the creation property value is "0" it will create java.lang.Integer, while for "0.0" it will create a java.lang.Double.

If the expected custom number type is not one of the built-in fundamental java numeric types, there is a className creation property provided:

All numbers of NUMERIC metadata type are still created and persisted by their sting value only. The other numbers are created by the valueOf(String) static method of the specified class.